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

Allow log.xxx.default to set logging settings for the default logger only #11292

Merged
merged 6 commits into from
May 16, 2020

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented May 4, 2020

In #11269 a user wanted to set the default logger to WARN level but leave the rest of the loggers at Info. The current settings require that in order to set this the user would have to add:

[log.file.macaron]
LEVEL = Info

[log.file.router]
LEVEL = Info

[log.file.access]
LEVEL = Info

for each different type logger they want.

This PR allows the user to set [log.file.default] for settings for the default logger only

Signed-off-by: Andrew Thornton [email protected]

@zeripath zeripath added the type/enhancement An improvement of existing functionality label May 4, 2020
@zeripath zeripath added this to the 1.12.0 milestone May 4, 2020
@codecov-io
Copy link

codecov-io commented May 4, 2020

Codecov Report

Merging #11292 into master will increase coverage by 0.00%.
The diff coverage is 40.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #11292   +/-   ##
=======================================
  Coverage   43.96%   43.96%           
=======================================
  Files         614      614           
  Lines       87426    87428    +2     
=======================================
+ Hits        38437    38438    +1     
- Misses      44251    44253    +2     
+ Partials     4738     4737    -1     
Impacted Files Coverage Δ
modules/setting/log.go 69.64% <40.00%> (+0.27%) ⬆️
services/pull/temp_repo.go 34.18% <0.00%> (-3.42%) ⬇️
modules/git/repo.go 49.79% <0.00%> (-1.26%) ⬇️
models/gpg_key.go 53.95% <0.00%> (+0.52%) ⬆️
modules/queue/unique_queue_disk_channel.go 55.76% <0.00%> (+1.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d54479...8f3709c. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 4, 2020
modules/setting/log.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 5, 2020
@silverwind
Copy link
Member

Maybe add some info about this to app.ini.sample to make it more discoverable?

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 15, 2020
@silverwind
Copy link
Member

silverwind commented May 15, 2020

Logging config still feels like black magic to me (for example, I'm still not sure how to get everything logged to stdout only), but I guess this is fine.

@techknowlogick techknowlogick merged commit 0052d78 into go-gitea:master May 16, 2020
@zeripath zeripath deleted the allow-default-log-settings branch May 16, 2020 07:49
@zeripath
Copy link
Contributor Author

zeripath commented May 16, 2020

@silverwind it's really not difficult:

[log]
MODE = console
LEVEL = debug
ROOT_PATH = /home/andrew/src/go/gitea/log
REDIRECT_MACARON_LOG = true
MACARON = console
ROUTER = console
XORM = console

If, as is sensible, you don't want the SQL being logged - then set:

[database]
LOG_SQL=false

(I agree it's silly that this isn't the default and that the logging of SQL should only occur at DEBUG level but that's a breaking change which we need to discuss and propose on a PR.)

Say you want to have a specific TRACE level logging for a particular file or area:

[log]
MODE = console, traceconsole
...

[log.traceconsole]
MODE=console
LEVEL=trace
EXPRESSION=compare

The expression will attempt a match against the filename:line:caller, or against the message itself

The difficulties come from if you want logging at level WARN or above only - in which case the additional comments I've put in to the document explain why.

[database]
LOG_SQL=false

...

[log]
MODE = console
LEVEL = info
ROOT_PATH = /home/andrew/src/go/gitea/log
REDIRECT_MACARON_LOG = true
MACARON = console
ROUTER = console
XORM = console

[log.console.default]
LEVEL=warn

Then you will only get main gitea logs at WARN but still get ROUTER, MACARON, and XORM info logs.

ydelafollye pushed a commit to ydelafollye/gitea that referenced this pull request Jul 31, 2020
…only (go-gitea#11292)

* Allow log.xxx.default to set logging settings for the default logger only

Signed-off-by: Andrew Thornton <[email protected]>

* Update modules/setting/log.go

* as per @silverwind add some documentation

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants