Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration for logger #64

Merged
merged 1 commit into from
Jan 25, 2025

Conversation

keis
Copy link
Contributor

@keis keis commented Jan 25, 2025

Makes it possible to configure

  • log file (or explicit stderr logging using "-")
  • log level

Log level doesn't do much but I think it's a sensible thing to have.

On a related note it would be more idiomatic to use log.Debug and let logrus sort it out rather than using a custom if d.Debug { ... }. It's a more controversial change though and maybe there's some context I'm missing that makes that preferable.

If you think it's a good idea I can add that too

@jurkovic-nikola
Copy link
Owner

jurkovic-nikola commented Jan 25, 2025

Hello, please modify your code to include proper JSON values, so IDE doesn't dump warnings about fields.

LogLevel log.Level json:"logLevel"``

There is no reason to have LogFile config field, since you placed omit omitempty and never initialized variable in upgrade process, so this will always default to "". Instead of manipulation of logging file, if you don't want logging into a file, define config field for console or file logging.

d.Debug is there for a debug purpose, since when you flip this value, all packet sent towards device and vice versa will be logged, this will scale to 1000 lines of log under 1 minute if you have couple of devices in your system.

And LogLevel do much, if you set this to error, you'll never have any warnings logged or anything bellow the error level.

Makes it possible to configure
 * log file (or explicit stderr logging using "-")
 * log level
@keis
Copy link
Contributor Author

keis commented Jan 25, 2025

updated!

What I meant regarding the log level is that setting it to info doesn't do much right now as all the debug logging uses the the info level anyway and not, as I would argue would be more appropriate, debug level. For stuff like dumping traffic maybe even trace.

Using those log levels where suitable could make the Debug option kinda redundant.

@jurkovic-nikola jurkovic-nikola merged commit 8b2ecec into jurkovic-nikola:main Jan 25, 2025
1 check passed
@keis keis deleted the logger-config branch January 25, 2025 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants