fizx-loggable 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +1 -0
  2. data/lib/loggable.rb +5 -2
  3. data/test/test_loggable.rb +11 -0
  4. metadata +1 -1
data/README CHANGED
@@ -4,6 +4,7 @@ Features:
4
4
 
5
5
  1. Global logger, overrideable at the class level.
6
6
  2. Logging methods mixed into your classes.
7
+ 3. Set global logger level with ENV["LOG_LEVEL"]
7
8
 
8
9
  >> require "loggable"
9
10
  => true
@@ -1,5 +1,5 @@
1
1
  require "logger"
2
- module Loggable
2
+ module Loggable
3
3
  module ClassMethods
4
4
  def logger
5
5
  @logger || Loggable.default
@@ -15,10 +15,13 @@ module Loggable
15
15
 
16
16
  module LoggableMethods
17
17
  def default
18
+ return @default_logger if @default_logger
18
19
  @default_logger ||= Logger.new(STDOUT)
20
+ @default_logger.level = ENV["LOG_LEVEL"] if ENV["LOG_LEVEL"]
21
+ @default_logger
19
22
  end
20
23
  def default=(l)
21
- @default_loffer = l
24
+ @default_logger = l
22
25
  end
23
26
  end
24
27
 
@@ -32,4 +32,15 @@ class TestLoggable < Test::Unit::TestCase
32
32
  l.info "info"
33
33
  l.debug "debug"
34
34
  end
35
+
36
+ def test_env
37
+ Loggable.default = nil
38
+ ENV["LOG_LEVEL"] = "info"
39
+ assert_equal "info", Loggable.default.level
40
+
41
+ Loggable.default = nil
42
+ ENV["LOG_LEVEL"] = "debug"
43
+ assert_equal "debug", Loggable.default.level
44
+
45
+ end
35
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fizx-loggable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Maxwell