-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Currently, the Log class in our server app only logs messages with a timestamp, method name, and location. However, it would be useful to be able to add tags to each log message and then specify which messages with which prefix of the tag to display.
For example, if we have tags for "database", "network", and "security", we could specify in the .env file (which is read by the EnvConfig class) which prefixes of these tags we want to display. This would allow us to filter out messages that we don't need to see and focus on the ones that are relevant to us.
Suppose we have three tags: "database", "network", and "security". We want to log messages related to the database and network, but not security. We can specify this in the .env file like so:
LOG_TAGS=database,networkThen, in our code, we can use the Log class like this:
Log.INFO("Connected to database", "database");
Log.WARNING("Failed to connect to server", "network");
Log.INFO("User logged in", "security");The first two messages will be displayed because they have tags that match the prefixes specified in the .env file. The last message will not be displayed because it has a tag that doesn't match any of the prefixes.
This allows us to filter out messages that we don't need to see and focus on the ones that are relevant to us.