yell 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -88,10 +88,10 @@ there.
88
88
 
89
89
  The standard adapters are:
90
90
 
91
- **:stdout** or **STDOUT**: Messages will be written to STDOUT
92
- **:stderr** or **STDERR**: Messages will be written to STDERR
93
- **:file**: Messages will be written to a file
94
- **:datefile**: Messages will be written to a timestamped file
91
+ `:stdout` : Messages will be written to STDOUT
92
+ `:stderr` : Messages will be written to STDERR
93
+ `:file` : Messages will be written to a file
94
+ `:datefile` : Messages will be written to a timestamped file
95
95
 
96
96
 
97
97
  Here are some short examples on how to combine them:
data/lib/yell.rb CHANGED
@@ -49,6 +49,15 @@ module Yell #:nodoc:
49
49
  Yell::Logger.new( *args, &block )
50
50
  end
51
51
 
52
+ def level( val = nil )
53
+ Yell::Level.new( val )
54
+ end
55
+
56
+ def format( pattern, date_pattern = nil )
57
+ Yell::Formatter.new( pattern, date_pattern )
58
+ end
59
+
60
+
52
61
  def env #:nodoc:
53
62
  ENV['YELL_ENV'] || ENV['RACK_ENV'] || 'development'
54
63
  end
@@ -1,5 +1,7 @@
1
- module Yell
2
- module Adapters
1
+ # encoding: utf-8
2
+
3
+ module Yell #:nodoc:
4
+ module Adapters #:nodoc:
3
5
 
4
6
  class Io < Yell::Adapters::Base
5
7
 
data/lib/yell/event.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Yell #:nodoc:
2
4
 
3
5
  class Event
@@ -27,15 +29,18 @@ module Yell #:nodoc:
27
29
  # Accessor to the pid
28
30
  attr_reader :pid
29
31
 
32
+ # Accessor to the current tread_id
33
+ attr_reader :thread_id
34
+
30
35
 
31
- # Initialize a new log event
32
36
  def initialize( level, message = nil, &block )
33
37
  @time = Time.now
34
38
  @level = level
35
39
  @message = block ? block.call : message
36
40
 
37
- @hostname = Socket.gethostname rescue nil
38
- @pid = Process.pid
41
+ @hostname = Socket.gethostname rescue nil
42
+ @pid = Process.pid
43
+ @thread_id = Thread.current.object_id
39
44
 
40
45
  _initialize_caller
41
46
  end
@@ -42,11 +42,6 @@ module Yell #:nodoc:
42
42
  ExtendedFormat = "%d [%5L] %p %h : %m"
43
43
 
44
44
 
45
- def self.format( pattern, date_pattern = nil )
46
- Yell::Formatter.new( pattern, date_pattern )
47
- end
48
-
49
-
50
45
  # The +Formatter+ provides a handle to configure your log message style.
51
46
  class Formatter
52
47
 
@@ -55,15 +50,16 @@ module Yell #:nodoc:
55
50
  "l" => "event.level[0,1]", # Level (short), e.g.'I', 'W'
56
51
  "L" => "event.level", # Level, e.g. 'INFO', 'WARN'
57
52
  "d" => "date(event)", # ISO8601 Timestamp
58
- "p" => "event.pid", # PID
59
53
  "h" => "event.hostname", # Hostname
54
+ "p" => "event.pid", # PID
55
+ "t" => "event.thread_id", # Thread ID
60
56
  "F" => "event.file", # Path with filename where the logger was called
61
57
  "f" => "File.basename(event.file)", # Filename where the loger was called
62
58
  "M" => "event.method", # Method name where the logger was called
63
59
  "n" => "event.line" # Line where the logger was called
64
60
  }
65
61
 
66
- PatternRegexp = /([^%]*)(%\d*)?([#{PatternTable.keys.join}])?(.*)/
62
+ PatternRegexp = /([^%]*)(%\d*)?(#{PatternTable.keys.join('|')})?(.*)/
67
63
 
68
64
 
69
65
  # Initializes a new +Yell::Formatter+.
data/lib/yell/level.rb CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  module Yell #:nodoc:
4
4
 
5
- def self.level( val = nil )
6
- Yell::Level.new( val )
7
- end
8
-
9
5
  # The +Level+ class handles the severities for you in order to determine
10
6
  # if an adapter should log or not.
11
7
  #
data/lib/yell/logger.rb CHANGED
@@ -2,31 +2,34 @@
2
2
 
3
3
  module Yell #:nodoc:
4
4
 
5
- # The +Logger+ is your entrypoint. Anything onwards is derived from here.
5
+ # The +Yell::Logger+ is your entrypoint. Anything onwards is derived from here.
6
+ #
7
+ # A +Yell::Logger+ instance holds all your adapters and sends the log events
8
+ # to them if applicable. There are multiple ways of how to create a new logger.
9
+ #
10
+ # @example A standard file logger
11
+ # Yell::Logger.new
12
+ # Yell::Logger.new 'development.log'
13
+ #
14
+ # @example A standard datefile logger
15
+ # Yell::Logger.new :datefile
16
+ # Yell::Logger.new :datefile, 'development.log'
17
+ #
18
+ # @example Setting the log level
19
+ # Yell::Logger.new :level => :warn
20
+ #
21
+ # Yell::Logger.new do
22
+ # level :warn
23
+ # end
24
+ #
25
+ # @example Combined settings
26
+ # Yell::Logger.new 'development.log', :level => :warn
27
+ #
28
+ # Yell::Logger.new :datefile, 'development.log' do
29
+ # level :info
30
+ # end
6
31
  class Logger
7
- # Creates a new Logger instance
8
- #
9
- # @example A standard file logger
10
- # Yell::Logger.new
11
- # Yell::Logger.new 'development.log'
12
- #
13
- # @example A standard datefile logger
14
- # Yell::Logger.new :datefile
15
- # Yell::Logger.new :datefile, 'development.log'
16
- #
17
- # @example Setting the log level
18
- # Yell::Logger.new :level => :warn
19
- #
20
- # Yell::Logger.new do
21
- # level :warn
22
- # end
23
- #
24
- # @example Combined settings
25
- # Yell::Logger.new 'development.log', :level => :warn
26
- #
27
- # Yell::Logger.new :datefile, 'development.log' do
28
- # level :info
29
- # end
32
+
30
33
  def initialize( *args, &block )
31
34
  @adapters = []
32
35
 
data/lib/yell/version.rb CHANGED
@@ -1,4 +1,7 @@
1
+ # encoding: utf-8
2
+
1
3
  module Yell #:nodoc:
2
- VERSION = "0.4.2"
4
+ VERSION = "0.4.3"
3
5
 
4
6
  end
7
+
@@ -37,6 +37,11 @@ describe Yell::Formatter do
37
37
  it { format.should == Process.pid.to_s }
38
38
  end
39
39
 
40
+ context "%t" do
41
+ subject { "%t" }
42
+ it { format.should == Thread.current.object_id.to_s }
43
+ end
44
+
40
45
  context "%h" do
41
46
  subject { "%h" }
42
47
  it { format.should == Socket.gethostname }
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.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-30 00:00:00.000000000 Z
12
+ date: 2012-03-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rr
16
- requirement: &70222528328160 !ruby/object:Gem::Requirement
16
+ requirement: &70326139575900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70222528328160
24
+ version_requirements: *70326139575900
25
25
  description: Yell - Your Extensible Logging Library. Define multiple adapters, various
26
26
  log level combinations or message formatting options like you've never done before
27
27
  email: