chiradeep / go-nitro

A Golang client to the Citrix ADC API
Apache License 2.0
18 stars 21 forks source link

Disable log output #50

Closed jantytgat closed 3 years ago

jantytgat commented 3 years ago

From what I understand, the go-nitro package is outputting DEBUG and TRACE level messages to the console in order to comply with Terraform guidelines for providers.

Is it possible to implement a parameter for the NitroClient to indicate whether or not to output these logs while performing operations. I don't mind if the default value would be set to true, as not to change the current behaviour.

This would also allow me to define the parameter specifically for the client, without having to call log.SetOutput(ioutil.Discard) for the complete program.

chiradeep commented 3 years ago

agreed. shouldn't be tied to usage of the library. will take a look

chiradeep commented 3 years ago

@jantytgat check out this branch use_hclog_instead_oflog.Printf Usage would be client.setLogLevel("WARN") to turn off almost all logs

Code is still incomplete: requires a lot of Printf to be converted to key, value format of hclog @dheerajng @giorgos-nikolopoulos comments please?

jantytgat commented 3 years ago

Hi @chiradeep ,

Thanks for the quick reply, here are my first remarks:

Biggest downside I can see right now is that you are adding an additional external dependency, but on the other hand it is way better than having to add if-statements everywhere to enable/disable logs!

I will have a look at the code itself later today!

giorgos-nikolopoulos commented 3 years ago

LGTM

I would suggest adding a parameter in NitroParams to set the log level through the NewNitroClientFromParams

dheerajng commented 3 years ago

LGTM. Minor comments are provided on the commit.

chiradeep commented 3 years ago

Fixed by #51