class Locd::CLI::Command::Main
CLI
interface using the Thor via my `atli` fork.
@see whatisthor.com/
Constants
- LOG_LEVEL_STRINGS
Just the symbol log levels from {SemnaticLogger::LEVELS} converted to frozen strings
@return [Array<String>]
Public Class Methods
new(args = [], local_options = {})
click to toggle source
Wrap {Thor#initialize} to call {#init_setup_logging} after letting `super` do it's thing so logging is setup before we do anything else.
Calls superclass method
# File lib/locd/cli/command/main.rb, line 105 def initialize args = [], local_options = {}, config = {} super args, local_options, config # If anything raises in here, the command seems to just silently exit..? begin init_setup_logging! rescue Exception => e $stderr.write \ "ERROR: #{ e.message } #{ e.class }\n#{ e.backtrace.join( "\n" ) }\n" end logger.debug "initialized", args: args, local_options: local_options, options: self.options end
Public Instance Methods
config()
click to toggle source
# File lib/locd/cli/command/main.rb, line 197 def config respond Locd.config.to_h end
version()
click to toggle source
# File lib/locd/cli/command/main.rb, line 186 def version respond Locd::VERSION end
Protected Instance Methods
init_setup_logging!()
click to toggle source
Setup logging using {#options}.
# File lib/locd/cli/command/main.rb, line 131 def init_setup_logging! kwds = {} level = if options[:trace] :trace elsif options[:debug] :debug elsif options[:log_level] LOG_LEVEL_STRINGS.find_only { |level| level.start_with? options[:log_level] }.to_sym end NRSER::Log.level = level unless level.nil? if levels = Locd.config[:log, :levels] levels.each do |name, level| const = begin NRSER.to_const name rescue next end level = level.to_sym self.logger.debug "Setting logger level", logger: const.logger, level: level const.logger.level = level self.logger.debug "Logger level set", logger: const.logger end end if [:trace, :debug].include? NRSER::Log.level logger.send NRSER::Log.level, "Hello! We about to start the show..." end end