Module: Lumberjack
- Defined in:
- lib/lumberjack.rb,
lib/lumberjack/rack.rb,
lib/lumberjack/device.rb,
lib/lumberjack/logger.rb,
lib/lumberjack/severity.rb,
lib/lumberjack/template.rb,
lib/lumberjack/formatter.rb,
lib/lumberjack/log_entry.rb,
lib/lumberjack/device/null.rb,
lib/lumberjack/device/writer.rb,
lib/lumberjack/device/log_file.rb,
lib/lumberjack/rack/unit_of_work.rb,
lib/lumberjack/device/rolling_log_file.rb,
lib/lumberjack/formatter/string_formatter.rb,
lib/lumberjack/formatter/inspect_formatter.rb,
lib/lumberjack/device/date_rolling_log_file.rb,
lib/lumberjack/device/size_rolling_log_file.rb,
lib/lumberjack/formatter/exception_formatter.rb,
lib/lumberjack/formatter/pretty_print_formatter.rb
Defined Under Namespace
Modules: Rack, Severity Classes: Device, Formatter, LogEntry, Logger, Template
Constant Summary collapse
- LINE_SEPARATOR =
(Config::CONFIG['host_os'].match(/mswin/i) ? "\r\n" : "\n")
Class Method Summary collapse
-
.unit_of_work ⇒ Object
Define a unit of work within a block.
-
.unit_of_work_id ⇒ Object
Get the UniqueIdentifier for the current unit of work.
Class Method Details
.unit_of_work ⇒ Object
Define a unit of work within a block. Within the block supplied to this method, calling unit_of_work_id
will return the same 12 digit hexadecimal number string. This can then be used for tying together log entries.
For the common use case of treating a single web request as a unit of work, see the Lumberjack::Rack::UnitOfWork class.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lumberjack.rb', line 23 def unit_of_work save_val = Thread.current[:lumberjack_logger_unit_of_work_id] #Thread.current[:lumberjack_logger_unit_of_work_id] = UniqueIdentifier.new Thread.current[:lumberjack_logger_unit_of_work_id] = rand(0xFFFFFFFFFFFF).to_s(16).rjust(12, '0').upcase begin return yield ensure Thread.current[:lumberjack_logger_unit_of_work_id] = save_val end end |
.unit_of_work_id ⇒ Object
Get the UniqueIdentifier for the current unit of work.
35 36 37 |
# File 'lib/lumberjack.rb', line 35 def unit_of_work_id Thread.current[:lumberjack_logger_unit_of_work_id] end |