Module: OllamaChat::Logging
- Included in:
- Chat
- Defined in:
- lib/ollama_chat/logging.rb
Overview
Provides a simple logging facility for the OllamaChat application. It offers methods to access a logger, determine the current log level, and write messages at various severity levels, including debug.
Instance Method Summary collapse
-
#log(severity, msg, warn: false) ⇒ Object
The log method records a message or exception at the specified severity level using the logger and optionally triggers a warning output.
-
#logger ⇒ Logger
The logger method returns the current Logger instance used by OllamaChat.
Instance Method Details
#log(severity, msg, warn: false) ⇒ Object
The log method records a message or exception at the specified severity level using the logger and optionally triggers a warning output
21 22 23 24 25 26 27 28 |
# File 'lib/ollama_chat/logging.rb', line 21 def log(severity, msg, warn: false) if msg.is_a?(Exception) msg = "Caught #{msg.class}: #{msg}\n#{Array(msg&.backtrace).join(?\n)}" end logger.send(severity, msg) warn and self.warn(msg) nil end |
#logger ⇒ Logger
The logger method returns the current Logger instance used by OllamaChat. If no Logger exists, it creates one pointing to the configured log file.
9 10 11 12 13 |
# File 'lib/ollama_chat/logging.rb', line 9 def logger @logger and return @logger OC::OLLAMA::CHAT::LOGFILE.dirname.mkpath @logger = Logger.new(OC::OLLAMA::CHAT::LOGFILE) end |