Module: Outlog
- Defined in:
- lib/outlog.rb,
lib/outlog/version.rb,
lib/outlog/base_logger.rb,
lib/outlog/json_logger.rb,
lib/outlog/null_logger.rb,
lib/outlog/console_logger.rb
Defined Under Namespace
Classes: BaseLogger, ConsoleLogger, Error, JsonLogger, NullLogger
Constant Summary
collapse
- VERSION =
"0.4.0"
Class Method Summary
collapse
Class Method Details
.create_logger ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/outlog.rb', line 25
def create_logger
environment = ENV["RACK_ENV"] || ENV["APP_ENV"] || "development"
case environment
when "development"
::Outlog::ConsoleLogger.new
when "test"
::Outlog::NullLogger.new
else
::Outlog::JsonLogger.new
end
end
|
.logger ⇒ Object
17
18
19
|
# File 'lib/outlog.rb', line 17
def logger
@logger ||= create_logger
end
|
.logger=(new_logger) ⇒ Object
21
22
23
|
# File 'lib/outlog.rb', line 21
def logger= new_logger
@logger = new_logger
end
|
.with_logger(new_logger) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/outlog.rb', line 38
def with_logger new_logger
previous_logger = @logger
@logger = new_logger
yield
ensure
@logger = previous_logger
end
|