Skip to content

Commit ec938bb

Browse files
committed
Merge pull request #4 from blackopseng3/master
Bugfix and improvements
2 parents 65d45df + d9690b4 commit ec938bb

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ stackify-api-ruby starts with start of Rails. Every error, which occurs within y
3434

3535
Rails.logger.info "Some log message"
3636

37+
If you want to redefine <b>logger</b>, you should add
38+
39+
config.logger = ::Stackify::LoggerProxy.new(ActiveSupport::Logger.new(File.join(Rails.root, 'log', "#{Rails.env}.log")))
40+
41+
to your config/environments/%environment%. <b>Note:</b> in this case Stackify#config.log_level will affect entire system.
42+
3743
### Other Environment
3844

3945
For using stackify-api-ruby gem within any Ruby application add to top of your main file:

lib/stackify/logger_proxy.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ def initialize logger
77
%w( debug info warn error fatal unknown).each do |level|
88
LoggerProxy.class_eval do
99
define_method level.to_sym do |*args , &block|
10-
msg = message(args, block)
10+
msg = message(*args, &block)
1111
Stackify.logger_client.log(level.downcase, msg, caller)
12-
@logger.send(level.to_sym, args, &block)
12+
@logger.send(level.to_sym, msg, &block)
1313
end
1414
end
1515
end
@@ -24,10 +24,12 @@ def method_missing(name, *args, &block)
2424
private
2525

2626
def message *args, &block
27-
if block
27+
if block_given?
2828
block.call
2929
else
30-
args.flatten[0]
30+
args = args.flatten.compact
31+
args = (args.count == 1 ? args[0] : args)
32+
args.is_a?(Proc) ? args.call : args
3133
end
3234
end
3335

0 commit comments

Comments
 (0)