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 CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ == 2011-09-03 version 0.2.1
3
+
4
+ * Logs HTTP method, URI and UA by default in access log.
5
+ * Fixes Rails 3.1 compatibility
6
+
7
+
2
8
  == 2011-08-28 version 0.2.0
3
9
 
4
10
  * Rewritten
@@ -18,13 +18,16 @@ module Agent
18
18
  end
19
19
 
20
20
  ACCESS_LOG_PRESET_PARAM_KEYS = {
21
- 'controller' => 'controller',
22
- 'action' => 'action',
21
+ 'controller' => :controller,
22
+ 'action' => :action,
23
23
  }
24
24
 
25
25
  ACCESS_LOG_PRESET_ENV_KEYS = {
26
- 'remote_addr' => 'REMOTE_ADDR',
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("#{RAILS_ROOT}/#{CONFIG_PATH}")
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 sample
93
+ logger.warn CONFIG_SAMPLE
78
94
  return
79
95
  end
80
96
 
81
- conf = yaml[RAILS_ENV]
97
+ conf = yaml[rails_env]
82
98
  unless conf
83
- logger.warn "#{CONFIG_PATH} doesn't include setting for current environment (#{RAILS_ENV})."
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
@@ -1,7 +1,7 @@
1
1
  module TreasureData
2
2
  module Logger
3
3
 
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
 
6
6
  end
7
7
  end
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
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-08-28 00:00:00 +09:00
18
+ date: 2011-09-03 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency