td-logger 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -0
- data/lib/td/logger/agent/access_log.rb +6 -3
- data/lib/td/logger/agent/rails.rb +20 -4
- data/lib/td/logger/version.rb +1 -1
- metadata +4 -4
data/ChangeLog
CHANGED
@@ -18,13 +18,16 @@ module Agent
|
|
18
18
|
end
|
19
19
|
|
20
20
|
ACCESS_LOG_PRESET_PARAM_KEYS = {
|
21
|
-
'controller' =>
|
22
|
-
'action' =>
|
21
|
+
'controller' => :controller,
|
22
|
+
'action' => :action,
|
23
23
|
}
|
24
24
|
|
25
25
|
ACCESS_LOG_PRESET_ENV_KEYS = {
|
26
|
-
'
|
26
|
+
'ip' => 'REMOTE_ADDR',
|
27
|
+
'method' => 'REQUEST_METHOD',
|
28
|
+
'uri' => 'REQUEST_URI',
|
27
29
|
'referer' => 'HTTP_REFERER',
|
30
|
+
'ua' => 'HTTP_USER_AGENT'
|
28
31
|
}
|
29
32
|
|
30
33
|
def self.enable_access_log(tag)
|
@@ -28,6 +28,22 @@ production:
|
|
28
28
|
test:
|
29
29
|
EOF
|
30
30
|
|
31
|
+
def self.rails_env
|
32
|
+
if defined?(RAILS_ENV) && RAILS_ENV.to_s != ''
|
33
|
+
RAILS_ENV.to_s
|
34
|
+
else
|
35
|
+
::Rails.env
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.rails_root
|
40
|
+
if defined?(RAILS_ROOT) && RAILS_ROOT.to_s != ''
|
41
|
+
RAILS_ROOT.to_s
|
42
|
+
else
|
43
|
+
::Rails.root
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
31
47
|
class Config
|
32
48
|
def initialize(conf)
|
33
49
|
if agent = conf['agent']
|
@@ -69,18 +85,18 @@ EOF
|
|
69
85
|
def self.read_config(rails)
|
70
86
|
logger = ::Rails.logger || ::Logger.new(STDOUT)
|
71
87
|
begin
|
72
|
-
yaml = YAML.load_file("#{
|
88
|
+
yaml = YAML.load_file("#{rails_root}/#{CONFIG_PATH}")
|
73
89
|
rescue
|
74
90
|
logger.warn "Can't load #{CONFIG_PATH} file."
|
75
91
|
logger.warn " #{$!}"
|
76
92
|
logger.warn "Put the following file:"
|
77
|
-
logger.warn
|
93
|
+
logger.warn CONFIG_SAMPLE
|
78
94
|
return
|
79
95
|
end
|
80
96
|
|
81
|
-
conf = yaml[
|
97
|
+
conf = yaml[rails_env]
|
82
98
|
unless conf
|
83
|
-
logger.warn "#{CONFIG_PATH} doesn't include setting for current environment (#{
|
99
|
+
logger.warn "#{CONFIG_PATH} doesn't include setting for current environment (#{rails_env})."
|
84
100
|
logger.warn "Disabling Treasure Data logger."
|
85
101
|
return
|
86
102
|
end
|
data/lib/td/logger/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: td-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sadayuki Furuhashi
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-03 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|