logatron 0.1.2 → 0.1.4
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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/lib/logatron/basic_logger.rb +14 -17
- data/lib/logatron/basic_scoped_logger.rb +6 -1
- data/lib/logatron/configuration.rb +14 -2
- data/lib/logatron/const.rb +8 -0
- data/lib/logatron/message_formatting.rb +2 -0
- data/lib/logatron/railtie.rb +7 -1
- data/lib/logatron/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 62a07d92d7abeffea265750308ed64ef263dc225
|
|
4
|
+
data.tar.gz: 881eeb3bbd022b0c0c5e2d4ca22e69ec14f6d5be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 542a4428a588fa04f6a110e41d5a976a1fb2b4a75d729f0f013cbba333dfd2b18736fd21f95969189f31d993b9e123434ed26080ac732780a53e0161da8389e0
|
|
7
|
+
data.tar.gz: 5ea1382b0ccdc27da974228549ee66681077e685ba55b137ca2e5899a3e8c79e2b5c2332dd22940665bd9bf1be6e90db49fdef45a92c7c281acd6961a5edeb96
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.2.2
|
|
@@ -1,42 +1,39 @@
|
|
|
1
|
+
require 'logatron/message_formatting'
|
|
2
|
+
require 'logatron/const'
|
|
3
|
+
require 'logatron/configuration'
|
|
4
|
+
require 'logatron/basic_scoped_logger'
|
|
1
5
|
module Logatron
|
|
2
6
|
class BasicLogger
|
|
3
7
|
include Logatron::Formatting
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
Logatron::DEBUG => 0,
|
|
7
|
-
Logatron::INFO => 1,
|
|
8
|
-
Logatron::WARN => 2,
|
|
9
|
-
Logatron::ERROR => 3,
|
|
10
|
-
Logatron::CRITICAL => 4,
|
|
11
|
-
Logatron::FATAL => 5
|
|
12
|
-
}
|
|
9
|
+
|
|
13
10
|
|
|
14
11
|
def level=(a_level)
|
|
15
|
-
Logatron.configuration.logger.level =
|
|
12
|
+
Logatron.configuration.logger.level = SEVERITY_MAP[a_level]
|
|
16
13
|
end
|
|
17
14
|
|
|
18
15
|
def info(msg)
|
|
19
|
-
write(format_log(msg: msg, severity: INFO),
|
|
16
|
+
write(format_log(msg: msg, severity: INFO), SEVERITY_MAP[INFO])
|
|
20
17
|
end
|
|
21
18
|
|
|
22
19
|
def warn(msg)
|
|
23
|
-
write(format_log(msg: msg, severity: WARN),
|
|
20
|
+
write(format_log(msg: msg, severity: WARN), SEVERITY_MAP[WARN])
|
|
24
21
|
end
|
|
25
22
|
|
|
26
23
|
def debug(msg)
|
|
27
|
-
write(format_log(msg: msg, severity: DEBUG),
|
|
24
|
+
write(format_log(msg: msg, severity: DEBUG), SEVERITY_MAP[DEBUG])
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def error(msg)
|
|
31
|
-
write(format_log(msg: msg, severity: ERROR),
|
|
28
|
+
write(format_log(msg: msg, severity: ERROR), SEVERITY_MAP[ERROR])
|
|
32
29
|
end
|
|
33
30
|
|
|
34
31
|
def critical(msg)
|
|
35
|
-
write(format_log(msg: msg, severity: CRITICAL),
|
|
32
|
+
write(format_log(msg: msg, severity: CRITICAL), SEVERITY_MAP[CRITICAL])
|
|
36
33
|
end
|
|
37
34
|
|
|
38
35
|
def fatal(msg)
|
|
39
|
-
write(format_log(msg: msg, severity: FATAL),
|
|
36
|
+
write(format_log(msg: msg, severity: FATAL), SEVERITY_MAP[FATAL])
|
|
40
37
|
end
|
|
41
38
|
|
|
42
39
|
def log(id: '-', site: '-', msg: '-', severity: INFO, request: '-', status: '-', source: '-', &block)
|
|
@@ -44,10 +41,10 @@ module Logatron
|
|
|
44
41
|
start = Time.now
|
|
45
42
|
begin
|
|
46
43
|
res = block.call(ml)
|
|
47
|
-
write(format_log(severity: severity, msg: msg, status: status, duration: milliseconds_elapsed(Time.now, start), inputs: source, request: request),
|
|
44
|
+
write(format_log(severity: severity, msg: msg, status: status, duration: milliseconds_elapsed(Time.now, start), inputs: source, request: request),SEVERITY_MAP[severity])
|
|
48
45
|
res
|
|
49
46
|
rescue Exception => e
|
|
50
|
-
write(format_log(severity: severity, msg: msg, status: status, duration: milliseconds_elapsed(Time.now, start), inputs: source, request: request),
|
|
47
|
+
write(format_log(severity: severity, msg: msg, status: status, duration: milliseconds_elapsed(Time.now, start), inputs: source, request: request),SEVERITY_MAP[severity])
|
|
51
48
|
ml.flush
|
|
52
49
|
raise e
|
|
53
50
|
end
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
require 'logatron/const'
|
|
2
|
+
require 'logatron/basic_logger'
|
|
3
|
+
require 'logatron/message_formatting'
|
|
4
|
+
require 'logatron/configuration'
|
|
5
|
+
|
|
1
6
|
module Logatron
|
|
2
7
|
class BasicScopedLogger
|
|
3
8
|
include Logatron::Formatting
|
|
@@ -45,7 +50,7 @@ module Logatron
|
|
|
45
50
|
def flush
|
|
46
51
|
Logatron.configuration.loggable_levels.each do |key|
|
|
47
52
|
@logs[key].each do |item|
|
|
48
|
-
@logger.write(item,
|
|
53
|
+
@logger.write(item,SEVERITY_MAP[key])
|
|
49
54
|
end
|
|
50
55
|
end
|
|
51
56
|
end
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
require 'syslog/logger'
|
|
2
|
+
require 'logatron/const'
|
|
3
|
+
require 'logatron/basic_formatter'
|
|
4
|
+
require 'active_support/backtrace_cleaner'
|
|
5
|
+
require 'active_support/json'
|
|
2
6
|
|
|
3
7
|
module Logatron
|
|
4
8
|
class << self
|
|
5
|
-
|
|
9
|
+
def configuration=
|
|
10
|
+
@configuration = configuration
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def configuration
|
|
14
|
+
@configuration ||= Configuration.new
|
|
15
|
+
end
|
|
6
16
|
end
|
|
7
17
|
|
|
18
|
+
|
|
8
19
|
def self.configure
|
|
9
|
-
self.configuration
|
|
20
|
+
self.configuration
|
|
10
21
|
yield(configuration)
|
|
11
22
|
end
|
|
12
23
|
|
|
@@ -16,6 +27,7 @@ module Logatron
|
|
|
16
27
|
|
|
17
28
|
def initialize
|
|
18
29
|
@logger = Syslog::Logger.new('ascent')
|
|
30
|
+
|
|
19
31
|
@transformer = proc {|x| x.to_json}
|
|
20
32
|
@host = `hostname`.chomp
|
|
21
33
|
@level = INFO
|
data/lib/logatron/const.rb
CHANGED
data/lib/logatron/railtie.rb
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
module Syslog
|
|
2
|
+
class Logger
|
|
3
|
+
alias_method :log, :add
|
|
4
|
+
end
|
|
5
|
+
end
|
|
6
|
+
|
|
1
7
|
module Logatron
|
|
2
8
|
class Middleware
|
|
3
9
|
def initialize(app)
|
|
@@ -28,7 +34,7 @@ module Logatron
|
|
|
28
34
|
|
|
29
35
|
end
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
config.lograge.logger = Logatron
|
|
32
38
|
config.lograge.enabled = true
|
|
33
39
|
config.lograge.formatter = Lograge::Formatters::Json.new
|
|
34
40
|
config.lograge.custom_options = lambda do |event|
|
data/lib/logatron/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: logatron
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Grimes
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -80,6 +80,7 @@ extensions: []
|
|
|
80
80
|
extra_rdoc_files: []
|
|
81
81
|
files:
|
|
82
82
|
- ".gitignore"
|
|
83
|
+
- ".ruby-version"
|
|
83
84
|
- CODE_OF_CONDUCT.md
|
|
84
85
|
- Gemfile
|
|
85
86
|
- Gemfile.lock
|