la_logger 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  source 'http://ruby.taobao.org/'
2
2
 
3
3
  gem 'fluent-logger'
4
+ gem 'activesupport'
4
5
 
5
6
  group :development do
6
7
  gem 'fluentd'
data/Gemfile.lock CHANGED
@@ -1,11 +1,17 @@
1
1
  GEM
2
2
  remote: http://ruby.taobao.org/
3
3
  specs:
4
+ activesupport (4.0.0)
5
+ i18n (~> 0.6, >= 0.6.4)
6
+ minitest (~> 4.2)
7
+ multi_json (~> 1.3)
8
+ thread_safe (~> 0.1)
9
+ tzinfo (~> 0.3.37)
4
10
  ast (1.1.0)
5
- backports (3.3.3)
6
- bson (1.9.2)
7
- bson_ext (1.9.2)
8
- bson (~> 1.9.2)
11
+ atomic (1.1.14)
12
+ bson (1.8.6)
13
+ bson_ext (1.8.6)
14
+ bson (~> 1.8.6)
9
15
  cool.io (1.1.1)
10
16
  iobuffer (>= 1.0.0)
11
17
  diff-lcs (1.2.4)
@@ -13,10 +19,10 @@ GEM
13
19
  fluent-logger (0.4.6)
14
20
  msgpack (>= 0.4.4, < 0.6.0, != 0.5.3, != 0.5.2, != 0.5.1, != 0.5.0)
15
21
  yajl-ruby (~> 1.0)
16
- fluent-plugin-mongo (0.6.7)
17
- fluentd (>= 0.10.7)
18
- mongo (>= 1.6.0)
19
- fluentd (0.10.38)
22
+ fluent-plugin-mongo (0.7.1)
23
+ fluentd (~> 0.10.9)
24
+ mongo (~> 1.8.0)
25
+ fluentd (0.10.39)
20
26
  cool.io (~> 1.1.1)
21
27
  http_parser.rb (~> 0.5.1)
22
28
  json (>= 1.4.3)
@@ -26,37 +32,43 @@ GEM
26
32
  dotenv (>= 0.7)
27
33
  thor (>= 0.13.6)
28
34
  http_parser.rb (0.5.3)
35
+ i18n (0.6.5)
29
36
  iobuffer (1.1.2)
30
37
  json (1.8.0)
31
- mongo (1.9.1)
32
- bson (~> 1.9.1)
33
- msgpack (0.5.5)
34
- parser (2.0.0.pre6)
38
+ minitest (4.7.5)
39
+ mongo (1.8.6)
40
+ bson (~> 1.8.6)
41
+ msgpack (0.5.6)
42
+ multi_json (1.8.0)
43
+ parser (2.0.0.pre8)
35
44
  ast (~> 1.1)
36
45
  slop (~> 3.4, >= 3.4.5)
37
- powerpack (0.0.6)
46
+ powerpack (0.0.8)
38
47
  rainbow (1.1.4)
39
48
  rspec (2.14.1)
40
49
  rspec-core (~> 2.14.0)
41
50
  rspec-expectations (~> 2.14.0)
42
51
  rspec-mocks (~> 2.14.0)
43
52
  rspec-core (2.14.5)
44
- rspec-expectations (2.14.2)
53
+ rspec-expectations (2.14.3)
45
54
  diff-lcs (>= 1.1.3, < 2.0)
46
55
  rspec-mocks (2.14.3)
47
- rubocop (0.12.0)
48
- backports (~> 3.3.3)
56
+ rubocop (0.13.1)
49
57
  parser (~> 2.0.0.pre6)
50
- powerpack (~> 0.0.3)
58
+ powerpack (~> 0.0.6)
51
59
  rainbow (>= 1.1.4)
52
60
  slop (3.4.6)
53
61
  thor (0.18.1)
62
+ thread_safe (0.1.3)
63
+ atomic
64
+ tzinfo (0.3.37)
54
65
  yajl-ruby (1.1.0)
55
66
 
56
67
  PLATFORMS
57
68
  ruby
58
69
 
59
70
  DEPENDENCIES
71
+ activesupport
60
72
  bson_ext
61
73
  fluent-logger
62
74
  fluent-plugin-mongo
data/README.md CHANGED
@@ -1,53 +1,89 @@
1
- # LaLogger: A general logger module wraps Fluentd-logger
1
+ ## LaLogger: A general logger module wraps Fluentd-logger
2
2
 
3
- Require: ruby 1.9.x, fluent-logger (not working on JRuby without modification).
3
+ ### Requirement
4
4
 
5
- ## Concepts
5
+ - ruby 1.9.x,
6
+ - activesupport
7
+ - fluent-logger (which depends on `yaji-ruby` so will not working on JRuby without modification)
6
8
 
7
- - Initialize a logger object with `tag` (which becomings collection name for `tag_mapped`
8
- setting in `fluent.conf`) and log level:
9
+ ### Concept
9
10
 
10
- class LoggerUser
11
- def logger
12
- # initialize tag and log level, default level is 'WARN'
13
- LaLogger.new('specific_tag', LaLogger::ERROR)
14
- end
11
+ - Singleton
12
+ - Severity control
13
+ - Centralized log storage by fluentd
14
+ - Send to STDERR in debug mode
15
15
 
16
- def logger_this
17
- # use warn, error, fatal, ... to log messages with optional
18
- # extra information in hash format:
19
- logger.error('oops! an error happend!', {extra: 'data'})
16
+ ### Synopsis
20
17
 
21
- # send (post) message using fluent-logger object directly
22
- logger.post('custom.tag', {custom: 'message'})
23
- end
24
- end
18
+ Setup fluentd configuration to forward specific tag:
25
19
 
26
- - Silently fails-over to `STDOUT` if `ENV['FLUENTD']` not defined.
20
+ <match la.**>
21
+ # plugin type
22
+ type mongo
27
23
 
28
- To use fluentd service, define: `ENV[FLUENTD] = 'localhost:24224:label'`
29
- somewhere in your code before use the logger.
24
+ # mongodb host + port
25
+ host localhost
26
+ port 27017
30
27
 
31
- Default port `24224` is optional, `label` is also optional (default is `nil`).
28
+ # mongodb db + collection
29
+ database lalogger_test
30
+ tag_mapped
31
+ collection default
32
32
 
33
- Note: as logger object is wrapped by a singleton class, there is no effect to
34
- change this setting after logger object has created.
33
+ remove_tag_prefix la.
35
34
 
36
- ## Severities
35
+ # interval
36
+ flush_interval 1s
37
+ </match>
37
38
 
38
- Imported from ruby's default `Logger::Severity`, namely: `debug, info, warn, error,
39
- fatal, unknown`.
39
+ In your program:
40
40
 
41
- ## Develop or Test
41
+ 1. Define the host and ip where `fluentd` is running and a `global` tag matches `<match la.**>` above:
42
42
 
43
- Run `foreman start` to start the `fluentd` server fro test.
43
+ ~~~~~~ ruby
44
+ ENV[FLUENTD] = 'localhost:24224:la'
45
+ ~~~~~~~~~~~~~~~~
46
+
47
+ default port `24224` is optional: `localhost::la` is same as above.
48
+
49
+ Note: as logger object is wrapped by a singleton class, there is no effect to
50
+ change this setting after logger object has created.
51
+
52
+ 2. Use the logger in your program:
53
+
54
+ ~~~~~~ ruby
55
+ def logger
56
+ # initialize tag and log level, default level is 'WARN'
57
+ LaLogger.new('la.logger.tag', LaLogger::ERROR)
58
+ end
59
+ ~~~~~~~~~~~~~~~~
60
+
61
+ Tag set here will becoming collection name if you use `tag_mapped`
62
+ setting in your `fluent.conf` file
44
63
 
45
- ## Production
64
+ ~~~~~~ ruby
65
+ def logger_this
66
+ # use warn, error, fatal, ... to log messages with optional
67
+ # extra information in hash format:
68
+ logger.error('oops! an error happend!', {extra: 'data'})
69
+ end
70
+ ~~~~~~~~~~~~~~~~
46
71
 
47
- Set up your fluentd conf file, set
72
+ You can use `raw` command `post` too:
48
73
 
49
- <match lalogger.**>
74
+ ~~~~~~~~~ ruby
75
+ # send (post) message using fluent-logger object directly
76
+ logger.post('custom.tag', {custom: 'message'})
77
+ ~~~~~~~~~~~~~~~~
50
78
 
51
- where `lalogger` equals the tag parts you set in your `ENV['FLUENTD']` variable.
79
+ In this way you can specify an `tag`.
80
+
81
+ ## Severities
82
+
83
+ Imported from ruby's default `Logger::Severity`,
84
+ namely: `debug, info, warn, error, fatal, unknown`.
85
+
86
+ ## Develop or Test
87
+
88
+ Run `foreman start` to start the `fluentd` server fro test.
52
89
 
53
- Optionally set `remove_tag_prefix lalogger.` to remove tag from collection names.
data/la_logger.gemspec CHANGED
@@ -12,9 +12,9 @@ Gem::Specification.new 'la_logger', LaLogger::VERSION do |s|
12
12
  s.test_files = Dir.glob('{spec,test}/**/*.rb')
13
13
 
14
14
  s.add_dependency 'fluent-logger'
15
- s.add_dependency 'activesupport', '~> 3.2'
16
- s.add_development_dependency 'rspec', '~> 2.5'
15
+ s.add_dependency 'activesupport'
16
+ s.add_development_dependency 'rspec'
17
17
  s.add_development_dependency 'mongo'
18
18
  s.add_development_dependency 'bson_ext'
19
- s.add_development_dependency 'simplecov', '~> 2.5'
19
+ s.add_development_dependency 'simplecov'
20
20
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Define version of the module
4
4
  module LaLogger
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.2'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: la_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-25 00:00:00.000000000 Z
12
+ date: 2013-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluent-logger
@@ -32,33 +32,33 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: '3.2'
37
+ version: '0'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: '3.2'
45
+ version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rspec
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ~>
51
+ - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
- version: '2.5'
53
+ version: '0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ~>
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
- version: '2.5'
61
+ version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: mongo
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -96,17 +96,17 @@ dependencies:
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
- - - ~>
99
+ - - ! '>='
100
100
  - !ruby/object:Gem::Version
101
- version: '2.5'
101
+ version: '0'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
- - - ~>
107
+ - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
- version: '2.5'
109
+ version: '0'
110
110
  description: A singleton wrapper for fluent logger.
111
111
  email: huangw@7lime.com
112
112
  executables: []