sapience 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -9
- data/config/default.yml +4 -4
- data/lib/sapience.rb +1 -1
- data/lib/sapience/appender/{file.rb → stream.rb} +9 -9
- data/lib/sapience/base.rb +2 -2
- data/lib/sapience/configuration.rb +1 -1
- data/lib/sapience/formatters/color.rb +1 -1
- data/lib/sapience/logger.rb +1 -1
- data/lib/sapience/sapience.rb +6 -6
- data/lib/sapience/version.rb +1 -1
- data/test_app/spec/fixtures/sapience.yml +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5acd3b3dd076bc64f596d3274c065e91cde33534
|
4
|
+
data.tar.gz: b6001baf41664e17f82ae512b956b8be67d66775
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c588da952333b0717112b02bf956c4721394a9b3e25a0faf562889aaf79bbdc6d6abedffc6af48b2cfc9915fe8d3edbf1b4a37fcc46056d6c58ee1b1f5710720
|
7
|
+
data.tar.gz: a2f04ee0e9b06c8367cf909add482fba8eb9955923fbfb472f2c0808d0fddf517d1cb1acd3ccd36d5600c3bdbc7ea09adb64dc3ee3ef3762b39b38c1d477d0d7
|
data/README.md
CHANGED
@@ -39,7 +39,7 @@ Sapience.configure do |config|
|
|
39
39
|
config.backtrace_level = :error
|
40
40
|
config.application = "my-app"
|
41
41
|
config.appenders = [
|
42
|
-
{
|
42
|
+
{ stream: { io: STDOUT, formatter: :color } },
|
43
43
|
{ sentry: { dsn: "https://username:password@app.getsentry.com/00000" } },
|
44
44
|
{ datadog: { url: "udp://localhost:8125" } },
|
45
45
|
]
|
@@ -53,28 +53,28 @@ Sapience provides a default configuration that will be used unless another file
|
|
53
53
|
default:
|
54
54
|
log_level: info
|
55
55
|
appenders:
|
56
|
-
-
|
56
|
+
- stream:
|
57
57
|
io: STDOUT
|
58
58
|
formatter: color
|
59
59
|
|
60
60
|
test:
|
61
61
|
log_level: warn
|
62
62
|
appenders:
|
63
|
-
-
|
63
|
+
- stream:
|
64
64
|
file_name: log/test.log
|
65
65
|
formatter: color
|
66
66
|
|
67
67
|
development:
|
68
68
|
log_level: debug
|
69
69
|
appenders:
|
70
|
-
-
|
70
|
+
- stream:
|
71
71
|
file_name: log/development.log
|
72
72
|
formatter: color
|
73
73
|
|
74
74
|
production:
|
75
75
|
log_level: warn
|
76
76
|
appenders:
|
77
|
-
-
|
77
|
+
- stream:
|
78
78
|
file_name: log/production.log
|
79
79
|
formatter: json
|
80
80
|
```
|
@@ -86,13 +86,13 @@ One of the things that did not suite us so well with the Semantic Logger approac
|
|
86
86
|
There are a number of appenders that all listen to different events and act on its data. It is possible to specify the `level` and `backtrace_level` for each appender by providing (example) `level: :error` to the add_appender method.
|
87
87
|
|
88
88
|
|
89
|
-
###
|
89
|
+
### Stream
|
90
90
|
|
91
|
-
|
91
|
+
Stream appenders are basically a log stream. You can add as many stream appenders as you like logging to different locations.
|
92
92
|
|
93
93
|
```ruby
|
94
|
-
Sapience.add_appender(:
|
95
|
-
Sapience.add_appender(:
|
94
|
+
Sapience.add_appender(:stream, file: "log/sapience.log", formatter: :json)
|
95
|
+
Sapience.add_appender(:stream, io: STDOUT, formatter: :color, level: :trace)
|
96
96
|
```
|
97
97
|
|
98
98
|
### Sentry
|
data/config/default.yml
CHANGED
@@ -2,27 +2,27 @@
|
|
2
2
|
default:
|
3
3
|
log_level: info
|
4
4
|
appenders:
|
5
|
-
-
|
5
|
+
- stream:
|
6
6
|
io: STDOUT
|
7
7
|
formatter: color
|
8
8
|
|
9
9
|
test:
|
10
10
|
log_level: warn
|
11
11
|
appenders:
|
12
|
-
-
|
12
|
+
- stream:
|
13
13
|
file_name: log/test.log
|
14
14
|
formatter: color
|
15
15
|
|
16
16
|
development:
|
17
17
|
log_level: debug
|
18
18
|
appenders:
|
19
|
-
-
|
19
|
+
- stream:
|
20
20
|
file_name: log/development.log
|
21
21
|
formatter: color
|
22
22
|
|
23
23
|
production:
|
24
24
|
log_level: warn
|
25
25
|
appenders:
|
26
|
-
-
|
26
|
+
- stream:
|
27
27
|
file_name: log/production.log
|
28
28
|
formatter: json
|
data/lib/sapience.rb
CHANGED
@@ -23,7 +23,7 @@ require "sapience/logger"
|
|
23
23
|
require "sapience/loggable"
|
24
24
|
require "sapience/subscriber"
|
25
25
|
|
26
|
-
require "sapience/appender/
|
26
|
+
require "sapience/appender/stream"
|
27
27
|
require "sapience/appender/sentry"
|
28
28
|
require "sapience/appender/wrapper"
|
29
29
|
require "sapience/appender/datadog"
|
@@ -1,12 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# Stream appender
|
2
2
|
#
|
3
|
-
# Writes log messages to a file or open
|
3
|
+
# Writes log messages to a file or open IO stream
|
4
4
|
#
|
5
5
|
module Sapience
|
6
6
|
module Appender
|
7
|
-
class
|
7
|
+
class Stream < Sapience::Subscriber
|
8
8
|
|
9
|
-
# Create a
|
9
|
+
# Create a Stream Logger appender instance.
|
10
10
|
#
|
11
11
|
# Parameters
|
12
12
|
# :file_name [String|IO]
|
@@ -35,10 +35,10 @@ module Sapience
|
|
35
35
|
# Sapience.config.default_level = :info
|
36
36
|
#
|
37
37
|
# # Log to screen
|
38
|
-
# Sapience.add_appender(:
|
38
|
+
# Sapience.add_appender(:stream, io: STDOUT, formatter: :color)
|
39
39
|
#
|
40
40
|
# # And log to a file at the same time
|
41
|
-
# Sapience::Logger.add_appender(:
|
41
|
+
# Sapience::Logger.add_appender(:stream, file_name: 'application.log', formatter: :color)
|
42
42
|
#
|
43
43
|
# logger = Sapience['test']
|
44
44
|
# logger.info 'Hello World'
|
@@ -51,17 +51,17 @@ module Sapience
|
|
51
51
|
# Sapience.config.default_level = :trace
|
52
52
|
#
|
53
53
|
# # Log to screen but only display :info and above
|
54
|
-
# Sapience.add_appender(:
|
54
|
+
# Sapience.add_appender(:stream, io: STDOUT, level: :info)
|
55
55
|
#
|
56
56
|
# # And log to a file at the same time, including all :trace level data
|
57
|
-
# Sapience.add_appender(:
|
57
|
+
# Sapience.add_appender(:stream, file_name: 'application.log')
|
58
58
|
#
|
59
59
|
# logger = Sapience['test']
|
60
60
|
# logger.info 'Hello World'
|
61
61
|
# rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity
|
62
62
|
def initialize(options = {}, &block)
|
63
63
|
unless options[:io] || options[:file_name]
|
64
|
-
fail "Sapience::Appender::
|
64
|
+
fail "Sapience::Appender::Stream missing mandatory parameter :file_name or :io"
|
65
65
|
end
|
66
66
|
|
67
67
|
opts = options.dup
|
data/lib/sapience/base.rb
CHANGED
@@ -52,10 +52,10 @@ module Sapience
|
|
52
52
|
# Sapience.config.default_level = :info
|
53
53
|
#
|
54
54
|
# # Log to screen
|
55
|
-
# Sapience.add_appender(:
|
55
|
+
# Sapience.add_appender(:stream, io: STDOUT, formatter: :color)
|
56
56
|
#
|
57
57
|
# # And log to a file at the same time
|
58
|
-
# Sapience.add_appender(:
|
58
|
+
# Sapience.add_appender(:stream, file_name: 'application.log', formatter: :color)
|
59
59
|
#
|
60
60
|
# logger = Sapience['MyApplication']
|
61
61
|
# logger.debug("Only display this if log level is set to Debug or lower")
|
@@ -12,7 +12,7 @@ module Sapience
|
|
12
12
|
application: "Sapience",
|
13
13
|
host: nil,
|
14
14
|
ap_options: { multiline: false },
|
15
|
-
appenders: [{
|
15
|
+
appenders: [{ stream: { io: STDOUT, formatter: :color } }],
|
16
16
|
}.freeze
|
17
17
|
|
18
18
|
# Initial default Level for all new instances of Sapience::Logger
|
@@ -22,7 +22,7 @@ module Sapience
|
|
22
22
|
|
23
23
|
# Adds color to the default log formatter
|
24
24
|
# Example:
|
25
|
-
# Sapience.add_appender(:
|
25
|
+
# Sapience.add_appender(:stream, io: $stdout, formatter: :color)
|
26
26
|
def call(log, _logger) # rubocop:disable AbcSize, PerceivedComplexity, CyclomaticComplexity
|
27
27
|
colors = Sapience::AnsiColors
|
28
28
|
level_color = colors::LEVEL_MAP[log.level]
|
data/lib/sapience/logger.rb
CHANGED
data/lib/sapience/sapience.rb
CHANGED
@@ -10,7 +10,7 @@ require "socket"
|
|
10
10
|
# config.host = ENV.fetch('SAPIENCE_HOST', nil)
|
11
11
|
# config.ap_options = { multiline: false }
|
12
12
|
# config.appenders = [
|
13
|
-
# {
|
13
|
+
# { stream: { io: STDOUT, formatter: :color } },
|
14
14
|
# { statsd: { url: 'udp://localhost:2222' } },
|
15
15
|
# { sentry: { dsn: 'https://foobar:443' } },
|
16
16
|
# ]
|
@@ -134,14 +134,14 @@ module Sapience
|
|
134
134
|
# Examples:
|
135
135
|
#
|
136
136
|
# # Send all logging output to Standard Out (Screen)
|
137
|
-
# Sapience.add_appender(:
|
137
|
+
# Sapience.add_appender(:stream, io: STDOUT)
|
138
138
|
#
|
139
139
|
# # Send all logging output to a file
|
140
|
-
# Sapience.add_appender(:
|
140
|
+
# Sapience.add_appender(:stream, file_name: 'logfile.log')
|
141
141
|
#
|
142
142
|
# # Send all logging output to a file and only :info and above to standard output
|
143
|
-
# Sapience.add_appender(:
|
144
|
-
# Sapience.add_appender(:
|
143
|
+
# Sapience.add_appender(:stream, file_name: 'logfile.log')
|
144
|
+
# Sapience.add_appender(:stream, io: STDOUT, level: :info)
|
145
145
|
#
|
146
146
|
# Log to log4r, Logger, etc.:
|
147
147
|
#
|
@@ -168,7 +168,7 @@ module Sapience
|
|
168
168
|
|
169
169
|
# Start appender thread if it is not already running
|
170
170
|
Sapience::Logger.start_appender_thread
|
171
|
-
Sapience.logger = appender if appender.is_a?(Sapience::Appender::
|
171
|
+
Sapience.logger = appender if appender.is_a?(Sapience::Appender::Stream)
|
172
172
|
Sapience.metrix = appender if appender.is_a?(Sapience::Appender::Datadog)
|
173
173
|
appender
|
174
174
|
end
|
data/lib/sapience/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sapience
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikael Henriksson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-08-
|
12
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -209,8 +209,8 @@ files:
|
|
209
209
|
- lib/sapience.rb
|
210
210
|
- lib/sapience/ansi_colors.rb
|
211
211
|
- lib/sapience/appender/datadog.rb
|
212
|
-
- lib/sapience/appender/file.rb
|
213
212
|
- lib/sapience/appender/sentry.rb
|
213
|
+
- lib/sapience/appender/stream.rb
|
214
214
|
- lib/sapience/appender/wrapper.rb
|
215
215
|
- lib/sapience/base.rb
|
216
216
|
- lib/sapience/concerns/compatibility.rb
|
@@ -358,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
358
358
|
version: '0'
|
359
359
|
requirements: []
|
360
360
|
rubyforge_project:
|
361
|
-
rubygems_version: 2.
|
361
|
+
rubygems_version: 2.5.1
|
362
362
|
signing_key:
|
363
363
|
specification_version: 4
|
364
364
|
summary: Hasslefree autoconfiguration for logging, metrics and exception collection.
|