bbc-cosmos-logger 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +1 -0
- data/bbc-cosmos-logger.gemspec +27 -0
- data/lib/bbc/cosmos/logger.rb +50 -0
- data/lib/bbc/cosmos/logger/version.rb +7 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9eec35926fc0a0d39a1ca8b713fcc99654877a55
|
4
|
+
data.tar.gz: ff1350aaa51d9655a49d13b3b949fb7151d3884f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4b302a130bf343ed3a6a59eeb65a2453e77b10bdf5f40a616d998a381e3903b7cec7922b1cac395945c97397c1523fb70dba40b6f69a60f1fad659f7a3dfa939
|
7
|
+
data.tar.gz: adabf083314d284c3ea8900ac3f6ca35eae1a470cc450c0791def30171e740abab151efa69849f7c1bbdaede623a8627b2ff183ee42e3447cbe97db06f1598fb
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Robert Kenny
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# BBC::Cosmos::Logger
|
2
|
+
|
3
|
+
Logging helper gem for GELF & file logging on Cosmos
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'bbc-cosmos-logger'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install bbc-cosmos-logger
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
In your Ruby Cosmos Application:
|
22
|
+
|
23
|
+
```rb
|
24
|
+
require 'bbc/cosmos/logger'
|
25
|
+
|
26
|
+
ENV['APP_LOG_LOCATION'] = "/my/log/location.log"
|
27
|
+
ENV['LOG_MAX_BACKUPS'] = 5 # How many backups to keep
|
28
|
+
ENV['LOG_MAXTIME'] = 30 # Time in seconds to keep backups
|
29
|
+
|
30
|
+
ENV['GELF_SERVER'] = 'gelf.logger.com'
|
31
|
+
ENV['GELF_PORT'] = '12201'
|
32
|
+
|
33
|
+
logger = BBC::Cosmos::Logger.create('my_stack_id')
|
34
|
+
|
35
|
+
logger.warn "OMG ERRORZ" # Will log to your GELF server and to file
|
36
|
+
```
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it ( http://github.com/bbc-news/bbc-cosmos-logger/fork )
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bbc/cosmos/logger/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bbc-cosmos-logger"
|
8
|
+
spec.version = BBC::Cosmos::Logger::VERSION
|
9
|
+
spec.authors = ["Robert Kenny", "Steve Jack"]
|
10
|
+
spec.email = ["robert.kenny@bbc.co.uk","steve.jack01.ext@bbc.co.uk"]
|
11
|
+
spec.summary = "Ruby logging on Cosmos"
|
12
|
+
spec.description = "Logging helper gem for GELF & file logging"
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "log4r"
|
22
|
+
spec.add_runtime_dependency "log4r-gelf"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "bbc/cosmos/logger/version"
|
2
|
+
|
3
|
+
require 'log4r'
|
4
|
+
require 'log4r-gelf'
|
5
|
+
|
6
|
+
# Monkey Patch Log4r to allow us to use is as a Rack::CommonLogger
|
7
|
+
module Log4r
|
8
|
+
class Logger
|
9
|
+
def write(value); info(value) end
|
10
|
+
def <<(value); info(value) end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module BBC
|
15
|
+
module Cosmos
|
16
|
+
module Logger
|
17
|
+
class SimpleFormatter < Log4r::Formatter
|
18
|
+
def format(event)
|
19
|
+
"[#{Time.now}] #{event.name} #{Log4r::LNAMES[event.level]} #{event.data}\n"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
DEFAULT_LOG_LOCATION = 'debug.log'
|
24
|
+
DEFAULT_MAX_BACKUPS = 2
|
25
|
+
DEFAULT_MAXTIME = 600
|
26
|
+
DEFAULT_GELF_SERVER = 'localhost'
|
27
|
+
DEFAULT_GELF_PORT = '12201'
|
28
|
+
|
29
|
+
def self.create(id)
|
30
|
+
log = Log4r::Logger.new(id)
|
31
|
+
|
32
|
+
Log4r::RollingFileOutputter.new(
|
33
|
+
'logfile',
|
34
|
+
:formatter => SimpleFormatter,
|
35
|
+
:filename => ENV['APP_LOG_LOCATION'] || DEFAULT_LOG_LOCATION,
|
36
|
+
:max_backups => ENV['LOG_MAX_BACKUPS'] || DEFAULT_MAX_BACKUPS,
|
37
|
+
:maxtime => ENV['LOG_MAXTIME'] || DEFAULT_MAXTIME,
|
38
|
+
:trunc => true)
|
39
|
+
|
40
|
+
Log4r::GelfOutputter.new(
|
41
|
+
'gelfling',
|
42
|
+
:formatter => SimpleFormatter,
|
43
|
+
'gelf_server' => ENV['GELF_SERVER'],
|
44
|
+
'gelf_port' => ENV['GELF_PORT'])
|
45
|
+
|
46
|
+
log.tap {|l| l.add('logfile', 'gelfling') }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bbc-cosmos-logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Kenny
|
8
|
+
- Steve Jack
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: log4r
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
requirement: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - '>='
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
26
|
+
prerelease: false
|
27
|
+
type: :runtime
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: log4r-gelf
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
prerelease: false
|
41
|
+
type: :runtime
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.5'
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.5'
|
54
|
+
prerelease: false
|
55
|
+
type: :development
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
prerelease: false
|
69
|
+
type: :development
|
70
|
+
description: Logging helper gem for GELF & file logging
|
71
|
+
email:
|
72
|
+
- robert.kenny@bbc.co.uk
|
73
|
+
- steve.jack01.ext@bbc.co.uk
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- .gitignore
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bbc-cosmos-logger.gemspec
|
84
|
+
- lib/bbc/cosmos/logger.rb
|
85
|
+
- lib/bbc/cosmos/logger/version.rb
|
86
|
+
homepage: ''
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.1.9
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Ruby logging on Cosmos
|
110
|
+
test_files: []
|
111
|
+
has_rdoc:
|