Module: Legion::CLI::Chat::ChatLogger
- Defined in:
- lib/legion/cli/chat/chat_logger.rb
Constant Summary collapse
- LOG_DIR =
File.('~/.legion')
- LOG_FILE =
File.join(LOG_DIR, 'legion-chat.log')
- LEVELS =
{ 'debug' => ::Logger::DEBUG, 'info' => ::Logger::INFO, 'warn' => ::Logger::WARN, 'error' => ::Logger::ERROR }.freeze
Class Attribute Summary collapse
-
.logger ⇒ Object
readonly
Returns the value of attribute logger.
Class Method Summary collapse
- .debug(msg) ⇒ Object
- .error(msg) ⇒ Object
- .info(msg) ⇒ Object
- .setup(level: 'info') ⇒ Object
- .warn(msg) ⇒ Object
Class Attribute Details
.logger ⇒ Object (readonly)
Returns the value of attribute logger.
21 22 23 |
# File 'lib/legion/cli/chat/chat_logger.rb', line 21 def logger @logger end |
Class Method Details
.debug(msg) ⇒ Object
31 |
# File 'lib/legion/cli/chat/chat_logger.rb', line 31 def debug(msg) = logger&.debug(msg) |
.error(msg) ⇒ Object
37 |
# File 'lib/legion/cli/chat/chat_logger.rb', line 37 def error(msg) = logger&.error(msg) |
.info(msg) ⇒ Object
33 |
# File 'lib/legion/cli/chat/chat_logger.rb', line 33 def info(msg) = logger&.info(msg) |
.setup(level: 'info') ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/legion/cli/chat/chat_logger.rb', line 23 def setup(level: 'info') FileUtils.mkdir_p(LOG_DIR) @logger = ::Logger.new(LOG_FILE, 5, 1_048_576) # 5 rotated files, 1MB each @logger.level = parse_level(level) @logger.formatter = method(:format_entry) @logger end |
.warn(msg) ⇒ Object
35 |
# File 'lib/legion/cli/chat/chat_logger.rb', line 35 def warn(msg) = logger&.warn(msg) |