class SemanticLogger::Log
def assign(message: nil,
Example:
Returns [true|false] whether this log entry should be logged
Assign named arguments to this log entry, supplying defaults where applicable
def assign(message: nil, payload: nil, min_duration: 0.0, exception: nil, metric: nil, metric_amount: nil, duration: nil, backtrace: nil, log_exception: :full, on_exception_level: nil, dimensions: nil) self.message = message self.payload = payload self.duration = duration self.metric = metric self.metric_amount = metric_amount self.dimensions = dimensions if exception case log_exception when :full self.exception = exception when :partial self.message = "#{message} -- Exception: #{exception.class}: #{exception.message}" when nil, :none # Log the message without the exception that was raised nil else raise(ArgumentError, "Invalid value:#{log_exception.inspect} for argument :log_exception") end # On exception change the log level if on_exception_level self.level = on_exception_level self.level_index = Levels.index(level) end end # Elastic logging: Log when :duration exceeds :min_duration # Except if there is an exception when it will always be logged return false if duration && (duration < min_duration) && exception.nil? if backtrace self.backtrace = Utils.extract_backtrace(backtrace) elsif level_index >= SemanticLogger.backtrace_level_index self.backtrace = Utils.extract_backtrace(caller) end true end