forked from topofocus/ib-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now using the standard-rails-aproach. ib/logger defines a default-logger which is used if no other logger is assigned. The logger can be redefined at any time, simply by calling IB::Connection.current.logger = Same for its behaivior: IB::Connection.current.logger.level= 3 or IB::Connection.current.logger.formater= proc{ |a,b,c,msg| msg }
- Loading branch information
Hartmut Bischoff
committed
Jan 13, 2015
1 parent
659a2c0
commit 57e51a0
Showing
4 changed files
with
63 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,16 @@ | ||
require "logger" | ||
|
||
# Add default_logger accessor into Object | ||
module LogDev | ||
# define default_logger | ||
def default_logger | ||
@default_logger ||= Logger.new(STDOUT).tap do |logger| | ||
time_format = RUBY_VERSION =~ /1\.8\./ ? '%H:%M:%S.%N' : '%H:%M:%S.%3N' | ||
logger.formatter = proc do |level, time, prog, msg| | ||
|
||
"#{time.strftime(time_format)} #{msg}\n" | ||
Logger.new(STDOUT).tap do |l| | ||
l.formatter = proc do |severity, datetime, progname, msg| | ||
# "#{datetime.strftime("%d.%m.(%X)")}#{"%5s" % severity}->#{progname}##{msg}\n" | ||
## the default logger displays the message only | ||
msg | ||
end | ||
logger.level = Logger::INFO | ||
l.level = Logger::INFO | ||
end | ||
end | ||
|
||
def default_logger= logger | ||
@default_logger = logger | ||
end | ||
|
||
# Add universally accessible log method/accessor into Object | ||
def log *args | ||
default_logger.tap do |logger| | ||
logger.fatal *args unless args.empty? | ||
end | ||
end | ||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters