simplesyslogger 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/lib/simplesyslogger/version.rb +1 -1
- data/lib/simplesyslogger.rb +9 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbb957b034d37818b2631c18b54bbc44cd8876c6
|
4
|
+
data.tar.gz: c49f9a46a03c18a992a982ca2e822cca2e52c87e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b7882dc7673895398dacc39f7d189582c951d87e534be9634d9d773f63ce5f2df46dfce48f45c7ad5741e135c5c8b33a4c49937656307ee41ed007b65eaf429
|
7
|
+
data.tar.gz: 21c1b2c5b2ffab0a61ba5a6976736f9d7581d9dc47cefd1d251f17b66bb1a4686aba8ab693fbdfa66ba692c7116de61d31e847dfa6000d2b61eed23aded73a6c
|
data/README.md
CHANGED
@@ -21,8 +21,11 @@ Or install it yourself as:
|
|
21
21
|
Example usage in sinatra:
|
22
22
|
|
23
23
|
configure do
|
24
|
-
log = SimpleSysLogger::
|
25
|
-
|
24
|
+
log = SimpleSysLogger::SysLogger.new({
|
25
|
+
:ident => "MY_COOL_APPNAME",
|
26
|
+
:level => Logger::DEBUG #TODO:// # logging level - i.e. send messages that are at least of the Logger::INFO level - not fully implemented yet
|
27
|
+
})
|
28
|
+
|
26
29
|
log.level = ENV['RACK_ENV'] == 'production' ? Logger::INFO : Logger::DEBUG
|
27
30
|
end
|
28
31
|
|
data/lib/simplesyslogger.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'syslog'
|
1
3
|
require "simplesyslogger/version"
|
2
4
|
|
3
5
|
module SimpleSysLogger
|
4
6
|
|
5
|
-
class
|
7
|
+
class SysLogger
|
6
8
|
|
7
9
|
attr_reader :level, :ident, :options, :facility
|
8
10
|
|
@@ -15,13 +17,11 @@ module SimpleSysLogger
|
|
15
17
|
Logger::UNKNOWN => "alert"
|
16
18
|
}
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@level = Logger::INFO
|
24
|
-
@facility = @facility
|
20
|
+
def initialize(opts = {})
|
21
|
+
@ident = opts[:ident] || $0
|
22
|
+
@options = opts[:options] || (Syslog::LOG_PID | Syslog::LOG_CONS)
|
23
|
+
@level = opts[:level]|| Logger::INFO
|
24
|
+
@facility = opts[:facility] || Syslog::LOG_LOCAL0
|
25
25
|
end
|
26
26
|
|
27
27
|
|
@@ -58,7 +58,7 @@ module SimpleSysLogger
|
|
58
58
|
# +progname+:: optionally, overwrite the program name that appears in the log message.
|
59
59
|
def add(severity, message = nil, progname = nil, &block)
|
60
60
|
formatted_communication = "=====> #{MAPPING[severity]} :::: #{message}"
|
61
|
-
Syslog.open(progname || @ident,
|
61
|
+
Syslog.open(progname || @ident, @options) { |s|
|
62
62
|
puts "#{MAPPING[severity]} ..... logger:::: #{formatted_communication}"
|
63
63
|
#s.warning "logger:::: #{formatted_communication}"
|
64
64
|
s.send("#{MAPPING[severity]}".to_sym, formatted_communication)
|