syslog-ml-logger 1.7.3 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.rdoc +11 -2
  2. data/lib/syslog-ml-logger.rb +15 -2
  3. metadata +6 -6
@@ -17,17 +17,19 @@ will be ignored.
17
17
  This particular Logger::Syslog improves the original by correctly mapping Rails log severities to
18
18
  the Syslog counterparts. It also adds the ability to select a syslog facility other than "user."
19
19
 
20
+ Version 1.8.0 cuts lines longer then 1024 characters in multiple lines cause syslog cuts them off
21
+ Version 1.7.3 sends multiple lines to the syslog server instead of one large line which is cut of
20
22
  Version 1.6.7 takes a formatter as logger does and uses call to format the message.
21
23
 
22
24
  == SYNOPSIS:
23
25
 
24
26
  === config/environment.rb
25
27
 
26
- config.gem 'syslog-logger'
28
+ require 'syslog-ml-logger'
27
29
 
28
30
  === Gemfile
29
31
 
30
- gem 'syslog-logger'
32
+ gem 'syslog-ml-logger'
31
33
 
32
34
  === config/environments/production.rb
33
35
 
@@ -39,6 +41,10 @@ By default, Logger::Syslog uses the program name 'rails' and the facility 'user'
39
41
  changed via the arguments to Logger::Syslog.new:
40
42
 
41
43
  RAILS_DEFAULT_LOGGER = Logger::Syslog.new('mygreatapp', Syslog::LOG_LOCAL7)
44
+
45
+ Or use when using multiple environments with multiple projects
46
+
47
+ config.logger = Logger::Syslog.new(Rails.env + '-' + Rails.root.to_s.gsub(/\/[path-to-rails-apps]\/(.*)\/ruby/,'\1'), Syslog::LOG_LOCAL0)
42
48
 
43
49
  === BSD syslog setup
44
50
 
@@ -90,6 +96,9 @@ syslogd(8) manpage for further details.
90
96
 
91
97
  == LICENSE:
92
98
 
99
+ Extending below with:
100
+ Copyright (c) 2012, Daniel van den Oord
101
+
93
102
  Copyright (c) 2008, 2009 Eric Hodel, Christopher Powell, Ian Lesperance,
94
103
  Dana Contreras, Brian Smith, Ashley Martens
95
104
 
@@ -6,7 +6,10 @@ class Logger::Syslog
6
6
  include Logger::Severity
7
7
 
8
8
  # The version of Logger::Syslog you are using.
9
- VERSION = '1.7.3'
9
+ VERSION = '1.8.0'
10
+
11
+ # Max length of syslog string
12
+ MAXLENGTH = 1024
10
13
 
11
14
  # From 'man syslog.h':
12
15
  # LOG_EMERG A panic condition was reported to all processes.
@@ -120,7 +123,9 @@ class Logger::Syslog
120
123
 
121
124
  # breakup multiple lines into multiple syslog messages
122
125
  message.each_line do | msg |
123
- SYSLOG.send(LEVEL_LOGGER_MAP[severity], format_message(format_severity(severity), Time.now, progname, clean(msg.chop)))
126
+ cut(line).each do |msg|
127
+ SYSLOG.send(LEVEL_LOGGER_MAP[severity], format_message(format_severity(severity), Time.now, progname, clean(msg.chop)))
128
+ end
124
129
  end
125
130
  true
126
131
  end
@@ -162,4 +167,12 @@ class Logger::Syslog
162
167
  return message
163
168
  end
164
169
 
170
+ # Cut lines in strings having a max length of 1024
171
+ def cut(line)
172
+ msgs = []
173
+ (0..(line.length / MAXLENGTH)).each do |i|
174
+ msgs << line[i*MAXLENGTH, MAXLENGTH + 1]
175
+ end
176
+ return msgs
177
+ end
165
178
  end
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syslog-ml-logger
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 7
9
- - 3
10
- version: 1.7.3
8
+ - 8
9
+ - 0
10
+ version: 1.8.0
11
11
  platform: ruby
12
12
  authors:
13
- - Daniel van den Oord;Eric Hodel; Chris Powell; Matthew Boeh; Ian Lesperance; Dana Danger; Brian Smith; Ashley Martens
13
+ - Daniel van den Oord;Erwin Rohde,Eric Hodel; Chris Powell; Matthew Boeh; Ian Lesperance; Dana Danger; Brian Smith; Ashley Martens
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-10-19 00:00:00 Z
18
+ date: 2012-11-30 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: An improved Logger replacement that logs multiple-lines to syslog. It is almost drop-in with a few caveats.