Semlogger::Base for types added.
This commit is contained in:
parent
95417dec97
commit
4e803a26e7
|
@ -27,9 +27,19 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Semlogger < ::Logger
|
class Semlogger < ::Logger
|
||||||
class CustomType
|
class Base
|
||||||
attr_accessor :logger
|
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
|
def initialize name, *obj
|
||||||
@name, @obj = name.to_s.to_sym, obj
|
@name, @obj = name.to_s.to_sym, obj
|
||||||
end
|
end
|
||||||
|
@ -37,13 +47,6 @@ class Semlogger < ::Logger
|
||||||
def to_semlogger
|
def to_semlogger
|
||||||
[@name] + @obj
|
[@name] + @obj
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
attr_accessor :logdev, :level, :progname
|
attr_accessor :logdev, :level, :progname
|
||||||
|
|
Loading…
Reference in a new issue