Class: Legion::Logging::Logger

Inherits:
Object
  • Object
show all
Includes:
Builder, Methods
Defined in:
lib/legion/logging/logger.rb

Constant Summary

Constants included from Methods

Methods::COMPONENT_REGEX, Methods::EXCEPTION_PRIORITY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Builder

#async?, #build_runner_trace, #json?, #json_format, #log_format, #log_level, #output, #prepare_log_path, #resolve_lex_tag, #set_log, #start_async_writer, #stop_async_writer, #text_format

Methods included from Methods

#debug, #emit_tagged, #error, #fatal, #info, #log_exception, #runner_exception, #thread, #trace, #unknown, #warn

Constructor Details

#initialize(level: 'info', log_file: nil, log_stdout: nil, lex: nil, trace: false, extended: false, trace_size: 4, format: :text, async: false, **opts) ⇒ Logger

Returns a new instance of Logger.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/legion/logging/logger.rb', line 14

def initialize(level: 'info', log_file: nil, log_stdout: nil, lex: nil, trace: false, extended: false, trace_size: 4, format: :text, async: false, **opts)
  @lex = lex
  set_log(logfile: log_file, log_stdout: log_stdout)
  log_level(level)
  log_format(format: format, lex: lex, extended: extended, **opts)
  @color = opts[:color]
  @color = format != :json && (opts[:color] || (opts[:color].nil? && log_file.nil?))
  @trace_enabled = trace
  @trace_size = trace_size
  @extended = extended
  start_async_writer if async
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



9
10
11
# File 'lib/legion/logging/logger.rb', line 9

def color
  @color
end

#extendedObject

Returns the value of attribute extended.



9
10
11
# File 'lib/legion/logging/logger.rb', line 9

def extended
  @extended
end

#levelObject

Returns the value of attribute level.



9
10
11
# File 'lib/legion/logging/logger.rb', line 9

def level
  @level
end

#lexObject

Returns the value of attribute lex.



9
10
11
# File 'lib/legion/logging/logger.rb', line 9

def lex
  @lex
end

#logObject

Returns the value of attribute log.



9
10
11
# File 'lib/legion/logging/logger.rb', line 9

def log
  @log
end

#log_fileObject

Returns the value of attribute log_file.



9
10
11
# File 'lib/legion/logging/logger.rb', line 9

def log_file
  @log_file
end

#trace_enabledObject

Returns the value of attribute trace_enabled.



9
10
11
# File 'lib/legion/logging/logger.rb', line 9

def trace_enabled
  @trace_enabled
end