mozart-logger 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +3 -0
- data/README.md +68 -0
- data/Rakefile +1 -0
- data/bin/console +8 -0
- data/bin/setup +7 -0
- data/lib/mozart/logger.rb +48 -0
- data/lib/mozart/logger/version.rb +5 -0
- data/mozart-logger.gemspec +33 -0
- metadata +192 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f7c63bb92a60380465f491c0d7d2208ed5145464
|
4
|
+
data.tar.gz: ffcf8f0062eb557e4b55457d062557d7236091ed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21425e38edf06ee63c3eeabf009179e7d7c566ef3f15fd8e404dac86a16f0ef609c3905e063d539be87ac16d298790210a3b8d5e1b08244f35a9686c2cd44662
|
7
|
+
data.tar.gz: dcb680da53ab6e82da137c7756ed1d0e527a29e4568983955d56b26b303da752daf7cb8a290ad79c98240bc32cfc2d8f3c2c9bd2e156b9e8b077e18d1933a171
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Mozart::Logger
|
2
|
+
|
3
|
+
Private gem for setting up structured logging and metrics for use within our Mozart service applications.
|
4
|
+
|
5
|
+
It is an abstraction wrapping around our open-source software [Alephant Logger](https://github.com/BBC-News/alephant-logger).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
group :production do
|
13
|
+
gem "mozart-logger", "1.0.0", :git => "git@github.com:bbc/mozart-logger.git"
|
14
|
+
end
|
15
|
+
```
|
16
|
+
|
17
|
+
> Note: this is a private gem published to
|
18
|
+
> https://gemstore.news.tools.bbc.co.uk/nexus
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle install
|
23
|
+
|
24
|
+
## Setup
|
25
|
+
|
26
|
+
```rb
|
27
|
+
require "mozart/logger"
|
28
|
+
|
29
|
+
opts = {
|
30
|
+
:statsd => {
|
31
|
+
:host => ENV["STATSD_HOST"],
|
32
|
+
:port => 8125,
|
33
|
+
:namespace => "mozart-routing"
|
34
|
+
},
|
35
|
+
:cloudwatch => {
|
36
|
+
:namespace => ENV["CLOUDWATCH_NAMESPACE"]
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
Mozart::Logger.setup opts, ENV["APP_LOG_LOCATION"] # configures Alephant Logger
|
41
|
+
|
42
|
+
use Rack::CommonLogger, Alephant::Logger.get_logger # optional
|
43
|
+
```
|
44
|
+
|
45
|
+
> Note: you should only provide one key
|
46
|
+
> either `:statsd` or `:cloudwatch`
|
47
|
+
> the latter will be ignored if both provided
|
48
|
+
|
49
|
+
## Usage
|
50
|
+
|
51
|
+
```rb
|
52
|
+
require "alephant/logger"
|
53
|
+
|
54
|
+
class Foo
|
55
|
+
include include Alephant::Logger
|
56
|
+
|
57
|
+
def initialize
|
58
|
+
logger.info(
|
59
|
+
"event" => "ClassInitialized",
|
60
|
+
"method" => "#{self.class.name}##{__method__}",
|
61
|
+
"someKey" => 123
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
> Note: for more details, refer to the following gems
|
68
|
+
> [Alephant-Logger-CloudWatch](https://github.com/BBC-News/alephant-logger-cloudwatch), [Alephant-Logger-Statsd](https://github.com/BBC-News/alephant-logger-statsd/) and [Alephant-Logger-JSON](https://github.com/BBC-News/alephant-logger-json)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "mozart/logger/version"
|
2
|
+
require "alephant/logger"
|
3
|
+
require "alephant/logger/json"
|
4
|
+
require "alephant/logger/statsd"
|
5
|
+
require "alephant/logger/cloudwatch"
|
6
|
+
require "bbc/cosmos/config"
|
7
|
+
|
8
|
+
module Mozart
|
9
|
+
module Logger
|
10
|
+
def self.setup(opts, log_path)
|
11
|
+
Alephant::Logger.setup drivers(opts, log_path)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.drivers(opts, log_path)
|
15
|
+
[].tap do |drivers|
|
16
|
+
drivers << json_driver(log_path)
|
17
|
+
drivers << metric_driver(opts)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.metric_driver(opts)
|
22
|
+
return statsd_driver(opts[:statsd]) if opts[:statsd]
|
23
|
+
cloudwatch_driver(opts[:cloudwatch]) if opts[:cloudwatch] && production?
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.json_driver(log_path)
|
27
|
+
Alephant::Logger::JSON.new log_path
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.statsd_driver(opts)
|
31
|
+
Alephant::Logger::Statsd.new opts
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.cloudwatch_driver(opts)
|
35
|
+
Alephant::Logger::CloudWatch.new cloudwatch_namespace(opts)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.cloudwatch_namespace(opts)
|
39
|
+
opts.tap do |h|
|
40
|
+
h[:namespace] = h[:namespace] % BBC::Cosmos::Config.cosmos.environment
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.production?
|
45
|
+
BBC::Cosmos::Config.cosmos.environment == "live"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "mozart/logger/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "mozart-logger"
|
7
|
+
spec.version = Mozart::Logger::VERSION
|
8
|
+
spec.authors = ["BBC News"]
|
9
|
+
spec.email = ["FutureMediaNewsRubyGems@bbc.co.uk"]
|
10
|
+
|
11
|
+
spec.summary = "Mozart Logging and Metrics"
|
12
|
+
spec.description = "Private gem setting up logging/metrics for Mozart"
|
13
|
+
spec.homepage = "https://github.com/bbc/mozart-logger"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "rspec-nc"
|
26
|
+
spec.add_development_dependency "pry"
|
27
|
+
|
28
|
+
spec.add_runtime_dependency "alephant-logger", "~> 3"
|
29
|
+
spec.add_runtime_dependency "alephant-logger-json", "~> 0"
|
30
|
+
spec.add_runtime_dependency "alephant-logger-statsd", "~> 0"
|
31
|
+
spec.add_runtime_dependency "alephant-logger-cloudwatch", "~> 2"
|
32
|
+
spec.add_runtime_dependency "bbc-cosmos-config"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mozart-logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- BBC News
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-nc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: alephant-logger
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: alephant-logger-json
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: alephant-logger-statsd
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: alephant-logger-cloudwatch
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: bbc-cosmos-config
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: Private gem setting up logging/metrics for Mozart
|
154
|
+
email:
|
155
|
+
- FutureMediaNewsRubyGems@bbc.co.uk
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".gitignore"
|
161
|
+
- Gemfile
|
162
|
+
- README.md
|
163
|
+
- Rakefile
|
164
|
+
- bin/console
|
165
|
+
- bin/setup
|
166
|
+
- lib/mozart/logger.rb
|
167
|
+
- lib/mozart/logger/version.rb
|
168
|
+
- mozart-logger.gemspec
|
169
|
+
homepage: https://github.com/bbc/mozart-logger
|
170
|
+
licenses: []
|
171
|
+
metadata: {}
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
requirements: []
|
187
|
+
rubyforge_project:
|
188
|
+
rubygems_version: 2.2.2
|
189
|
+
signing_key:
|
190
|
+
specification_version: 4
|
191
|
+
summary: Mozart Logging and Metrics
|
192
|
+
test_files: []
|