Skip to content

Implement Tags in Log Class #58

@kestivvi

Description

@kestivvi

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,network

Then, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: 🙂🙂Below average taskscope: 🛠️it's job for developerstype: enhancementnew functionality or improvement for the inside, but not the outside

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions