I support log4r,
For individual scripts (different .rb files), you can approach this in several ways (for example, I know), firstly, remember that the functions that I cover here are available in> = 1.1.4.
One way is to set another PatternFormatter line to the script (if you create a yaml or xml configuration file, you can specify different patterns for each class name).
Another way would be to use one of the GDC, NDC or MDC in PatternFormatter.
GDC will set the "Global Diagnostic Context", that is, this value, which is available for all threads running under the script. You can use it by putting% g in the template and setting the value via GDC.set (String) to get more details: http://log4r.rubyforge.org/manual.html
NDC and MDC are nested and associated diagnostic contexts, respectively. The template for them is to use% x and% X {Symbol | Object} and for their installation via NDC.set (String) and MDC.put (Symbol | Object, Object)
Another way would be to use the% t pattern, which prints the file name and line number where the call was made.
The trade-off between each of these methods is that they are gradually becoming more expensive in using CPU resources. I tend to use GDC first for what you ask.
C gk
source share