Module: Chroma::Util
- Defined in:
- lib/chroma/util.rb
Overview
The Util module provides utility methods for logging messages and data at different levels of severity.
Class Method Summary collapse
-
.log_debug(message, data = {}) ⇒ Object
Logs a debug message with the given data using the provided Logger instance.
-
.log_error(message, data = {}) ⇒ Object
Logs an error message with the given data using the provided Logger instance.
-
.log_info(message, data = {}) ⇒ Object
Logs an informational message with the given data using the provided Logger instance.
Class Method Details
.log_debug(message, data = {}) ⇒ Object
Logs a debug message with the given data using the provided Logger instance.
message - A String message to be logged. data - A Hash of additional data to be included in the log entry.
Examples
Util.log_debug("Debugging information", { user_id: 123, action: "update" })
Returns nothing.
35 36 37 38 39 40 41 42 |
# File 'lib/chroma/util.rb', line 35 def self.log_debug(, data = {}) config = data.delete(:config) || Chroma.config logger = config.logger || Chroma.logger if (!logger.nil? || !config.log_level.nil?) && config.log_level <= Chroma::LEVEL_DEBUG log_internal(, data, level: Chroma::LEVEL_DEBUG, logger: Chroma.logger) end end |
.log_error(message, data = {}) ⇒ Object
Logs an error message with the given data using the provided Logger instance.
message - A String message to be logged. data - A Hash of additional data to be included in the log entry.
Examples
Util.log_error("An error occurred", { user_id: 123, error_code: "404" })
Returns nothing.
16 17 18 19 20 21 22 23 |
# File 'lib/chroma/util.rb', line 16 def self.log_error(, data = {}) config = data.delete(:config) || Chroma.config logger = config.logger || Chroma.logger if (!logger.nil? || !config.log_level.nil?) && config.log_level <= Chroma::LEVEL_ERROR log_internal(, data, level: Chroma::LEVEL_ERROR, logger: Chroma.logger) end end |
.log_info(message, data = {}) ⇒ Object
Logs an informational message with the given data using the provided Logger instance.
message - A String message to be logged. data - A Hash of additional data to be included in the log entry.
Examples
Util.log_info("Processing request", { request_id: "abc123", route: "/users" })
Returns nothing.
54 55 56 57 58 59 60 61 |
# File 'lib/chroma/util.rb', line 54 def self.log_info(, data = {}) config = data.delete(:config) || Chroma.config logger = config.logger || Chroma.logger if (!logger.nil? || !config.log_level.nil?) && config.log_level <= Chroma::LEVEL_INFO log_internal(, data, level: Chroma::LEVEL_INFO, logger: Chroma.logger) end end |