Closed cscairns closed 12 years ago
You can most certainly get the name of the class. However, the name of the method is not very accessible in Ruby without incurring a significant performance hit.
The pattern layout can be used to specify how log messages should be formatted when written to the logging destination http://rubydoc.info/gems/logging/1.6.2/Logging/Layouts/Pattern
Each class in your application should have it's own logger. This allows you to identify where the log event came from, and it allows you to set the log level for each class. For instance, you can set just one class to debug and avoid enormous amounts of log messages.
This is just a starting point. Please ask more questions if you have them. There are some example configurations in the logging source code [https://github.com/TwP/logging/tree/master/examples], and all the code is well tested and well documented.
This is a pretty slick gem! I hope that you continue to support it.
One of things that I like to do when logging is to provide the context of the object class and current method caller. For ex:
"WorkerX::a_method - some error went down here"
How can I do this with logging?