-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom callback #55
Comments
@richjenks I currently have a custom layer on top of KLogger which sends out an email alarm if a critical or error level is detected. Also, it's able to parse the logfile to a database so yes I think this could be a nice feature! Let me know if you need any help as you might be able to get some inspiration of my codebase. |
@onno-vos-dev I do the same thing too and thought it would feel cleaner as a callback rather than a wrapper class. It would at least decouple the logger and custom code a bit. Is your custom layer available online so I can have a look? I have a basic idea of how this would work but would appreciate a use-case for perspective. |
@richjenks I'll email you tonight or on the weekend. :) Email from your Git page ok? |
@onno-vos-dev thanks and yep, email on my profile is correct, I'll keep an eye out for it :) |
katzgrau#55 Implementation is simple: an array holds registered callables and, when a log is written, they are called one-by-one and passed an array of info about both the `Loggger` object and the current log item.
Would it not be a better implementation to use filters: callbacks would have a list of rules, if each rule is met, then the callback is called? Of course, a callback could not have any rule. |
Does anyone think the addition of custom callback feature would be of value? It could be passed the
Logger
object and/orLogger::lastLine
and would open a lot of possibilities, for example:notice
or higheremergency
issues to a separate fileThe developer would have to write the implementations themself (e.g. database connections) but custom callbacks might be a good way to allow advanced logging features without affecting how easy-to-use the basic functions are.
If people think this is of value I'll look into this feature.
The text was updated successfully, but these errors were encountered: