No commit activity in last 3 years
No release in over 3 years
A generic gem to handle logging for all other telemetry gems
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Telemetry::Logger

A generic gem to handle logging for all other telemetry gems

Setting up the logger

Telemetry::Logger.setup(level: 'warn', color: false, log_file: './telemetry.log')

opts = {
  include_pid: false,
  level: 'info',
  log_file: nil,
  color: true,
  application: 'telemetry',
  app_version: Telemetry::Logger::VERSION
}

Example Logging

Telemetry::Logger.setup(level: 'info')
Telemetry::Logger.info 'test info'

Telemetry::Logger.debug 'test debug'
Telemetry::Logger.warn 'test warn'
Telemetry::Logger.error 'test error'
Telemetry::Logger.fatal 'test fatal'
Telemetry::Logger.unknown 'test unknown'

Example Exception Tracking

Instead of repeating the same error method all over the place for exceptions, you can use the exception method to save on complexity and automatically report exceptions to supported APMs

Telemetry::Logger.setup(level: 'info')
Telemetry::Logger.exception(StandardError.new('test error'), level: 'warn')
Telemetry::Logger.exception(StandardError.new('test error'), level: 'fatal')
Telemetry::Logger.exception(StandardError.new('test error'), handled: true)
Telemetry::Logger.exception(StandardError.new('test error'), backtrace: true)

# options for exception method
opts = {
  level: 'error', # sets the log level
  handled: true, # tells the apms if we handled this exception
  backtrace: true, # should we log the backtrace?
  backtrace_limit: 20, # how many lines should we limit the backtrace to?
  raise: false, # should we reraise this exception instead of swallowing it?
}