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

Improve logging pattern by including caller class name #688

Merged
merged 2 commits into from May 11, 2022
Merged

Improve logging pattern by including caller class name #688

merged 2 commits into from May 11, 2022

Conversation

ghost
Copy link

@ghost ghost commented May 8, 2022

Description

Change logging pattern to include caller class name. This change means that contributors no longer need to remember to manually add prefix for messages they log.

Console pattern is now 13:50:09 <INFO:GameServer> Game Server started on port 22102, while logfile pattern is 2022-05-08T13:50:09Z <INFO:emu.grasscutter.server.game.GameServer> Game Server started on port 22102.

  • Caller class name lookup incurs additional overhead, however since we are not planning on logging tens of thousands messages per second I do not think there is any significance of that.
  • Since pattern now includes shorthand class name, I've tried to adjust it to minimize redundant characters that would artifically make log messages longer. As such, [ ] wrapping around time (date) has been removed, while level has been merged together with class name and wrapping changed to < >.
  • While console uses short-hand version of class name, logfile contains full one.
  • Logfile pattern has been adjusted to mimic that of console, specifically adding verbosity level which was previously missing.

Issues fixed by this PR

N/A

Type of changes

  • Bug fix
  • New feature
  • Enhancement
  • Documentation

Checklist:

  • My code follows the style guidelines of this project
  • My pull request is unique and no other pull requests have been opened for these changes
  • I have read the Contributing note and Code of conduct
  • I am responsible for any copyright issues with my code if it occurs in the future.

@ghost
Copy link

ghost commented May 8, 2022

Not a fan of the long log format to be honest, but lets see what the others think about it.

@ghost ghost requested a review from KingRainbow44 May 8, 2022 12:49
@ghost
Copy link
Author

ghost commented May 8, 2022

By long format you mean one in logfiles? It can be shortened but I thought that it won't make much difference for logfiles and it can help in some rare cases when shortened class name is ambigious.

@gentlespoon
Copy link
Contributor

gentlespoon commented May 9, 2022

Is it going to print the FQCN or just the CN? Personally I like cn, but fq is probably too much. With cn it is usually good enough to locate the source of the log.

@ghost
Copy link
Author

ghost commented May 9, 2022

At the moment it shows CN (ie. GameServer) in console and FQCN in logfiles (ie. emu.grasscutter.server.game.GameServer).

@KingRainbow44 KingRainbow44 added the enhancement New feature or request label May 11, 2022
@KingRainbow44 KingRainbow44 merged commit 69984d7 into Grasscutters:development May 11, 2022
@ghost ghost deleted the patch-3 branch May 13, 2022 00:10
Birdulon pushed a commit to Birdulon/Grasscutter that referenced this pull request Aug 21, 2022
Improve logging pattern by including caller class name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants