I'm trying to enhance my logging system and came up with a concept that seems like it should already exist, but I can't find anything resembling it. Has anyone encountered something similar or know what it might be called?
The idea is to shift from inline logging to a more centralized storage method. For instance, instead of logging something like:
```
log("Success", ['portal','api'], 'task', "Sales numbers are constant, proceeding to report")
```
I envision using a key-based approach like this:
```
log(**gen_kwargs("20.PA.E.2429030A"))
```
Where a database keeps track of the details for the key like this:
```
{
'20.PA.E.2429030A':{
'message':'Sales numbers are constant. Proceeding to report',
'destination': ['portal','api'],
'layer': 'event',
'status_code': 20,
'date_created': "2024-10-15",
'user_attribution': '[email protected]'
}
}
```
The pros of this method include author tracking, version control, and the ability to dynamically update messages. However, the drawbacks are the need for a centralized infrastructure and the added complexity to the code.
It could be a middle-ground approach where key data isn't entirely random and still holds important information. I'm curious whether this kind of mechanism has already been developed or if there's a specific term for it.
3 Answers
I think what you're trying to do is awesome. I’ve seen similar setups in past jobs, but they were usually custom-built. It might be worth keeping control of your logging to cater to your specific needs.
Have you checked out OpenTelemetry? It might give you the framework you need for a centralized logging approach!
I've built a custom logging library that allows for dynamic changes in log levels and destinations, like JSON and SQLite, which works great. Sure, syncing logs can complicate things, but it’s manageable.
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically