common_event_formatter 0.1.0
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.
- data/README.md +19 -0
- data/lib/common_event_formatter.rb +23 -0
- metadata +63 -0
data/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# CEE/Lumberjack log formatter for Ruby/Rails
|
|
2
|
+
|
|
3
|
+
Treat your logs as the event stream they are.
|
|
4
|
+
|
|
5
|
+
## Rails Example Config
|
|
6
|
+
|
|
7
|
+
Gemfile
|
|
8
|
+
|
|
9
|
+
gem "common_event_formatter"
|
|
10
|
+
|
|
11
|
+
config/application.rb
|
|
12
|
+
|
|
13
|
+
config.logger = Logger.new($stdout)
|
|
14
|
+
config.logger.formatter = CommonEventFormatter.new
|
|
15
|
+
|
|
16
|
+
config/unicorn.rb (for those using unicorn)
|
|
17
|
+
|
|
18
|
+
require "common_event_formatter"
|
|
19
|
+
Configurator::DEFAULTS[:logger].formatter = CommonEventFormatter.new
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "logger"
|
|
2
|
+
require "json"
|
|
3
|
+
|
|
4
|
+
class CommonEventFormatter < Logger::Formatter
|
|
5
|
+
VERSION = "0.1.0"
|
|
6
|
+
|
|
7
|
+
def call(severity, time, progname, msg)
|
|
8
|
+
create_event({:level => severity, :time => time, :app => pwd, :pname => (progname || $0), :msg => msg2str(msg)})
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def create_event(hash)
|
|
12
|
+
hash.merge(process_hash).to_json + "\n"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
def pwd
|
|
17
|
+
Dir.pwd.split('/').last
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def process_hash
|
|
21
|
+
{:pid => Process.pid, :ppid => Process.ppid, :uid => Process.uid, :gid => Process.gid}
|
|
22
|
+
end
|
|
23
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: common_event_formatter
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Daniel Farrell
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-01-12 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: json
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0'
|
|
30
|
+
description: Format logs in the CEE/lumberjack structured format
|
|
31
|
+
email: danielfarrell76@gmail.com
|
|
32
|
+
executables: []
|
|
33
|
+
extensions: []
|
|
34
|
+
extra_rdoc_files: []
|
|
35
|
+
files:
|
|
36
|
+
- lib/common_event_formatter.rb
|
|
37
|
+
- README.md
|
|
38
|
+
homepage: http://github.com/danielfarrell/common_event_formatter
|
|
39
|
+
licenses: []
|
|
40
|
+
post_install_message:
|
|
41
|
+
rdoc_options: []
|
|
42
|
+
require_paths:
|
|
43
|
+
- lib
|
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
|
+
none: false
|
|
46
|
+
requirements:
|
|
47
|
+
- - ! '>='
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
|
+
none: false
|
|
52
|
+
requirements:
|
|
53
|
+
- - ! '>='
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
56
|
+
requirements: []
|
|
57
|
+
rubyforge_project:
|
|
58
|
+
rubygems_version: 1.8.23
|
|
59
|
+
signing_key:
|
|
60
|
+
specification_version: 3
|
|
61
|
+
summary: Format logs in the CEE/lumberjack structured format
|
|
62
|
+
test_files: []
|
|
63
|
+
has_rdoc:
|