logging-remote-syslog 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -0
- data/lib/logging/VERSION +1 -1
- data/lib/logging/appenders/remote-syslog.rb +10 -1
- data/spec/logging/appenders/remote_syslog_spec.rb +10 -0
- metadata +15 -12
data/README.md
CHANGED
@@ -19,6 +19,12 @@ Or install it yourself as:
|
|
19
19
|
$ gem install logging-remote-syslog
|
20
20
|
```
|
21
21
|
|
22
|
+
## Options
|
23
|
+
:ident - [String] The identity of the sender
|
24
|
+
:syslog_server [String] - The syslog server
|
25
|
+
:strip_colors [True|False] - Some loggers like shell colors, should we remove them?
|
26
|
+
:facility [String] - Something like local6
|
27
|
+
|
22
28
|
## Usage
|
23
29
|
|
24
30
|
```
|
@@ -41,6 +47,9 @@ logger.info 'MyApp Message'
|
|
41
47
|
rake
|
42
48
|
```
|
43
49
|
|
50
|
+
## Change Log
|
51
|
+
0.0.3 - Strip ANSI shell codes by default
|
52
|
+
|
44
53
|
## Contributing
|
45
54
|
|
46
55
|
1. Fork it
|
data/lib/logging/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -79,6 +79,8 @@ module Logging::Appenders
|
|
79
79
|
@syslog_server = opts.getopt(:syslog_server, '127.0.0.1')
|
80
80
|
@port = opts.getopt(:port, 514, :as => Integer)
|
81
81
|
|
82
|
+
@strip_colors = opts.getopt(:strip_colors, true)
|
83
|
+
|
82
84
|
facility_name = opts.getopt(:facility, 'user')
|
83
85
|
|
84
86
|
@facility = ::SyslogProtocol::FACILITIES[facility_name]
|
@@ -116,6 +118,13 @@ module Logging::Appenders
|
|
116
118
|
@map = map
|
117
119
|
end
|
118
120
|
|
121
|
+
def strip_ansi_colors(message)
|
122
|
+
message.gsub /\\e\[?.*?[\@-~]/, ''
|
123
|
+
end
|
124
|
+
|
125
|
+
def prepare_message(message)
|
126
|
+
@strip_colors ? strip_ansi_colors(message) : message
|
127
|
+
end
|
119
128
|
|
120
129
|
private
|
121
130
|
|
@@ -144,7 +153,7 @@ module Logging::Appenders
|
|
144
153
|
:program => @ident
|
145
154
|
)
|
146
155
|
|
147
|
-
udp_sender.write(message)
|
156
|
+
udp_sender.write(prepare_message(message))
|
148
157
|
|
149
158
|
self
|
150
159
|
end
|
@@ -55,4 +55,14 @@ describe Logging::Appenders::RemoteSyslog do
|
|
55
55
|
logger.level = level
|
56
56
|
logger.info("Test Message").should == true
|
57
57
|
end
|
58
|
+
|
59
|
+
it 'strips shell codes by default' do
|
60
|
+
appender = Logging.appenders.remote_syslog('Test', :syslog_server => '127.0.0.1', :facility => SyslogProtocol::FACILITIES['local6'])
|
61
|
+
appender.prepare_message('\e[KTest Message\e[0m').should == 'Test Message'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should not strip shell code if asked' do
|
65
|
+
appender = Logging.appenders.remote_syslog('Test', :syslog_server => '127.0.0.1', :facility => SyslogProtocol::FACILITIES['local6'], :strip_colors => false)
|
66
|
+
appender.prepare_message('\e[KTest Message\e[0m').should == '\e[KTest Message\e[0m'
|
67
|
+
end
|
58
68
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logging-remote-syslog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: logging
|
@@ -128,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
segments:
|
130
130
|
- 0
|
131
|
-
hash:
|
131
|
+
hash: 561701682782871936
|
132
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
133
|
none: false
|
134
134
|
requirements:
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
segments:
|
139
139
|
- 0
|
140
|
-
hash:
|
140
|
+
hash: 561701682782871936
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
143
|
rubygems_version: 1.8.24
|
@@ -147,14 +147,17 @@ summary: ! '# logging/remote-syslog logging/remote-syslog is a remote syslog ap
|
|
147
147
|
for use with the Logging library. ![Travis CI Status](https://secure.travis-ci.org/BIAINC/logging-remote-syslog.png) ##
|
148
148
|
Installation Add this line to your application''s Gemfile: ``` gem ''logging-remote-syslog'',
|
149
149
|
:require => ''logging/remote-syslog'' ``` And then execute: ``` $ bundle ``` Or
|
150
|
-
install it yourself as: ``` $ gem install logging-remote-syslog ``` ##
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
150
|
+
install it yourself as: ``` $ gem install logging-remote-syslog ``` ## Options
|
151
|
+
:ident - [String] The identity of the sender :syslog_server [String] - The syslog
|
152
|
+
server :strip_colors [True|False] - Some loggers like shell colors, should we remove
|
153
|
+
them? :facility [String] - Something like local6 ## Usage ``` require ''logging''
|
154
|
+
require ''logging/remote-syslog'' logger = Logging.logger[''MyApp''] logger.add_appenders(
|
155
|
+
Logging.appenders.remote_syslog(ident, syslog_server: syslog_host, port: syslog_port)
|
156
|
+
) logger.level = :info logger.info ''MyApp Message'' ``` ## Tests ``` rake ``` ##
|
157
|
+
Change Log 0.0.3 - Strip ANSI shell codes by default ## Contributing 1. Fork it
|
158
|
+
2. Create your feature branch (`git checkout -b my-new-feature`) 3. Write code and
|
159
|
+
add _tests_ 4. Commit your changes (`git commit -am ''Added some feature''`) 5.
|
160
|
+
Push to the branch (`git push origin my-new-feature`) 6. Create new Pull Request'
|
158
161
|
test_files:
|
159
162
|
- spec/logging/appenders/remote_syslog_spec.rb
|
160
163
|
- spec/spec_helper.rb
|