class Redis::DistributedLogger

Constants

DEBUG

Low-level information, mostly for developers.

ERROR

A handleable error condition.

FATAL

An unhandleable error that results in a program crash.

INFO

Generic (useful) information about system operation.

UNKNOWN

An unknown message that should always be logged.

VERSION
WARN

A warning.

Attributes

datetime_format[RW]

for compatibily with classic Logger methods

level[RW]

for compatibily with classic Logger methods

Public Class Methods

new( redis, key, stdout = nil ) click to toggle source
# File lib/redis/distributed_logger.rb, line 22
def initialize( redis, key, stdout = nil )
  @_redis = redis
  @_key = key
  @_stdout = stdout
  @_level = INFO
end

Public Instance Methods

<<(msg) click to toggle source
# File lib/redis/distributed_logger.rb, line 29
def <<(msg)
  @_redis.lpush( @_key, { at: Time.now.to_i, severity: nil, progname: nil, message: msg }.to_json )
end
add( severity, message = nil, progname = nil ) { |: message| ... } click to toggle source
# File lib/redis/distributed_logger.rb, line 33
def add( severity, message = nil, progname = nil, &block )
  @_redis.lpush( @_key, { at: Time.now.to_i, severity: severity, progname: block_given? ? message : progname, message: block_given? ? yield : message }.to_json )
end
Also aliased as: log
close() click to toggle source
# File lib/redis/distributed_logger.rb, line 38
def close
  # nothing
end
debug( arg = nil ) { |: arg, block_given? ? arg : nil )| ... } click to toggle source
# File lib/redis/distributed_logger.rb, line 62
def debug( arg = nil, &block )
  add( DEBUG, block_given? ? yield : arg, block_given? ? arg : nil )
end
debug?() click to toggle source
# File lib/redis/distributed_logger.rb, line 42
def debug?
  @_level <= DEBUG
end
error( arg = nil ) { |: arg, block_given? ? arg : nil )| ... } click to toggle source
# File lib/redis/distributed_logger.rb, line 66
def error( arg = nil, &block )
  add( ERROR, block_given? ? yield : arg, block_given? ? arg : nil )
end
error?() click to toggle source
# File lib/redis/distributed_logger.rb, line 46
def error?
  @_level <= ERROR
end
fatal( arg = nil ) { |: arg, block_given? ? arg : nil )| ... } click to toggle source
# File lib/redis/distributed_logger.rb, line 70
def fatal( arg = nil, &block )
  add( FATAL, block_given? ? yield : arg, block_given? ? arg : nil )
end
fatal?() click to toggle source
# File lib/redis/distributed_logger.rb, line 50
def fatal?
  @_level <= FATAL
end
info( arg = nil ) { |: arg, block_given? ? arg : nil )| ... } click to toggle source
# File lib/redis/distributed_logger.rb, line 74
def info( arg = nil, &block )
  add( INFO, block_given? ? yield : arg, block_given? ? arg : nil )
end
info?() click to toggle source
# File lib/redis/distributed_logger.rb, line 54
def info?
  @_level <= INFO
end
log( severity, message = nil, progname = nil, &block )
Alias for: add
unknown( arg = nil ) { |: arg, block_given? ? arg : nil )| ... } click to toggle source
# File lib/redis/distributed_logger.rb, line 78
def unknown( arg = nil, &block )
  add( UNKNOWN, block_given? ? yield : arg, block_given? ? arg : nil )
end
warn( arg = nil ) { |: arg, block_given? ? arg : nil )| ... } click to toggle source
# File lib/redis/distributed_logger.rb, line 82
def warn( arg = nil, &block )
  add( WARN, block_given? ? yield : arg, block_given? ? arg : nil )
end
warn?() click to toggle source
# File lib/redis/distributed_logger.rb, line 58
def warn?
  @_level <= WARN
end