filum 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/filum.rb +7 -1
- data/lib/filum/logger.rb +5 -5
- data/lib/filum/version.rb +1 -1
- data/test/integration/integration_test.rb +1 -1
- data/test/integration/logger_test.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc7fea2cacec8aaaa40b2017b9af8fc54c2aa224
|
4
|
+
data.tar.gz: d93d4e4bca152a0569e2d88be143c508a7fedaa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23153c103796478843318c97a3bb5753ffca5b824f62c42106e9f518b43a4c614cf5f976699d3d043736ca7e8b5ca764150e983724b197f36271543e55f50daa
|
7
|
+
data.tar.gz: 7e6d5ce623f159cadefcdc63ffcd11e8e5629dcbf92d70a75125a95d377eeb339bf56b186c933287a989514a4246bba394df4b716d4dfa5dfec661f10567e426
|
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Filum
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/meducation/filum.png)](https://travis-ci.org/meducation/filum)
|
4
|
+
[![Dependencies](https://gemnasium.com/meducation/filum.png?travis)](https://gemnasium.com/meducation/filum)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/meducation/filum.png)](https://codeclimate.com/github/meducation/filum)
|
6
|
+
|
7
|
+
|
3
8
|
Filum is a logger which automatically adds a context id to each log line.
|
4
9
|
|
5
10
|
This is useful when logging in multi threaded and multi process environments.
|
data/lib/filum.rb
CHANGED
@@ -32,7 +32,13 @@ module Filum
|
|
32
32
|
# Filum.logger.info "Log this"
|
33
33
|
#
|
34
34
|
def self.logger
|
35
|
-
|
35
|
+
logfile = Filum.config.logfile
|
36
|
+
dir = File.dirname(logfile)
|
37
|
+
unless File.directory?(dir)
|
38
|
+
FileUtils.mkdir_p(dir)
|
39
|
+
end
|
40
|
+
|
41
|
+
@logger ||= Filum::Logger.new(logfile)
|
36
42
|
@logger.level = Logger::INFO
|
37
43
|
@logger
|
38
44
|
end
|
data/lib/filum/logger.rb
CHANGED
@@ -7,23 +7,23 @@ module Filum
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def info(str)
|
10
|
-
super("#{DateTime.now} thread_id-#{Thread.current.object_id}
|
10
|
+
super("#{DateTime.now} thread_id-#{Thread.current.object_id} [#{Thread.current[:context_id]}] INFO | #{str} | #{caller[0]}")
|
11
11
|
end
|
12
12
|
|
13
13
|
def fatal(str)
|
14
|
-
super("#{DateTime.now} thread_id-#{Thread.current.object_id}
|
14
|
+
super("#{DateTime.now} thread_id-#{Thread.current.object_id} [#{Thread.current[:context_id]}] FATAL | #{str} | #{caller[0]}")
|
15
15
|
end
|
16
16
|
|
17
17
|
def error(str)
|
18
|
-
super("#{DateTime.now} thread_id-#{Thread.current.object_id}
|
18
|
+
super("#{DateTime.now} thread_id-#{Thread.current.object_id} [#{Thread.current[:context_id]}] ERROR | #{str} | #{caller[0]}")
|
19
19
|
end
|
20
20
|
|
21
21
|
def warn(str)
|
22
|
-
super("#{DateTime.now} thread_id-#{Thread.current.object_id}
|
22
|
+
super("#{DateTime.now} thread_id-#{Thread.current.object_id} [#{Thread.current[:context_id]}] WARN | #{str} | #{caller[0]}")
|
23
23
|
end
|
24
24
|
|
25
25
|
def debug(str)
|
26
|
-
super("#{DateTime.now} thread_id-#{Thread.current.object_id}
|
26
|
+
super("#{DateTime.now} thread_id-#{Thread.current.object_id} [#{Thread.current[:context_id]}] DEBUG | #{str} | #{caller[0]}")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
data/lib/filum/version.rb
CHANGED
@@ -15,7 +15,7 @@ module Filum
|
|
15
15
|
Worker.process
|
16
16
|
end
|
17
17
|
test_thread.join
|
18
|
-
assert_logged(/\[12345\]
|
18
|
+
assert_logged(/\[12345\]/)
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_multiple_threads
|
@@ -29,8 +29,8 @@ module Filum
|
|
29
29
|
end
|
30
30
|
test_thread1.join
|
31
31
|
test_thread2.join
|
32
|
-
assert_logged(/\[23456\]
|
33
|
-
assert_logged(/\[34567\]
|
32
|
+
assert_logged(/\[23456\]/)
|
33
|
+
assert_logged(/\[34567\]/)
|
34
34
|
end
|
35
35
|
|
36
36
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MalcyL
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|