FeroxRev / Pokemon-Go-Rocket-API

Client API Library
GNU General Public License v3.0
368 stars 230 forks source link

Logger Suggestions #122

Open disdain13 opened 8 years ago

disdain13 commented 8 years ago

I am going to be using a winforms interface, and the logging will need to be handled differently. I have been trying to use a "pure" implementation of the API, but this is one of the gotchas... the logger. Here are some suggestive options, I like options...

Harder: Please alter the Logger to implement a common interface (ILogger), and expose a singleton and method so the provider can be overridden or modified.It would be more elegant if I could just implement an interface and override the output.

Easier: If you dont wan't to go through that much trouble, expose a public delegate property for the Write() method, with the default delegate value being the current method. Then We could at least "override" this functionality by setting the delegate. This would be real easy.

disdain13 commented 8 years ago

I know you guys have been working really hard for this community. And while I have less knowledge in the pokemon server stuff, I can contribute to this project in ways. Here is a link to my proposed Logger replacement and related classes. Written to be drop in, changing the namespace is all.

https://github.com/disdain13/PokeRoadie/tree/master/PokeRoadie/Logging

disdain13 commented 8 years ago

the usage to get the existing functionality would be:

At application start: Logger.Current.LogProviders.Add(new ConsoleLogProvider()); Logger.Current.LogProviders.Add(new FlatFileLogProvider()); Logger.Current.Initialize();

To write would remain the same, so people won't have to change things: Logger.Write(message,level,color)

But, can also be done with a log entry object: Logger.Current.Write(logEntry);

At application end: Logger.Current.Close();