yell 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/examples/001-basic-usage.rb +24 -0
- data/examples/002.1-log-level-basics.rb +25 -0
- data/examples/002.2-log-level-on-certain-severities-only.rb +28 -0
- data/examples/002.3-log-level-within-range.rb +28 -0
- data/examples/003.1-formatting-DefaultFormat.rb +22 -0
- data/examples/003.2-formatting-BasicFormat.rb +22 -0
- data/examples/003.3-formatting-ExtendedFormat.rb +21 -0
- data/examples/003.4-formatting-on-your-own.rb +21 -0
- data/lib/yell.rb +0 -1
- data/lib/yell/event.rb +1 -1
- data/lib/yell/formatter.rb +8 -2
- data/lib/yell/level.rb +1 -1
- data/lib/yell/version.rb +1 -1
- metadata +9 -1
data/README.md
CHANGED
@@ -36,14 +36,14 @@ Alternatively, you may define `ENV['YELL_ENV']` to set the filename. If neither
|
|
36
36
|
`log` directory exists, Yell will place the file there (only if you have not passed
|
37
37
|
a filename explicitly.
|
38
38
|
|
39
|
-
Naturally,
|
39
|
+
Naturally, you can pass a `:filename` to Yell:
|
40
40
|
|
41
41
|
```ruby
|
42
42
|
logger = Yell.new 'yell.log'
|
43
43
|
```
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
To learn about how to use [log levels](https://github.com/rudionrails/yell/wiki/101-setting-the-log-level), [log formatting](https://github.com/rudionrails/yell/wiki/101-formatting-log-messages), or different [adapters](https://github.com/rudionrails/yell/wiki/101-using-adapters) see the [wiki](https://github.com/rudionrails/yell/wiki) or have a look into the examples folder.
|
46
|
+
|
47
47
|
|
48
48
|
Copyright © 2011-2012 Rudolf Schmidt, released under the MIT license
|
49
49
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../lib/yell'
|
4
|
+
|
5
|
+
puts <<-EOS
|
6
|
+
|
7
|
+
# On the basics, Yell works just like any other logging library.
|
8
|
+
#
|
9
|
+
# However, it enriches your log messages to make it more readable. By default,
|
10
|
+
# it will format the given message as follows:
|
11
|
+
|
12
|
+
logger = Yell.new STDOUT
|
13
|
+
logger.info "Hello World!"
|
14
|
+
|
15
|
+
#=> "2012-02-29T09:30:00+01:00 [ INFO] 65784 : Hello World!"
|
16
|
+
# ^ ^ ^ ^
|
17
|
+
# ISO8601 Timestamp Level Pid Message
|
18
|
+
|
19
|
+
|
20
|
+
EOS
|
21
|
+
|
22
|
+
puts "=== actual example ==="
|
23
|
+
logger = Yell.new STDOUT
|
24
|
+
logger.info "Hello World!"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../lib/yell'
|
4
|
+
|
5
|
+
puts <<-EOS
|
6
|
+
|
7
|
+
# Like many other logging libraries, Yell allows you to define from which level
|
8
|
+
# onwards you want to write your log message.
|
9
|
+
|
10
|
+
logger = Yell.new STDOUT, :level => :info
|
11
|
+
|
12
|
+
logger.debug "This is a :debug message"
|
13
|
+
#=> nil
|
14
|
+
|
15
|
+
logger.info "This is a :info message"
|
16
|
+
#=> "2012-02-29T09:30:00+01:00 [ INFO] 65784 : This is a :info message"
|
17
|
+
|
18
|
+
|
19
|
+
EOS
|
20
|
+
|
21
|
+
puts "=== actual example ==="
|
22
|
+
logger = Yell.new STDOUT, :level => :info
|
23
|
+
|
24
|
+
logger.debug "This is a :debug message"
|
25
|
+
logger.info "This is a :info message"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../lib/yell'
|
4
|
+
|
5
|
+
puts <<-EOS
|
6
|
+
|
7
|
+
# The Yell::Level parser allows you to exactly specify on which levels to log,
|
8
|
+
# ignoring all the others. For instance: If we want to only log at the :debug
|
9
|
+
# and :warn levels we simply providing an array:
|
10
|
+
|
11
|
+
logger = Yell.new STDOUT, :level => [:debug, :warn]
|
12
|
+
|
13
|
+
[:debug, :info, :warn, :error, :fatal].each do |level|
|
14
|
+
logger.send( level, level )
|
15
|
+
end
|
16
|
+
#=> "2012-02-29T09:30:00+01:00 [DEBUG] 65784 : debug"
|
17
|
+
#=> "2012-02-29T09:30:00+01:00 [ WARN] 65784 : warn"
|
18
|
+
|
19
|
+
|
20
|
+
EOS
|
21
|
+
|
22
|
+
puts "=== actual example ==="
|
23
|
+
logger = Yell.new STDOUT, :level => [:debug, :warn]
|
24
|
+
|
25
|
+
[:debug, :info, :warn, :error, :fatal].each do |level|
|
26
|
+
logger.send( level, level )
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../lib/yell'
|
4
|
+
|
5
|
+
puts <<-EOS
|
6
|
+
|
7
|
+
# Additionally to writing only on specific levels, you may pass a range to
|
8
|
+
# the :level option:
|
9
|
+
|
10
|
+
logger = Yell.new STDOUT, :level => (:debug..:warn)
|
11
|
+
|
12
|
+
[:debug, :info, :warn, :error, :fatal].each do |level|
|
13
|
+
logger.send( level, level )
|
14
|
+
end
|
15
|
+
#=> "2012-02-29T09:30:00+01:00 [DEBUG] 65784 : debug"
|
16
|
+
#=> "2012-02-29T09:30:00+01:00 [ INFO] 65784 : info"
|
17
|
+
#=> "2012-02-29T09:30:00+01:00 [ WARN] 65784 : warn"
|
18
|
+
|
19
|
+
|
20
|
+
EOS
|
21
|
+
|
22
|
+
puts "=== actuale example ==="
|
23
|
+
logger = Yell.new STDOUT, :level => (:debug..:warn)
|
24
|
+
|
25
|
+
[:debug, :info, :warn, :error, :fatal].each do |level|
|
26
|
+
logger.send( level, level )
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../lib/yell'
|
4
|
+
|
5
|
+
puts <<-EOS
|
6
|
+
|
7
|
+
# The default formatting string looks like: %d [%5L] %p : %m and is used when
|
8
|
+
# nothing else is defined.
|
9
|
+
|
10
|
+
logger = Yell.new STDOUT, :format => Yell::DefaultFormat
|
11
|
+
logger.info "Hello World!"
|
12
|
+
#=> "2012-02-29T09:30:00+01:00 [ INFO] 65784 : Hello World!"
|
13
|
+
# ^ ^ ^ ^
|
14
|
+
# ISO8601 Timestamp Level Pid Message
|
15
|
+
|
16
|
+
|
17
|
+
EOS
|
18
|
+
|
19
|
+
puts "=== actuale example ==="
|
20
|
+
logger = Yell.new STDOUT, :format => Yell::DefaultFormat
|
21
|
+
logger.info "Hello World!"
|
22
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../lib/yell'
|
4
|
+
|
5
|
+
puts <<-EOS
|
6
|
+
|
7
|
+
# The basic formating string looks like: %l, %d: %m.
|
8
|
+
|
9
|
+
logger = Yell.new STDOUT, :format => Yell::BasicFormat
|
10
|
+
logger.info "Hello World!"
|
11
|
+
#=> "I, 2012-02-29T09:30:00+01:00 : Hello World!"
|
12
|
+
# ^ ^ ^
|
13
|
+
# ^ ISO8601 Timestamp Message
|
14
|
+
# Level (short)
|
15
|
+
|
16
|
+
|
17
|
+
EOS
|
18
|
+
|
19
|
+
puts "=== actuale example ==="
|
20
|
+
logger = Yell.new STDOUT, :format => Yell::BasicFormat
|
21
|
+
logger.info "Hello World!"
|
22
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../lib/yell'
|
4
|
+
|
5
|
+
puts <<-EOS
|
6
|
+
|
7
|
+
# The extended formatting string looks like: %d [%5L] %p %h : %m.
|
8
|
+
|
9
|
+
logger = Yell.new STDOUT, :format => Yell::ExtendedFormat
|
10
|
+
logger.info "Hello World!"
|
11
|
+
#=> "2012-02-29T09:30:00+01:00 [ INFO] 65784 localhost : Hello World!"
|
12
|
+
# ^ ^ ^ ^ ^
|
13
|
+
# ISO8601 Timestamp Level Pid Hostname Message
|
14
|
+
|
15
|
+
|
16
|
+
EOS
|
17
|
+
|
18
|
+
puts "=== actuale example ==="
|
19
|
+
logger = Yell.new STDOUT, :format => Yell::ExtendedFormat
|
20
|
+
logger.info "Hello World!"
|
21
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../lib/yell'
|
4
|
+
|
5
|
+
puts <<-EOS
|
6
|
+
|
7
|
+
The extended formatting string looks like: %d [%5L] %p %h : %m.
|
8
|
+
|
9
|
+
logger = Yell.new STDOUT, :format => "[%f:%n in `%M'] %m"
|
10
|
+
logger.info "Hello World!"
|
11
|
+
#=> [003.4-formatting-on-your-own.rb:20 in `<main>'] Hello World!
|
12
|
+
# ^ ^ ^ ^
|
13
|
+
# filename line method message
|
14
|
+
|
15
|
+
|
16
|
+
EOS
|
17
|
+
|
18
|
+
puts "=== actuale example ==="
|
19
|
+
logger = Yell.new STDOUT, :format => "[%f:%n in `%M'] %m"
|
20
|
+
logger.info "Hello World!"
|
21
|
+
|
data/lib/yell.rb
CHANGED
data/lib/yell/event.rb
CHANGED
data/lib/yell/formatter.rb
CHANGED
@@ -42,7 +42,7 @@ module Yell #:nodoc:
|
|
42
42
|
ExtendedFormat = "%d [%5L] %p %h : %m"
|
43
43
|
|
44
44
|
|
45
|
-
def format( pattern, date_pattern )
|
45
|
+
def self.format( pattern, date_pattern )
|
46
46
|
Yell::Formatter.new( pattern, date_pattern )
|
47
47
|
end
|
48
48
|
|
@@ -57,7 +57,7 @@ module Yell #:nodoc:
|
|
57
57
|
"L" => "event.level", # Level, e.g. 'INFO', 'WARN'
|
58
58
|
"d" => "date(event)", # ISO8601 Timestamp
|
59
59
|
"p" => "Process.pid", # PID
|
60
|
-
"h" => "
|
60
|
+
"h" => "hostname", # Hostname
|
61
61
|
"F" => "event.file", # Path with filename where the logger was called
|
62
62
|
"f" => "File.basename(event.file)", # Filename where the loger was called
|
63
63
|
"M" => "event.method", # Method name where the logger was called
|
@@ -105,6 +105,12 @@ module Yell #:nodoc:
|
|
105
105
|
@date_pattern ? event.time.strftime( @date_pattern ) : event.time.iso8601
|
106
106
|
end
|
107
107
|
|
108
|
+
def hostname
|
109
|
+
require 'socket' unless defined? Socket
|
110
|
+
|
111
|
+
Socket.gethostname rescue nil
|
112
|
+
end
|
113
|
+
|
108
114
|
end
|
109
115
|
end
|
110
116
|
|
data/lib/yell/level.rb
CHANGED
data/lib/yell/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -23,6 +23,14 @@ files:
|
|
23
23
|
- LICENSE.txt
|
24
24
|
- README.md
|
25
25
|
- Rakefile
|
26
|
+
- examples/001-basic-usage.rb
|
27
|
+
- examples/002.1-log-level-basics.rb
|
28
|
+
- examples/002.2-log-level-on-certain-severities-only.rb
|
29
|
+
- examples/002.3-log-level-within-range.rb
|
30
|
+
- examples/003.1-formatting-DefaultFormat.rb
|
31
|
+
- examples/003.2-formatting-BasicFormat.rb
|
32
|
+
- examples/003.3-formatting-ExtendedFormat.rb
|
33
|
+
- examples/003.4-formatting-on-your-own.rb
|
26
34
|
- lib/yell.rb
|
27
35
|
- lib/yell/adapters.rb
|
28
36
|
- lib/yell/adapters/.file.rb.swp
|