class Onyx::SQL::Repository::Logger::Standard

Overview

Logs anything followed by elapsed time by the block into a standard Logger.

logger = Logger.new(STDOUT, Logger::Severity::INFO)
repo_logger = Onyx::SQL::Repository::Logger::Standard.new(logger)

result = repo_logger.wrap("SELECT * FROM users") do
  db.query("SELECT * FROM users")
end

# [21:54:51:068]  INFO > SELECT * FROM users
# [21:54:51:068]  INFO > 501μs

Defined in:

onyx-sql/repository/logger/standard.cr

Constructors

Instance Method Summary

Instance methods inherited from class Onyx::SQL::Repository::Logger

wrap(data_to_log : String, &block) wrap

Constructor Detail

def self.new(logger : ::Logger = ::Logger.new(STDOUT, ::Logger::Severity::INFO), log_level : ::Logger::Severity = ::Logger::Severity::INFO, colors = true) #

[View source]

Instance Method Detail

def wrap(data_to_log : String, &block) #

Wrap a block, logging elapsed time at log_level and returning the result.


[View source]