blish-hud / Blish-HUD

A Guild Wars 2 overlay with extreme extensibility through compiled modules.
https://blishhud.com
MIT License
320 stars 59 forks source link

Added overloads to specify own logger names #888

Closed Tharylia closed 1 year ago

Tharylia commented 1 year ago

This PR aims to enable module developer to specify their own logger names.

My example for the need of this implementation:

The module Event Table can have an "unlimited" amount of event areas on the screen. Each area logs specific data. Currently there is no way to know from which area this log statement comes. The only alternative currently would be to prefix the name of the area on each logger call. This is prone the be forgotten and not the best method.

The new method allows me to specify my own name and results in logs like this:

14:31:12.9626 | DEBUG | Estreya.BlishHUD.EventTable.Controls.EventArea - Main | Added event The Path to Ascension with occurence 28.05.2023 13:30:00 ( Note the name "Main" after the type )

The logger can be created like this: Logger.GetLogger<EventArea>($"{typeof(EventArea).FullName} - {this.Configuration.Name}")

The new implementation does not break existing loggers in any way.

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

dlamkins commented 1 year ago

I'm not sure I see any major value in this change. You can wrap the logger and prefix your messages with the area if this is necessary, but this changes the structure of the log messages and seems like a very specific use case.

Tharylia commented 1 year ago

Alright, I will do that. 👍