-
-
Notifications
You must be signed in to change notification settings - Fork 11
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 logging for ChunkMeta #387
Conversation
return ENABLE_CHUNK_META_LOGS; | ||
} | ||
|
||
@Subcommand("chunkmeta") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is intuitive as a toggle, the command should be something like /cmc togglechunkmetalogs
or /cmc chunkmetalogs true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change that
@CommandAlias("cmc") | ||
public class ChunkMetaCommand extends BaseCommand { | ||
|
||
private static boolean ENABLE_CHUNK_META_LOGS = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command shouldn't hold what's effectively global state itself, there should be some dedicated collection of feature flags be it the config, or secondarily derived from the config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it shouldn't but it was the easiest option for a very accessory feature
if (ChunkMetaCommand.chunkMetaLogsEnabled()) { | ||
logger.info("[Chunkmeta] Unloading chunk " + coord + " - unloaded: " + coord.getLastUnloadedTime()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't be logging with guard conditions like this in modern java, we should be using the appropriate log level and a message supplier to prevent resources spent on extra checks and calculations.
This also makes the above command unnecessary.
e.g.
logger.debug(() -> "[Chunkmeta] Unloading chunk " + coord + " - unloaded: " + coord.getLastUnloadedTime())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some research into this and there's not really any good options for runtime log configuration like that, and since it's temporary I just went for something easy
Build Successful! You can find a link to the downloadable artifact below.
|
Hopefully this can be used to diagnose the issue