Class: LlmTranslate::Logger
- Inherits:
-
Object
- Object
- LlmTranslate::Logger
- Defined in:
- lib/llm_translate/logger.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#error_logger ⇒ Object
readonly
Returns the value of attribute error_logger.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #debug(message) ⇒ Object
- #error(message) ⇒ Object
- #fatal(message) ⇒ Object
- #info(message) ⇒ Object
-
#initialize(config) ⇒ Logger
constructor
A new instance of Logger.
- #log_ai_request(prompt_length, model) ⇒ Object
- #log_ai_response(response_length, tokens_used = nil) ⇒ Object
- #log_translation_complete(file_path, output_path) ⇒ Object
- #log_translation_start(file_path) ⇒ Object
- #warn(message) ⇒ Object
Constructor Details
#initialize(config) ⇒ Logger
Returns a new instance of Logger.
10 11 12 13 14 |
# File 'lib/llm_translate/logger.rb', line 10 def initialize(config) @config = config @logger = create_main_logger @error_logger = create_error_logger end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/llm_translate/logger.rb', line 8 def config @config end |
#error_logger ⇒ Object (readonly)
Returns the value of attribute error_logger.
8 9 10 |
# File 'lib/llm_translate/logger.rb', line 8 def error_logger @error_logger end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/llm_translate/logger.rb', line 8 def logger @logger end |
Instance Method Details
#debug(message) ⇒ Object
16 17 18 |
# File 'lib/llm_translate/logger.rb', line 16 def debug() logger.debug(()) end |
#error(message) ⇒ Object
28 29 30 31 |
# File 'lib/llm_translate/logger.rb', line 28 def error() logger.error(()) error_logger&.error(()) end |
#fatal(message) ⇒ Object
33 34 35 36 |
# File 'lib/llm_translate/logger.rb', line 33 def fatal() logger.fatal(()) error_logger&.fatal(()) end |
#info(message) ⇒ Object
20 21 22 |
# File 'lib/llm_translate/logger.rb', line 20 def info() logger.info(()) end |
#log_ai_request(prompt_length, model) ⇒ Object
50 51 52 53 54 |
# File 'lib/llm_translate/logger.rb', line 50 def log_ai_request(prompt_length, model) return unless config.verbose_translation? debug("AI Request - Model: #{model}, Prompt length: #{prompt_length} chars") end |
#log_ai_response(response_length, tokens_used = nil) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/llm_translate/logger.rb', line 56 def log_ai_response(response_length, tokens_used = nil) return unless config.verbose_translation? token_info = tokens_used ? ", Tokens: #{tokens_used}" : '' debug("AI Response - Length: #{response_length} chars#{token_info}") end |
#log_translation_complete(file_path, output_path) ⇒ Object
44 45 46 47 48 |
# File 'lib/llm_translate/logger.rb', line 44 def log_translation_complete(file_path, output_path) return unless config.verbose_translation? info("Translation complete: #{file_path} -> #{output_path}") end |
#log_translation_start(file_path) ⇒ Object
38 39 40 41 42 |
# File 'lib/llm_translate/logger.rb', line 38 def log_translation_start(file_path) return unless config.verbose_translation? info("Starting translation: #{file_path}") end |
#warn(message) ⇒ Object
24 25 26 |
# File 'lib/llm_translate/logger.rb', line 24 def warn() logger.warn(()) end |