Module: Lamian

Defined in:
lib/lamian.rb,
lib/lamian/config.rb,
lib/lamian/engine.rb,
lib/lamian/logger.rb,
lib/lamian/version.rb,
lib/lamian/middleware.rb,
lib/lamian/logger_extension.rb,
lib/lamian/sentry_scope_patch.rb,
lib/lamian/semantic_logger_appender.rb

Overview

Lamian is an in-memory logger, which content could be released for error messages. It is designed to work in pair with ‘exception_notification` gem inside rails aplications

Defined Under Namespace

Modules: LoggerExtension, RavenContextExtension, SentryScopePatch Classes: Config, Engine, Logger, Middleware, SemanticLoggerAppender, SidekiqRavenMiddleware, SidekiqSentryMiddleware

Constant Summary collapse

SENTRY_EXTRA_KEY =

The key under which logs are stored in the Sentry extra data.

:lamian_log
VERSION =

Current lamian version

format: ‘a.b.c’ with possible suffixes such as alpha

  • a is for major version, it is guaranteed to be changed if back-compatibility of public API is broken

  • b is for minor version, it is guaranteed to be changed on public API changes and also if private API back-compatibility is broken

  • c is for incremental version, it is updated in other cases

According to this, it is enough to specify ‘~> a.b’ if private API was not used and to specify ‘~> a.b.c’ if it was

"1.7.0"

Class Method Summary collapse

Class Method Details

.configure {|config| ... } ⇒ Lamian::Config Also known as: config

Yields curent configuration if block given

Examples:

Lamian.configure do |config|
  config.formatter = MyFormatter.new
end

Yields:

  • (config)

    current configuration

Yield Parameters:

Returns:



33
34
35
36
37
# File 'lib/lamian.rb', line 33

def configure
  @config ||= Config.new
  yield(@config) if block_given?
  @config
end

.dump(format: nil) ⇒ Object

Dumps log collected in this run

Parameters:

  • format (Symbol) (defaults to: nil)

    requested format of log. At this point, returns raw log if falsey or log without controll sequences (such as ‘[23m’) if truthy value given (for now)

Returns:

  • formatted log (String by default)



64
65
66
# File 'lib/lamian.rb', line 64

def dump(format: nil)
  logger.dump(format: format)
end

.dump_limitedString?

Truncates the collected log to the specified limit and dumps it.

Returns:

  • (String, nil)

    truncated formatted log.



70
71
72
# File 'lib/lamian.rb', line 70

def dump_limited
  dump(format: :txt)&.slice(0, Lamian.config.raven_log_size_limit)
end

.extend_logger(other_logger) ⇒ Object

Extends logger instance to tee it’s output to Lamian logger

Parameters:

  • other_logger (Logger)

    logger to extend



42
43
44
# File 'lib/lamian.rb', line 42

def extend_logger(other_logger)
  other_logger.extend(Lamian::LoggerExtension)
end

.loggerLamian::Logger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Gives access to current logger

Returns:



49
50
51
# File 'lib/lamian.rb', line 49

def logger
  Lamian::Logger.current
end

.run(&block) ⇒ Object

Collects logs sent inside block



54
55
56
# File 'lib/lamian.rb', line 54

def run(&block)
  logger.run(&block)
end