class Tng::Gtk::Utils::Logger

Constants

LOGFILE
LOGGER_LEVELS
LOGLEVEL

Private Class Methods

debug(start_stop: '', component:, operation:, message:, status:'', time_elapsed:'') click to toggle source
# File lib/tng/gtk/utils/logger.rb, line 57
def debug(start_stop: '', component:, operation:, message:, status:'', time_elapsed:'')
  generic(type: 'D', start_stop: start_stop, component: component, operation: operation, message: message, status: status, time_elapsed: time_elapsed)
end
error(start_stop: '', component:, operation:, message:, status:'', time_elapsed:'') click to toggle source
# File lib/tng/gtk/utils/logger.rb, line 45
def error(start_stop: '', component:, operation:, message:, status:'', time_elapsed:'')
  generic(type: 'E', start_stop: start_stop, component: component, operation: operation, message: message, status: status, time_elapsed: time_elapsed)
end
fatal(start_stop: '', component:, operation: , message:, status:'', time_elapsed:'') click to toggle source
# File lib/tng/gtk/utils/logger.rb, line 54
def fatal(start_stop: '', component:, operation: , message:, status:'', time_elapsed:'')
  generic(type: 'F', start_stop: start_stop, component: component, operation: operation, message: message, status: status, time_elapsed: time_elapsed)
end
generic(type:, start_stop:, component:, operation:, message:, status:, time_elapsed:) click to toggle source
# File lib/tng/gtk/utils/logger.rb, line 65
def generic(type:, start_stop:, component:, operation:, message:, status:, time_elapsed:) 
  message = {
    type: type,                 # mandatory, can be I(nfo), W(arning), D(ebug), E(rror), F(atal) or U(nknown)
    app_timestamp: Time.now.utc.strftime("%Y-%m-%e %H:%M:%S.%6N %Z" ), # mandatory, with miliseconds
    start_stop: start_stop,     # optional, can be empty, 'START' or 'STOP'
    component: component,       # mandatory
    operation: operation,       # mandatory
    message: message,           # mandatory
    status: status,             # optional, makes sense for start_stop='END'
    time_elapsed: time_elapsed  # optional, makes sense for start_stop='END'
  }
  LOGFILE.puts "#{message.to_json}" if log?(type)
  message
end
info(start_stop: '', component:, operation:, message:, status:'', time_elapsed:'') click to toggle source
# File lib/tng/gtk/utils/logger.rb, line 51
def info(start_stop: '', component:, operation:, message:, status:'', time_elapsed:'')
  generic(type: 'I', start_stop: start_stop, component: component, operation: operation, message: message, status: status, time_elapsed: time_elapsed)
end
log?(level) click to toggle source
# File lib/tng/gtk/utils/logger.rb, line 80
def log?(level)
  LOGGER_LEVELS.index(level) >= LOGGER_LEVELS.index(LOGLEVEL[0].upcase)
end
unknown(start_stop: '', component:, operation: , message:, status:'', time_elapsed:'') click to toggle source
# File lib/tng/gtk/utils/logger.rb, line 60
def unknown(start_stop: '', component:, operation: , message:, status:'', time_elapsed:'')
  generic(type: 'U', start_stop: start_stop, component:  component, operation: operation, message: message, status: status, time_elapsed: time_elapsed)
end
warning(start_stop: '', component:, operation: , message:, status:'', time_elapsed:'') click to toggle source
# File lib/tng/gtk/utils/logger.rb, line 48
def warning(start_stop: '', component:, operation: , message:, status:'', time_elapsed:'')
  generic(type: 'W', start_stop: start_stop, component: component, operation: operation, message: message, status: status, time_elapsed: time_elapsed)
end