logem 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MmIzZmE5ZGE4NGM4ZWNiZTVkYzg1YWM2OTdhNmExZGRjZjhhMmFlNg==
5
+ data.tar.gz: !binary |-
6
+ MzRkYWUzOWZmMjVkNDZlOGYwMTJlNGVmMzU4NzdmNzE2Yjk1NmEyMQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NDUwYzM5ZDlkOWMxMTc4MDY3ZjJkZDlhNjIzODIyYTUxZjk2ZWNiZTE2Y2Jj
10
+ ZmRkYTM0MjVmMjZkMjQxZDRhMjljYTQyODRiZDQ1OWRjOTUyMjdhODM1Zjlj
11
+ MTdiYzliNmRlODY1NDg2ZWNiZTg0MTg1MTIxMTA2NjE5YzQ1OGE=
12
+ data.tar.gz: !binary |-
13
+ YmIwNDFmNWM4YTc0NjA0MWM2NzRlMDQ1NWFkZGIyN2VmNGFiZmQ2YTc1YzQ1
14
+ NDdlMzExYjRmNmE1N2ZhNTI0YzJjODI0OTg5NGU4OTRkMTYwZWU2ZTE4OTI2
15
+ Nzg5MjkyMDhmZmI5MmUwOGEwMzg1MmU3MmRjNTU3OGZjZjc3MjY=
@@ -1,16 +1,48 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ addressable (2.3.5)
5
+ builder (3.2.2)
4
6
  diff-lcs (1.1.3)
5
- git (1.2.5)
6
- jeweler (1.8.4)
7
+ faraday (0.8.8)
8
+ multipart-post (~> 1.2.0)
9
+ git (1.2.6)
10
+ github_api (0.10.1)
11
+ addressable
12
+ faraday (~> 0.8.1)
13
+ hashie (>= 1.2)
14
+ multi_json (~> 1.4)
15
+ nokogiri (~> 1.5.2)
16
+ oauth2
17
+ hashie (2.0.5)
18
+ highline (1.6.20)
19
+ httpauth (0.2.0)
20
+ jeweler (1.8.8)
21
+ builder
7
22
  bundler (~> 1.0)
8
23
  git (>= 1.2.5)
24
+ github_api (= 0.10.1)
25
+ highline (>= 1.6.15)
26
+ nokogiri (= 1.5.10)
9
27
  rake
10
28
  rdoc
11
- json (1.7.5)
12
- rake (0.9.2.2)
13
- rdoc (3.12)
29
+ json (1.8.1)
30
+ jwt (0.1.8)
31
+ multi_json (>= 1.5)
32
+ multi_json (1.8.2)
33
+ multi_xml (0.5.5)
34
+ multipart-post (1.2.0)
35
+ nokogiri (1.5.10)
36
+ oauth2 (0.9.2)
37
+ faraday (~> 0.8)
38
+ httpauth (~> 0.2)
39
+ jwt (~> 0.1.4)
40
+ multi_json (~> 1.0)
41
+ multi_xml (~> 0.5)
42
+ rack (~> 1.2)
43
+ rack (1.5.2)
44
+ rake (10.1.0)
45
+ rdoc (3.12.2)
14
46
  json (~> 1.4)
15
47
  rspec (2.8.0)
16
48
  rspec-core (~> 2.8.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -1 +1,10 @@
1
+ require 'logem/base_logger'
1
2
  require 'logem/logger'
3
+
4
+ module Logem
5
+ ERROR = Logger::ERROR
6
+ WARN = Logger::WARN
7
+ INFO = Logger::INFO
8
+ DEBUG = Logger::DEBUG
9
+ TRACE = Logger::TRACE
10
+ end
@@ -0,0 +1,100 @@
1
+ module Logem
2
+ class BaseLogger
3
+ # Log levels
4
+ ERROR = 50
5
+ WARN = 40
6
+ INFO = 30
7
+ DEBUG = 20
8
+ TRACE = 10
9
+
10
+ DEFAULT_LEVEL = INFO
11
+ DEFAULT_LOG_LEVEL_ENV = "LOGEM_LOG_LEVEL"
12
+
13
+ attr :log_level_env
14
+ attr :context
15
+ attr_accessor :level
16
+
17
+ def initialize context, options = {}
18
+ @context = context
19
+ @log_level_env = options[:log_level_env ] || DEFAULT_LOG_LEVEL_ENV
20
+ @level = options[:level ] || self.class.string_to_level(ENV[@log_level_env]) || DEFAULT_LEVEL
21
+ @output = options[:output ] || $stdout
22
+ @time_formatter = options[:time_formatter]
23
+ @output_supports_logem = @output.respond_to? :logem
24
+ end
25
+
26
+ def log level, *args
27
+ return if @level > level
28
+
29
+ _log_ level, *args
30
+ end
31
+
32
+ def visible? level
33
+ @level <= level
34
+ end
35
+
36
+ def self.level_to_string level
37
+ case level
38
+ when ERROR then "ERROR"
39
+ when WARN then "WARN "
40
+ when INFO then "INFO "
41
+ when DEBUG then "DEBUG"
42
+ when TRACE then "TRACE"
43
+ else level.to_s
44
+ end
45
+ end
46
+
47
+ def self.string_to_level level_string
48
+ return DEFAULT_LEVEL if level_string.nil? or level_string.strip == ''
49
+
50
+ case level_string.strip.downcase
51
+ when 'error' then ERROR
52
+ when 'warn' then WARN
53
+ when 'info' then INFO
54
+ when 'debug' then DEBUG
55
+ when 'trace' then TRACE
56
+ else
57
+ $stdout.puts "Logem warning: #{level_string} is not a valid log level, " +
58
+ "default to #{level_to_string(DEFAULT_LEVEL).strip}"
59
+ DEFAULT_LEVEL
60
+ end
61
+ end
62
+
63
+ %w[error warn info debug trace].each do |level_str|
64
+ level = string_to_level(level_str)
65
+
66
+ define_method level_str do |*args|
67
+ return if @level > level
68
+
69
+ _log_ level, *args
70
+ end
71
+ end
72
+
73
+ private
74
+
75
+ def _log_ level, *args
76
+ time = Time.now
77
+
78
+ if @output_supports_logem
79
+ if @context
80
+ @output.logem time, level, @context, *args
81
+ else
82
+ @output.logem time, level, *args
83
+ end
84
+ else
85
+ time_str = @time_formatter ? @time_formatter.call(time) : time.to_s
86
+
87
+ if @context
88
+ parts = [time_str, self.class.level_to_string(level), @context.to_s]
89
+ else
90
+ parts = [time_str, self.class.level_to_string(level)]
91
+ end
92
+
93
+ args.each {|arg| parts << (arg.nil? ? 'nil' : arg.to_s) }
94
+
95
+ @output.puts parts.join(' | ')
96
+ end
97
+ end
98
+ end
99
+ end
100
+
@@ -1,97 +1,5 @@
1
1
  module Logem
2
- class Logger
3
- # Log levels
4
- ERROR = 50
5
- WARN = 40
6
- INFO = 30
7
- DEBUG = 20
8
- TRACE = 10
9
-
10
- DEFAULT_LEVEL = INFO
11
- DEFAULT_LOG_LEVEL_ENV = "LOGEM_LOG_LEVEL"
12
-
13
- attr :log_level_env
14
- attr :context
15
- attr_accessor :level
16
-
17
- def initialize context, options = {}
18
- @context = context
19
- @log_level_env = options[:log_level_env ] || DEFAULT_LOG_LEVEL_ENV
20
- @level = options[:level ] || self.class.string_to_level(ENV[@log_level_env]) || DEFAULT_LEVEL
21
- @output = options[:output ] || $stdout
22
- @time_formatter = options[:time_formatter]
23
- @output_supports_logem = @output.respond_to? :logem
24
- end
25
-
26
- def log level, *args
27
- return if @level > level
28
-
29
- _log_ level, *args
30
- end
31
-
32
- def visible? level
33
- @level <= level
34
- end
35
-
36
- def self.level_to_string level
37
- case level
38
- when ERROR then "ERROR"
39
- when WARN then "WARN "
40
- when INFO then "INFO "
41
- when DEBUG then "DEBUG"
42
- when TRACE then "TRACE"
43
- else level.to_s
44
- end
45
- end
46
-
47
- def self.string_to_level level_string
48
- return DEFAULT_LEVEL if level_string.nil? or level_string.strip == ''
49
-
50
- case level_string.strip.downcase
51
- when 'error' then ERROR
52
- when 'warn' then WARN
53
- when 'info' then INFO
54
- when 'debug' then DEBUG
55
- when 'trace' then TRACE
56
- else
57
- $stdout.puts "Logem warning: #{level_string} is not a valid log level, " +
58
- "default to #{level_to_string(DEFAULT_LEVEL).strip}"
59
- DEFAULT_LEVEL
60
- end
61
- end
62
-
63
- %w[error warn info debug trace].each do |level_str|
64
- level = string_to_level(level_str)
65
-
66
- define_method level_str do |*args|
67
- return if @level > level
68
-
69
- _log_ level, *args
70
- end
71
- end
72
-
73
- private
74
-
75
- def _log_ level, *args
76
- time = Time.now
77
-
78
- if @output_supports_logem
79
- @output.logem time, level, @context, *args
80
- else
81
- time_str = @time_formatter ? @time_formatter.call(time) : time.to_s
82
-
83
- parts = [time_str, self.class.level_to_string(level), @context.to_s]
84
- args.each {|arg| parts << (arg.nil? ? 'nil' : arg.to_s) }
85
-
86
- @output.puts parts.join(' | ')
87
- end
88
- end
2
+ class Logger < BaseLogger
89
3
  end
90
-
91
- ERROR = Logger::ERROR
92
- WARN = Logger::WARN
93
- INFO = Logger::INFO
94
- DEBUG = Logger::DEBUG
95
- TRACE = Logger::TRACE
96
4
  end
97
5
 
@@ -2,14 +2,15 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: logem 0.4.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "logem"
8
- s.version = "0.3.0"
9
+ s.version = "0.4.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
12
  s.authors = ["Guoliang Cao"]
12
- s.date = "2012-10-09"
13
+ s.date = "2013-11-01"
13
14
  s.description = "A simple logger for Ruby"
14
15
  s.email = "gcao99@gmail.com"
15
16
  s.extra_rdoc_files = [
@@ -30,6 +31,7 @@ Gem::Specification.new do |s|
30
31
  "examples/complete.rb",
31
32
  "examples/simple.rb",
32
33
  "lib/logem.rb",
34
+ "lib/logem/base_logger.rb",
33
35
  "lib/logem/logger.rb",
34
36
  "logem.gemspec",
35
37
  "spec/logem/logger_spec.rb",
@@ -38,11 +40,11 @@ Gem::Specification.new do |s|
38
40
  s.homepage = "http://github.com/gcao/logem"
39
41
  s.licenses = ["MIT"]
40
42
  s.require_paths = ["lib"]
41
- s.rubygems_version = "1.8.18"
43
+ s.rubygems_version = "2.1.5"
42
44
  s.summary = "A simple logger for Ruby"
43
45
 
44
46
  if s.respond_to? :specification_version then
45
- s.specification_version = 3
47
+ s.specification_version = 4
46
48
 
47
49
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
50
  s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Guoliang Cao
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-09 00:00:00.000000000 Z
11
+ date: 2013-11-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rdoc
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,23 +41,22 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bundler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
53
- version: 1.0.0
47
+ version: !binary |-
48
+ MS4wLjA=
54
49
  type: :development
55
50
  prerelease: false
56
51
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
52
  requirements:
59
53
  - - ! '>='
60
54
  - !ruby/object:Gem::Version
61
- version: 1.0.0
55
+ version: !binary |-
56
+ MS4wLjA=
62
57
  - !ruby/object:Gem::Dependency
63
58
  name: jeweler
64
59
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
60
  requirements:
67
61
  - - ~>
68
62
  - !ruby/object:Gem::Version
@@ -70,7 +64,6 @@ dependencies:
70
64
  type: :development
71
65
  prerelease: false
72
66
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
67
  requirements:
75
68
  - - ~>
76
69
  - !ruby/object:Gem::Version
@@ -96,6 +89,7 @@ files:
96
89
  - examples/complete.rb
97
90
  - examples/simple.rb
98
91
  - lib/logem.rb
92
+ - lib/logem/base_logger.rb
99
93
  - lib/logem/logger.rb
100
94
  - logem.gemspec
101
95
  - spec/logem/logger_spec.rb
@@ -103,29 +97,25 @@ files:
103
97
  homepage: http://github.com/gcao/logem
104
98
  licenses:
105
99
  - MIT
100
+ metadata: {}
106
101
  post_install_message:
107
102
  rdoc_options: []
108
103
  require_paths:
109
104
  - lib
110
105
  required_ruby_version: !ruby/object:Gem::Requirement
111
- none: false
112
106
  requirements:
113
107
  - - ! '>='
114
108
  - !ruby/object:Gem::Version
115
109
  version: '0'
116
- segments:
117
- - 0
118
- hash: -2636841020204959601
119
110
  required_rubygems_version: !ruby/object:Gem::Requirement
120
- none: false
121
111
  requirements:
122
112
  - - ! '>='
123
113
  - !ruby/object:Gem::Version
124
114
  version: '0'
125
115
  requirements: []
126
116
  rubyforge_project:
127
- rubygems_version: 1.8.18
117
+ rubygems_version: 2.1.5
128
118
  signing_key:
129
- specification_version: 3
119
+ specification_version: 4
130
120
  summary: A simple logger for Ruby
131
121
  test_files: []