la_logger 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -0
- data/Gemfile.lock +29 -17
- data/README.md +70 -34
- data/la_logger.gemspec +3 -3
- data/lib/la_logger/version.rb +1 -1
- metadata +14 -14
data/Gemfile
CHANGED
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
|
-
|
6
|
-
bson (1.
|
7
|
-
bson_ext (1.
|
8
|
-
bson (~> 1.
|
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.
|
17
|
-
fluentd (
|
18
|
-
mongo (
|
19
|
-
fluentd (0.10.
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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.
|
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.
|
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.
|
48
|
-
backports (~> 3.3.3)
|
56
|
+
rubocop (0.13.1)
|
49
57
|
parser (~> 2.0.0.pre6)
|
50
|
-
powerpack (~> 0.0.
|
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
|
-
|
1
|
+
## LaLogger: A general logger module wraps Fluentd-logger
|
2
2
|
|
3
|
-
|
3
|
+
### Requirement
|
4
4
|
|
5
|
-
|
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
|
-
|
8
|
-
setting in `fluent.conf`) and log level:
|
9
|
+
### Concept
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
11
|
+
- Singleton
|
12
|
+
- Severity control
|
13
|
+
- Centralized log storage by fluentd
|
14
|
+
- Send to STDERR in debug mode
|
15
15
|
|
16
|
-
|
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
|
-
|
22
|
-
logger.post('custom.tag', {custom: 'message'})
|
23
|
-
end
|
24
|
-
end
|
18
|
+
Setup fluentd configuration to forward specific tag:
|
25
19
|
|
26
|
-
|
20
|
+
<match la.**>
|
21
|
+
# plugin type
|
22
|
+
type mongo
|
27
23
|
|
28
|
-
|
29
|
-
|
24
|
+
# mongodb host + port
|
25
|
+
host localhost
|
26
|
+
port 27017
|
30
27
|
|
31
|
-
|
28
|
+
# mongodb db + collection
|
29
|
+
database lalogger_test
|
30
|
+
tag_mapped
|
31
|
+
collection default
|
32
32
|
|
33
|
-
|
34
|
-
change this setting after logger object has created.
|
33
|
+
remove_tag_prefix la.
|
35
34
|
|
36
|
-
|
35
|
+
# interval
|
36
|
+
flush_interval 1s
|
37
|
+
</match>
|
37
38
|
|
38
|
-
|
39
|
-
fatal, unknown`.
|
39
|
+
In your program:
|
40
40
|
|
41
|
-
|
41
|
+
1. Define the host and ip where `fluentd` is running and a `global` tag matches `<match la.**>` above:
|
42
42
|
|
43
|
-
|
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
|
-
|
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
|
-
|
72
|
+
You can use `raw` command `post` too:
|
48
73
|
|
49
|
-
|
74
|
+
~~~~~~~~~ ruby
|
75
|
+
# send (post) message using fluent-logger object directly
|
76
|
+
logger.post('custom.tag', {custom: 'message'})
|
77
|
+
~~~~~~~~~~~~~~~~
|
50
78
|
|
51
|
-
|
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'
|
16
|
-
s.add_development_dependency 'rspec'
|
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'
|
19
|
+
s.add_development_dependency 'simplecov'
|
20
20
|
end
|
data/lib/la_logger/version.rb
CHANGED
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.
|
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-
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
109
|
+
version: '0'
|
110
110
|
description: A singleton wrapper for fluent logger.
|
111
111
|
email: huangw@7lime.com
|
112
112
|
executables: []
|