logem 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/logem/logger.rb +9 -9
- data/logem.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/logem/logger.rb
CHANGED
@@ -7,30 +7,30 @@ module Logem
|
|
7
7
|
DEBUG = 20
|
8
8
|
TRACE = 10
|
9
9
|
|
10
|
-
|
10
|
+
DEFAULT_LEVEL = INFO
|
11
11
|
DEFAULT_LOG_LEVEL_ENV = "LOGEM_LOG_LEVEL"
|
12
12
|
|
13
13
|
attr :log_level_env
|
14
14
|
attr :context
|
15
|
-
attr_accessor :
|
15
|
+
attr_accessor :level
|
16
16
|
|
17
17
|
def initialize context, options = {}
|
18
18
|
@context = context
|
19
19
|
@log_level_env = options[:log_level_env ] || DEFAULT_LOG_LEVEL_ENV
|
20
|
-
@
|
20
|
+
@level = options[:level ] || self.class.string_to_level(ENV[@log_level_env]) || DEFAULT_LEVEL
|
21
21
|
@output = options[:output ] || $stdout
|
22
22
|
@time_formatter = options[:time_formatter]
|
23
23
|
@output_supports_logem = @output.respond_to? :logem
|
24
24
|
end
|
25
25
|
|
26
26
|
def log level, *args
|
27
|
-
return if @
|
27
|
+
return if @level > level
|
28
28
|
|
29
29
|
_log_ level, *args
|
30
30
|
end
|
31
31
|
|
32
32
|
def visible? level
|
33
|
-
@
|
33
|
+
@level <= level
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.level_to_string level
|
@@ -45,7 +45,7 @@ module Logem
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.string_to_level level_string
|
48
|
-
return
|
48
|
+
return DEFAULT_LEVEL if level_string.nil? or level_string.strip == ''
|
49
49
|
|
50
50
|
case level_string.strip.downcase
|
51
51
|
when 'error' then ERROR
|
@@ -55,8 +55,8 @@ module Logem
|
|
55
55
|
when 'trace' then TRACE
|
56
56
|
else
|
57
57
|
$stdout.puts "Logem warning: #{level_string} is not a valid log level, " +
|
58
|
-
"default to #{level_to_string(
|
59
|
-
|
58
|
+
"default to #{level_to_string(DEFAULT_LEVEL).strip}"
|
59
|
+
DEFAULT_LEVEL
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -64,7 +64,7 @@ module Logem
|
|
64
64
|
level = string_to_level(level_str)
|
65
65
|
|
66
66
|
define_method level_str do |*args|
|
67
|
-
return if @
|
67
|
+
return if @level > level
|
68
68
|
|
69
69
|
_log_ level, *args
|
70
70
|
end
|
data/logem.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -115,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
segments:
|
117
117
|
- 0
|
118
|
-
hash: -
|
118
|
+
hash: -2636841020204959601
|
119
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
120
|
none: false
|
121
121
|
requirements:
|