Reverse the coupling of module log and config #1606

Merged
konrad merged 9 commits from HoffmannP/api:main into main 2023-10-03 09:28:34 +00:00
Contributor

This way the config module can already use the log module with the same result (default logging to StdOut with Level INFO, same output as before) but ENV variables can already change the logging of config file related log output). It is now possible to dump as a cronjob without having to filter the default log about the used config file.

Also:

  • all logging modules are now configurable when initializing which makes testing easier
  • viper dependency removed from logging
  • log correct settings when configured error level is invalid
  • deprecation of value "false" for log.standard and log.events (already not mentioned in https://vikunja.io/docs/config-options/)
This way the config module can already use the log module with the same result (default logging to StdOut with Level INFO, same output as before) but ENV variables can already change the logging of config file related log output). It is now possible to dump as a cronjob without having to filter the default log about the used config file. Also: - all logging modules are now configurable when initializing which makes testing easier - viper dependency removed from logging - log correct settings when configured error level is invalid - deprecation of value "false" for log.standard and log.events (already not mentioned in https://vikunja.io/docs/config-options/)
HoffmannP added 3 commits 2023-09-26 14:11:25 +00:00
All loggers are configured independently through the constructor
Dependency on viper solely in config module
Minor fixes in error strings in logger constructors
Using config.log.database and config.log.mail instead of values from viper
Typo
Some checks failed
continuous-integration/drone/pr Build is failing
ba79afe29c
HoffmannP changed title from Reversing the coupling of mod log and config to Reversing the coupling of module log and config 2023-09-26 14:13:33 +00:00
HoffmannP changed title from Reversing the coupling of module log and config to Reverse the coupling of module log and config 2023-09-26 14:20:47 +00:00
HoffmannP added 1 commit 2023-09-27 10:00:23 +00:00
Change MkDir to MkDirAll so even subdirs are created
Some checks failed
continuous-integration/drone/pr Build is failing
5af348dbe1
HoffmannP added 1 commit 2023-09-27 13:35:33 +00:00
Author
Contributor

Is the constant "off" something that should be fixed?

Is the constant "off" something that should be fixed?
Owner

Is the constant "off" something that should be fixed?

I think it's sufficient to add it to the ignore list.

> Is the constant "off" something that should be fixed? I think it's sufficient to add it to the ignore list.
konrad reviewed 2023-09-27 15:38:24 +00:00
@ -415,15 +419,17 @@ func InitConfig() {
viper.SetConfigName("config")
err = viper.ReadInConfig()
log.ConfigLogger(LogEnabled.GetBool(), LogStandard.GetString(), LogPath.GetString(), LogLevel.GetString())
Owner

What if reading the config fails? Isn't this call redundant then?

What if reading the config fails? Isn't this call redundant then?
Author
Contributor

You are right, I move it down into the if-branch

You are right, I move it down into the if-branch
@ -41,42 +39,44 @@ const logModule = `vikunja`
// loginstance is the instance of the logger which is used under the hood to log
var logInstance = logging.MustGetLogger(logModule)
// logpath is the path in which log files will be written. This value should actually never be used
Owner

If it's never actually used, why specify it? Please add a comment.

If it's never actually used, why specify it? Please add a comment.
Author
Contributor

Is the constant "off" something that should be fixed?

I think it's sufficient to add it to the ignore list.

Who and which list?

> > Is the constant "off" something that should be fixed? > > I think it's sufficient to add it to the ignore list. Who and which list?
HoffmannP added 2 commits 2023-09-28 09:02:03 +00:00
Owner
This ignore list: https://kolaente.dev/vikunja/api/src/branch/main/.golangci.yml
HoffmannP added 1 commit 2023-09-28 09:53:07 +00:00
Ignore constant "off" recommendation
All checks were successful
continuous-integration/drone/pr Build is passing
21191c0338
HoffmannP added 1 commit 2023-10-01 16:05:15 +00:00
Merge branch 'main' into main
All checks were successful
continuous-integration/drone/pr Build is passing
4f425041ad
konrad approved these changes 2023-10-03 09:28:10 +00:00
konrad left a comment
Owner

Thanks!

Thanks!
konrad merged commit ad04d302af into main 2023-10-03 09:28:34 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: vikunja/vikunja#1606
No description provided.