Module: LunaPark::Notifiers::Log::Formatters
- Defined in:
- lib/luna_park/notifiers/log/formatters.rb
Constant Summary collapse
- SINGLE =
-
SINGLE - output is a single line string message.
notifier = LunaPark::Notifiers::Log.new(formatter: LunaPark::Notifiers::Log::Formatters::SINGLE) notifier.info('You hear', dog: 'wow', cats: {chloe: 'mow', timmy: 'mow'}) # I, [2022-09-29T10:51:15.753646 #28763] INFO -- : String - You hear {:dog=>"wow", :cats=>{:chloe=>"mow", :timmy=>"mow"}}
-
lambda do |klass, , details = {}| details.empty? ? "#<#{klass}> #{}" : "#<#{klass}> #{} #{details}" end
- MULTILINE =
-
MULTILINE - this format may become more preferred for development mode.
notifier = LunaPark::Notifiers::Log.new(formatter: LunaPark::Notifiers::Log::Formatters::MULTILINE) notifier.info('You hear', dog: 'wow', cat: {timmy:'purr'}, cow: 'moo', duck: 'quack', horse: 'yell' ) # I, [2022-09-29T10:56:21.463211 #28763] INFO -- : {:class=>String, # :message=>"You hear", # :details=> # {:dog=>"wow", # :cat=>{:timmy=>"purr"}, # :cow=>"moo", # :duck=>"quack", # :horse=>"yell"}}
-
lambda do |klass, , details = {}| PP.pp({ class: klass, message: , details: details }, '') end
- JSON =
-
JSON - this format should be good choose for logger which be processed by external logger system
notifier = LunaPark::Notifiers::Log.new(formatter: LunaPark::Notifiers::Log::Formatters::JSON) notifier.info('You hear', dog: 'wow', cats: {chloe: 'mow', timmy: 'mow'}) # I, [2022-09-29T12:00:47.600052 #90508] INFO -- : {"class":"String", "message":"You hear", # "details":{"dog":"wow","cats":{"chloe":"mow","timmy":"mow"}}}
-
lambda do |klass, , details = {}| ::JSON.generate(class: klass, message: , details: details) end
- PRETTY_JSON =
-
PRETTY_JSON - pretty json output
notifier = LunaPark::Notifiers::Log.new(formatter: LunaPark::Notifiers::Log::Formatters::PRETTY_JSON) notifier.info('You hear', dog: 'wow', cat: {timmy:'purr'}, cow: 'moo', duck: 'quack', horse: 'yell') # I, [2022-09-29T12:02:25.236301 #90508] INFO -- : { # "class": "String", # "message": "You hear", # "details": { # "dog": "wow", # "cat": { # "timmy": "purr" # }, # "cow": "moo", # "duck": "quack", # "horse": "yell" # }
-
lambda do |klass, , details = {}| ::JSON.pretty_generate(class: klass, message: , details: details) end