Semlogger::Base for types added.

This commit is contained in:
Denis Knauf 2012-10-17 23:14:09 +02:00
parent 95417dec97
commit 4e803a26e7

View file

@ -27,9 +27,19 @@ end
end
class Semlogger < ::Logger
class CustomType
class Base
attr_accessor :logger
def add severity, progname = nil, &block
@logger.add severity, self, progname = nil, &block
end
::Semlogger::Severity.constants.each do |severity|
module_eval "def #{severity.downcase}( *a, &e) add #{::Semlogger::Severity.const_get severity}, *a, &e end", __FILE__, __LINE__
end
end
class CustomType < Base
def initialize name, *obj
@name, @obj = name.to_s.to_sym, obj
end
@ -37,13 +47,6 @@ class Semlogger < ::Logger
def to_semlogger
[@name] + @obj
end
def add severity, progname = nil, &block
@logger.add severity, self, progname = nil, &block
end
::Semlogger::Severity.constants.each do |severity|
module_eval "def #{severity.downcase}( *a, &e) add #{::Semlogger::Severity.const_get severity}, *a, &e end", __FILE__, __LINE__
end
end
attr_accessor :logdev, :level, :progname