Sha256: 574c45046515f4afe893d7c6f05dc2a565d8057e43e8890982d0164b442de631
Contents?: true
Size: 1.11 KB
Versions: 13
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true require 'log_toolbox/log_payload' require 'action_controller' module LogToolbox class LogController < ActionController::Base include LogToolbox::LogPayload def change_level log_info("Log level was changed to #{level_param}") Rails.logger.level = Logger.const_get(level_param.upcase) render json: { message: "Your application log level was changed to #{rails_logger}", log_options: options, log_levels: levels } end def test log_debug('Log level DEBUG') log_info('Log level INFO') log_warn('Log level WARN') log_error('Log level ERR') log_critical('Log level CRIT') render json: { message: "Your application log level is #{rails_logger}", log_options: options, log_levels: levels } end private def options %w[DEBUG INFO WARN ERROR FATAL] end def levels { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, FATAL: 4 } end def rails_logger Rails.logger.level end def level_param params.require(:level) end end end
Version data entries
13 entries across 13 versions & 1 rubygems