zlog 0.6 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/CHANGELOG.md +6 -0
- data/README.md +6 -0
- data/example/example.file.rb +31 -0
- data/example/{example.rb → example.simple+stdout.rb} +0 -0
- data/lib/zlog/logging.rb +2 -2
- data/lib/zlog/simple_layouts.rb +8 -8
- data/lib/zlog/zlog.rb +9 -4
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09e454b71eb8ad7237defaeebfb4c5a04ed1e4c1
|
4
|
+
data.tar.gz: c634bc81b2f2242fa3511a8164712480edcf7661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 594b912a1186fab36e5b40f9c2b24f19528cdb4d6c7ab33fbb835cb9bb526542649e48994f838b24917268316e577d7867d93cf293b27c9901fc497ee3f892b2
|
7
|
+
data.tar.gz: 9675234eacea1b2939be8841818237ce67f8fefa5470d892e4b9a065325e20ded7687a89810b20cd93f747fdec198c5d2d5c8e11d9b27a60f979011b3bd2a367
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.7
|
2
|
+
|
3
|
+
* improvement: correctly ordered log levels (now: ... warn ok section error ...)
|
4
|
+
* bugfix: don't set root log level when initializing stdout logger; make sure logging to other appenders is not affected here
|
5
|
+
* bugfix: prevent duplicate entries of stdout appender + prevent removal of other appenders when initializing zlog stdout
|
6
|
+
|
1
7
|
## 0.6
|
2
8
|
|
3
9
|
* improvement: fixed versions of gem file dependencies
|
data/README.md
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require_relative '../lib/zlog'
|
3
|
+
|
4
|
+
FILENAME = 'example.file.log'
|
5
|
+
|
6
|
+
# configure logging to stdout, so we see what's going on
|
7
|
+
Zlog::init_stdout loglevel: :info
|
8
|
+
|
9
|
+
# configure file appender
|
10
|
+
Logging.appenders.rolling_file(
|
11
|
+
FILENAME,
|
12
|
+
age: 'daily',
|
13
|
+
layout: Logging.layouts.json,
|
14
|
+
loglevel: :debug
|
15
|
+
)
|
16
|
+
Logging.logger.root.add_appenders FILENAME
|
17
|
+
|
18
|
+
# add some log entries
|
19
|
+
log1 = Logging.logger['Log1-debug']
|
20
|
+
log2 = Logging.logger['Log2-info']
|
21
|
+
log3 = Logging.logger['Log3-warn++']
|
22
|
+
|
23
|
+
log1.debug "debugging info, this won't show up on console"
|
24
|
+
log2.info "writing some info"
|
25
|
+
log3.warn "warn me, we are getting close"
|
26
|
+
log3.error "error! nah, kidding"
|
27
|
+
log3.ok "finished with example"
|
28
|
+
|
29
|
+
# read back the file to stdout
|
30
|
+
puts "\n> cat #{FILENAME}"
|
31
|
+
puts File::read(FILENAME)
|
File without changes
|
data/lib/zlog/logging.rb
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
# http://stackoverflow.com/questions/2281490/how-to-add-a-custom-log-level-to-logger-in-ruby
|
3
3
|
module Logging
|
4
4
|
class Logger
|
5
|
-
def ok msg; add 5, msg end
|
6
|
-
def section msg; add 6, msg end
|
7
5
|
def abort msg, exit_code = 1
|
8
6
|
fatal msg
|
9
7
|
exit exit_code
|
@@ -15,3 +13,5 @@ module Logging
|
|
15
13
|
|
16
14
|
end
|
17
15
|
end
|
16
|
+
|
17
|
+
Logging.init :debug, :info, :warn, :ok, :section, :error, :fatal
|
data/lib/zlog/simple_layouts.rb
CHANGED
@@ -56,16 +56,16 @@ module Zlog::Layouts::SimpleCore
|
|
56
56
|
|
57
57
|
# standard order: ["DEBUG", "INFO", "WARN", "ERROR", "FATAL"]
|
58
58
|
|
59
|
-
LOGLEVEL2NAME = [:debug, :info, :warning, :
|
59
|
+
LOGLEVEL2NAME = [:debug, :info, :warning, :ok, :section, :error, :fatal]
|
60
60
|
|
61
61
|
STDOUT_PATTERN_NOCOLORS = {
|
62
62
|
:debug => ".. %s",
|
63
63
|
:info => "-- %s",
|
64
64
|
:warning => "ww %s",
|
65
|
-
:error => "ee %s",
|
66
|
-
:fatal => "ff %s",
|
67
65
|
:ok => "++ %s",
|
68
66
|
:section => "\n== %s",
|
67
|
+
:error => "ee %s",
|
68
|
+
:fatal => "ff %s",
|
69
69
|
:name => "%s: "
|
70
70
|
}
|
71
71
|
|
@@ -73,10 +73,10 @@ module Zlog::Layouts::SimpleCore
|
|
73
73
|
:debug => "\033[37m.. %s\033[0m",
|
74
74
|
:info => "\033[0m-- %s\033[0m",
|
75
75
|
:warning => "\033[1;33mww %s\033[0m",
|
76
|
-
:error => "\033[1;31mee %s\033[0m",
|
77
|
-
:fatal => "\033[1;41mff\033[0m\033[1;31 %s\033[0m",
|
78
76
|
:ok => "\033[1;32m++ %s\033[0m",
|
79
77
|
:section => "\n\033[1;34m== %s\033[0m",
|
78
|
+
:error => "\033[1;31mee %s\033[0m",
|
79
|
+
:fatal => "\033[1;41mff\033[0m\033[1;31 %s\033[0m",
|
80
80
|
:name => "\033[37m%s: "
|
81
81
|
}
|
82
82
|
|
@@ -84,10 +84,10 @@ module Zlog::Layouts::SimpleCore
|
|
84
84
|
:debug => "\033[38;5;246m.. %s\033[0m",
|
85
85
|
:info => "\033[38;5;255m-- %s\033[0m",
|
86
86
|
:warning => "\033[38;5;226mww %s\033[0m",
|
87
|
-
:error => "\033[38;5;196mee %s\033[0m",
|
88
|
-
:fatal => "\033[48;5;196mff\033[0m\033[38;5;196m %s\033[0m",
|
89
87
|
:ok => "\033[38;5;46m++ %s\033[0m",
|
90
88
|
:section => "\n\033[38;5;33m== %s\033[0m",
|
89
|
+
:error => "\033[38;5;196mee %s\033[0m",
|
90
|
+
:fatal => "\033[48;5;196mff\033[0m\033[38;5;196m %s\033[0m",
|
91
91
|
:name => "\033[38;5;246m%s: "
|
92
92
|
}
|
93
93
|
end
|
@@ -119,4 +119,4 @@ module Zlog::Layouts
|
|
119
119
|
format_simple event, true
|
120
120
|
end
|
121
121
|
end
|
122
|
-
end
|
122
|
+
end
|
data/lib/zlog/zlog.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
module Zlog
|
2
|
-
VERSION = "0.
|
2
|
+
VERSION = "0.7"
|
3
3
|
|
4
4
|
def self.init_stdout opts = {named: false, loglevel: nil}
|
5
|
-
|
5
|
+
# configure the default stdout appender
|
6
|
+
Logging.appenders.stdout(
|
6
7
|
level: opts[:loglevel],
|
7
8
|
layout: (opts[:named]) ? Zlog::Layouts.named : Zlog::Layouts.simple
|
8
|
-
|
9
|
-
|
9
|
+
)
|
10
|
+
# find all non-stdout appenders
|
11
|
+
# this prevents duplicates of stdout appender
|
12
|
+
as = Logging.logger.root.appenders.find_all{|i| i.name != "stdout" }
|
13
|
+
# add back all appenders + our own stdout appender
|
14
|
+
Logging.logger.root.appenders = as + ["stdout"]
|
10
15
|
end
|
11
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.7'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Richter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -37,8 +37,9 @@ files:
|
|
37
37
|
- LICENSE
|
38
38
|
- README.md
|
39
39
|
- Rakefile
|
40
|
+
- example/example.file.rb
|
40
41
|
- example/example.output.png
|
41
|
-
- example/example.rb
|
42
|
+
- example/example.simple+stdout.rb
|
42
43
|
- lib/zlog.rb
|
43
44
|
- lib/zlog/layouts.rb
|
44
45
|
- lib/zlog/logging.rb
|