log4r 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/README +3 -3
  2. data/Rakefile +3 -3
  3. data/doc/rdoc-log4r.css +696 -0
  4. data/examples/syslogcustom.rb +6 -1
  5. data/src/doc/Log4r.html +392 -0
  6. data/src/doc/Log4r/BasicFormatter.html +370 -0
  7. data/src/doc/Log4r/ConfigError.html +207 -0
  8. data/src/doc/Log4r/Configurator.html +1050 -0
  9. data/src/doc/Log4r/DateFileOutputter.html +454 -0
  10. data/src/doc/Log4r/DefaultFormatter.html +205 -0
  11. data/src/doc/Log4r/EmailOutputter.html +636 -0
  12. data/src/doc/Log4r/FileOutputter.html +321 -0
  13. data/src/doc/Log4r/Formatter.html +291 -0
  14. data/src/doc/Log4r/IOOutputter.html +392 -0
  15. data/src/doc/Log4r/Log4rConfig.html +193 -0
  16. data/src/doc/Log4r/Log4rTools.html +370 -0
  17. data/src/doc/Log4r/LogEvent.html +360 -0
  18. data/src/doc/Log4r/LogServer.html +322 -0
  19. data/src/doc/Log4r/Logger.html +1132 -0
  20. data/src/doc/Log4r/Logger/LoggerFactory.html +200 -0
  21. data/src/doc/Log4r/Logger/Repository.html +207 -0
  22. data/src/doc/Log4r/ObjectFormatter.html +262 -0
  23. data/src/doc/Log4r/Outputter.html +910 -0
  24. data/src/doc/Log4r/Outputter/OutputterFactory.html +200 -0
  25. data/src/doc/Log4r/Outputter/consoleoutputters_rb.html +57 -0
  26. data/src/doc/Log4r/Outputter/datefileoutputter_rb.html +93 -0
  27. data/src/doc/Log4r/Outputter/emailoutputter_rb.html +179 -0
  28. data/src/doc/Log4r/Outputter/fileoutputter_rb.html +64 -0
  29. data/src/doc/Log4r/Outputter/iooutputter_rb.html +59 -0
  30. data/src/doc/Log4r/Outputter/outputter_rb.html +222 -0
  31. data/src/doc/Log4r/Outputter/outputterfactory_rb.html +62 -0
  32. data/src/doc/Log4r/Outputter/remoteoutputter_rb.html +59 -0
  33. data/src/doc/Log4r/Outputter/rollingfileoutputter_rb.html +66 -0
  34. data/src/doc/Log4r/Outputter/staticoutputter_rb.html +55 -0
  35. data/src/doc/Log4r/Outputter/syslogoutputter_rb.html +110 -0
  36. data/src/doc/Log4r/Outputter/tst_rb.html +54 -0
  37. data/src/doc/Log4r/PatternFormatter.html +422 -0
  38. data/src/doc/Log4r/ROMPClient.html +193 -0
  39. data/src/doc/Log4r/ROMPServer.html +193 -0
  40. data/src/doc/Log4r/RemoteOutputter.html +384 -0
  41. data/src/doc/Log4r/RollingFileOutputter.html +528 -0
  42. data/src/doc/Log4r/RootLogger.html +512 -0
  43. data/src/doc/Log4r/SimpleFormatter.html +258 -0
  44. data/src/doc/Log4r/StderrOutputter.html +250 -0
  45. data/src/doc/Log4r/StdoutOutputter.html +250 -0
  46. data/src/doc/Log4r/SyslogOutputter.html +533 -0
  47. data/src/doc/Log4r/YamlConfigurator.html +948 -0
  48. data/src/doc/Log4r/base_rb.html +57 -0
  49. data/src/doc/Log4r/config_rb.html +76 -0
  50. data/src/doc/Log4r/configurator_rb.html +370 -0
  51. data/src/doc/Log4r/formatter/formatter_rb.html +121 -0
  52. data/src/doc/Log4r/formatter/patternformatter_rb.html +233 -0
  53. data/src/doc/Log4r/lib/drbloader_rb.html +57 -0
  54. data/src/doc/Log4r/lib/xmlloader_rb.html +57 -0
  55. data/src/doc/Log4r/logevent_rb.html +55 -0
  56. data/src/doc/Log4r/logger_rb.html +293 -0
  57. data/src/doc/Log4r/loggerfactory_rb.html +66 -0
  58. data/src/doc/Log4r/logserver_rb.html +161 -0
  59. data/src/doc/Log4r/rdoc/configurator.html +444 -0
  60. data/src/doc/Log4r/rdoc/emailoutputter.html +261 -0
  61. data/src/doc/Log4r/rdoc/formatter.html +200 -0
  62. data/src/doc/Log4r/rdoc/log4r.html +268 -0
  63. data/src/doc/Log4r/rdoc/logger.html +364 -0
  64. data/src/doc/Log4r/rdoc/logserver.html +247 -0
  65. data/src/doc/Log4r/rdoc/outputter.html +295 -0
  66. data/src/doc/Log4r/rdoc/patternformatter.html +313 -0
  67. data/src/doc/Log4r/rdoc/syslogoutputter.html +179 -0
  68. data/src/doc/Log4r/rdoc/yamlconfigurator.html +169 -0
  69. data/src/doc/Log4r/repository_rb.html +62 -0
  70. data/src/doc/Log4r/staticlogger_rb.html +55 -0
  71. data/src/doc/Log4r/yamlconfigurator_rb.html +95 -0
  72. data/src/doc/REXML.html +193 -0
  73. data/src/doc/created.rid +1 -0
  74. data/src/doc/images/brick.png +0 -0
  75. data/src/doc/images/brick_link.png +0 -0
  76. data/src/doc/images/bug.png +0 -0
  77. data/src/doc/images/bullet_black.png +0 -0
  78. data/src/doc/images/bullet_toggle_minus.png +0 -0
  79. data/src/doc/images/bullet_toggle_plus.png +0 -0
  80. data/src/doc/images/date.png +0 -0
  81. data/src/doc/images/find.png +0 -0
  82. data/src/doc/images/loadingAnimation.gif +0 -0
  83. data/src/doc/images/macFFBgHack.png +0 -0
  84. data/src/doc/images/package.png +0 -0
  85. data/src/doc/images/page_green.png +0 -0
  86. data/src/doc/images/page_white_text.png +0 -0
  87. data/src/doc/images/page_white_width.png +0 -0
  88. data/src/doc/images/plugin.png +0 -0
  89. data/src/doc/images/ruby.png +0 -0
  90. data/src/doc/images/tag_green.png +0 -0
  91. data/src/doc/images/wrench.png +0 -0
  92. data/src/doc/images/wrench_orange.png +0 -0
  93. data/src/doc/images/zoom.png +0 -0
  94. data/src/doc/index.html +384 -0
  95. data/src/doc/js/darkfish.js +116 -0
  96. data/src/doc/js/jquery.js +32 -0
  97. data/src/doc/js/quicksearch.js +114 -0
  98. data/src/doc/js/thickbox-compressed.js +10 -0
  99. data/src/doc/rdoc.css +696 -0
  100. data/src/log4r.rb +2 -2
  101. data/src/log4r/formatter/patternformatter.rb +18 -2
  102. data/src/log4r/logger.rb +2 -2
  103. data/src/log4r/outputter/emailoutputter.rb +2 -0
  104. data/src/log4r/outputter/syslogoutputter.rb +29 -9
  105. data/src/log4r/outputter/tst.rb +8 -0
  106. metadata +99 -3
  107. data/examples/logs/simple.log +0 -1
data/src/log4r.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # == Other Info
4
4
  #
5
5
  # Author:: Leon Torres
6
- # Version:: $Id: log4r.rb,v 1.3 2009/09/23 21:25:18 colbygk Exp $
6
+ # Version:: $Id: log4r.rb,v 1.4 2009/09/25 20:33:47 colbygk Exp $
7
7
 
8
8
  require "log4r/outputter/fileoutputter"
9
9
  require "log4r/outputter/consoleoutputters"
@@ -13,5 +13,5 @@ require "log4r/formatter/patternformatter"
13
13
  require "log4r/loggerfactory"
14
14
 
15
15
  module Log4r
16
- Log4rVersion = [1, 1, 1].join '.'
16
+ Log4rVersion = [1, 1, 2].join '.'
17
17
  end
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # == Other Info
4
4
  #
5
- # Version:: $Id: patternformatter.rb,v 1.3 2009/09/19 05:16:43 colbygk Exp $
5
+ # Version:: $Id: patternformatter.rb,v 1.5 2009/09/25 20:33:33 colbygk Exp $
6
6
 
7
7
  require "log4r/formatter/formatter"
8
8
 
@@ -11,12 +11,24 @@ module Log4r
11
11
  class PatternFormatter < BasicFormatter
12
12
 
13
13
  # Arguments to sprintf keyed to directive letters
14
+ # %c - event short name
15
+ # %C - event fullname
16
+ # %d - date
17
+ # %t - trace
18
+ # %m - message
19
+ # %h - thread name
20
+ # %p - process ID aka PID
21
+ # %M - formatted message
22
+ # %l - Level in string form
23
+ # %% - Insert a %
14
24
  DirectiveTable = {
15
25
  "c" => 'event.name',
16
26
  "C" => 'event.fullname',
17
27
  "d" => 'format_date',
18
28
  "t" => '(event.tracer.nil? ? "no trace" : event.tracer[0])',
19
29
  "m" => 'event.data',
30
+ "h" => 'thread_name',
31
+ "p" => 'Process.pid.to_s',
20
32
  "M" => 'format_object(event.data)',
21
33
  "l" => 'LNAMES[event.level]',
22
34
  "%" => '"%"'
@@ -31,7 +43,7 @@ module Log4r
31
43
  # * $5 is the directive letter
32
44
  # * $6 is the stuff after the directive or "" if not applicable
33
45
 
34
- DirectiveRegexp = /([^%]*)((%-?\d*(\.\d+)?)([cCdtmMl%]))?(.*)/
46
+ DirectiveRegexp = /([^%]*)((%-?\d*(\.\d+)?)([cCdtmhpMl%]))?(.*)/
35
47
 
36
48
  # default date format
37
49
  ISO8601 = "%Y-%m-%d %H:%M:%S"
@@ -62,6 +74,10 @@ module Log4r
62
74
  PatternFormatter.create_format_methods(self)
63
75
  end
64
76
 
77
+ def thread_name
78
+ Thread.current[:name] || Thread.current.to_s
79
+ end
80
+
65
81
  # PatternFormatter works by dynamically defining a <tt>format</tt> method
66
82
  # based on the supplied pattern format. This method contains a call to
67
83
  # Kernel#sptrintf with arguments containing the data requested in
data/src/log4r/logger.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # == Other Info
4
4
  #
5
- # Version:: $Id: logger.rb,v 1.1.1.1 2004/03/19 03:31:07 fando Exp $
5
+ # Version:: $Id: logger.rb,v 1.2 2009/09/24 04:58:28 colbygk Exp $
6
6
  # Author:: Leon Torres <leon(at)ugcs.caltech.edu>
7
7
 
8
8
  require "log4r/outputter/outputter"
@@ -138,7 +138,7 @@ module Log4r
138
138
  def is_root?; false end
139
139
 
140
140
  def ==(other)
141
- return true if id == other.id
141
+ return true if self.object_id == other.object_id
142
142
  end
143
143
  end
144
144
 
@@ -23,6 +23,7 @@ module Log4r
23
23
  }
24
24
  Logger.log_internal {e}
25
25
  self.level = OFF
26
+ raise e
26
27
  end
27
28
  end
28
29
 
@@ -109,6 +110,7 @@ module Log4r
109
110
  }
110
111
  Logger.log_internal {e}
111
112
  self.level = OFF
113
+ raise e
112
114
  ensure @buff.clear
113
115
  end
114
116
  end
@@ -1,6 +1,6 @@
1
1
  # :include: ../rdoc/syslogoutputter
2
2
  #
3
- # Version:: $Id: syslogoutputter.rb,v 1.3 2009/09/23 06:20:19 colbygk Exp $
3
+ # Version:: $Id: syslogoutputter.rb,v 1.5 2009/09/25 20:33:33 colbygk Exp $
4
4
  # Author:: Steve Lumos
5
5
  # Author:: Leon Torres
6
6
 
@@ -11,19 +11,21 @@ require 'syslog'
11
11
 
12
12
  module Log4r
13
13
 
14
- # syslog needs to set the custom levels
15
- #if LNAMES.size > 1
16
- # raise LoadError, "Must let syslogger.rb define custom levels"
17
- #end
18
- # tune log4r to syslog priorities
19
- #Configurator.custom_levels("DEBUG", "INFO", "NOTICE", "WARNING", "ERR", "CRIT", "ALERT", "EMERG")
20
-
21
14
  SYSLOGNAMES = Hash.new
22
15
 
23
16
  class SyslogOutputter < Outputter
24
17
  include Syslog::Constants
25
18
 
26
19
  # maps default log4r levels to syslog priorities (logevents never see ALL and OFF)
20
+ # SYSLOG Levels are:
21
+ # "DEBUG" => Syslog::LOG_DEBUG
22
+ # "INFO" => Syslog::LOG_INFO
23
+ # "NOTICE" => Syslog::LOG_NOTICE
24
+ # "WARN" => Syslog::LOG_WARN
25
+ # "ERROR" => Syslog::LOG_ERROR
26
+ # "FATAL" => Syslog::LOG_FATAL
27
+ # "ALERT" => Syslog::LOG_ALERT
28
+ # "EMERG" => Syslog::LOG_EMERG
27
29
  SYSLOG_LEVELS_MAP = {
28
30
  "DEBUG" => LOG_DEBUG,
29
31
  "INFO" => LOG_INFO,
@@ -35,6 +37,12 @@ module Log4r
35
37
  "EMERG" => LOG_EMERG, # by default EMERG is not in log4r
36
38
  }
37
39
 
40
+ # mapping from Log4r default levels to syslog, by string name
41
+ # "DEBUG" => "DEBUG"
42
+ # "INFO" => "INFO"
43
+ # "WARN" => "WARN"
44
+ # "ERROR" => "ERROR"
45
+ # "FATAL" => "FATAL"
38
46
  SYSLOG_LOG4R_MAP = {
39
47
  "DEBUG" => "DEBUG",
40
48
  "INFO" => "INFO",
@@ -59,7 +67,11 @@ module Log4r
59
67
  logopt = (hash[:logopt] or hash['logopt'] or LOG_PID | LOG_CONS).to_i
60
68
  facility = (hash[:facility] or hash['facility'] or LOG_USER).to_i
61
69
  map_levels_by_name_to_syslog()
62
- @syslog = Syslog.open(ident, logopt, facility)
70
+ if ( Syslog.opened? ) then
71
+ Logger.log_internal { "Syslog already initialized, to alter, " +
72
+ "you must close first"}
73
+ end
74
+ @syslog = ( Syslog.opened? ) ? Syslog : Syslog.open(ident, logopt, facility)
63
75
  end
64
76
 
65
77
  def closed?
@@ -83,6 +95,14 @@ module Log4r
83
95
  # should provide this underlying mapping, otherwise
84
96
  # all messages will be mapped to the underlying syslog
85
97
  # level of INFO by default.
98
+ # e.g.
99
+ # You have created custom levels called:
100
+ # <tt>Configurator.custom_levels "HIGH", "MEDIUM", "LOW"</tt>
101
+ # To map these to 'equivilent' syslog levels, after instantiatin
102
+ # a syslogoutputter:
103
+ # <tt>SyslogOutputter.map_levels_by_name_to_syslog(
104
+ # { "HIGH" => "ALERT", "MEDIUM" => "WARN", "LOW" => "INFO" }
105
+ # )</tt>
86
106
  def map_levels_by_name_to_syslog( lmap = SYSLOG_LOG4R_MAP )
87
107
  @levels_map = lmap
88
108
  end
@@ -0,0 +1,8 @@
1
+ require 'syslog'
2
+ include Syslog::Constants
3
+
4
+ s1=Syslog.open( "test1", LOG_PID | LOG_CONS | LOG_PERROR, LOG_USER )
5
+ s1.log( LOG_INFO, "%s", "test1 test1" )
6
+
7
+ s2=Syslog.open( "test2", LOG_PID | LOG_CONS, LOG_USER )
8
+ s2.log( LOG_INFO, "%s", "test2 test2" )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colby Gutierrez-Kraybill
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-23 00:00:00 -07:00
12
+ date: 2009-09-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -41,12 +41,12 @@ files:
41
41
  - doc/images/log4r-logo.png
42
42
  - doc/images/logo2.png
43
43
  - doc/log4r.css
44
+ - doc/rdoc-log4r.css
44
45
  - doc/templates/main.html
45
46
  - examples/customlevels.rb
46
47
  - examples/fileroll.rb
47
48
  - examples/log4r_yaml.yaml
48
49
  - examples/logclient.rb
49
- - examples/logs/simple.log
50
50
  - examples/logserver.rb
51
51
  - examples/moderate.xml
52
52
  - examples/moderateconfig.rb
@@ -59,6 +59,101 @@ files:
59
59
  - examples/syslogcustom.rb
60
60
  - examples/xmlconfig.rb
61
61
  - examples/yaml.rb
62
+ - src/doc/created.rid
63
+ - src/doc/images/brick.png
64
+ - src/doc/images/brick_link.png
65
+ - src/doc/images/bug.png
66
+ - src/doc/images/bullet_black.png
67
+ - src/doc/images/bullet_toggle_minus.png
68
+ - src/doc/images/bullet_toggle_plus.png
69
+ - src/doc/images/date.png
70
+ - src/doc/images/find.png
71
+ - src/doc/images/loadingAnimation.gif
72
+ - src/doc/images/macFFBgHack.png
73
+ - src/doc/images/package.png
74
+ - src/doc/images/page_green.png
75
+ - src/doc/images/page_white_text.png
76
+ - src/doc/images/page_white_width.png
77
+ - src/doc/images/plugin.png
78
+ - src/doc/images/ruby.png
79
+ - src/doc/images/tag_green.png
80
+ - src/doc/images/wrench.png
81
+ - src/doc/images/wrench_orange.png
82
+ - src/doc/images/zoom.png
83
+ - src/doc/index.html
84
+ - src/doc/js/darkfish.js
85
+ - src/doc/js/jquery.js
86
+ - src/doc/js/quicksearch.js
87
+ - src/doc/js/thickbox-compressed.js
88
+ - src/doc/Log4r/base_rb.html
89
+ - src/doc/Log4r/BasicFormatter.html
90
+ - src/doc/Log4r/config_rb.html
91
+ - src/doc/Log4r/ConfigError.html
92
+ - src/doc/Log4r/Configurator.html
93
+ - src/doc/Log4r/configurator_rb.html
94
+ - src/doc/Log4r/DateFileOutputter.html
95
+ - src/doc/Log4r/DefaultFormatter.html
96
+ - src/doc/Log4r/EmailOutputter.html
97
+ - src/doc/Log4r/FileOutputter.html
98
+ - src/doc/Log4r/formatter/formatter_rb.html
99
+ - src/doc/Log4r/formatter/patternformatter_rb.html
100
+ - src/doc/Log4r/Formatter.html
101
+ - src/doc/Log4r/IOOutputter.html
102
+ - src/doc/Log4r/lib/drbloader_rb.html
103
+ - src/doc/Log4r/lib/xmlloader_rb.html
104
+ - src/doc/Log4r/Log4rConfig.html
105
+ - src/doc/Log4r/Log4rTools.html
106
+ - src/doc/Log4r/LogEvent.html
107
+ - src/doc/Log4r/logevent_rb.html
108
+ - src/doc/Log4r/Logger/LoggerFactory.html
109
+ - src/doc/Log4r/Logger/Repository.html
110
+ - src/doc/Log4r/Logger.html
111
+ - src/doc/Log4r/logger_rb.html
112
+ - src/doc/Log4r/loggerfactory_rb.html
113
+ - src/doc/Log4r/LogServer.html
114
+ - src/doc/Log4r/logserver_rb.html
115
+ - src/doc/Log4r/ObjectFormatter.html
116
+ - src/doc/Log4r/Outputter/consoleoutputters_rb.html
117
+ - src/doc/Log4r/Outputter/datefileoutputter_rb.html
118
+ - src/doc/Log4r/Outputter/emailoutputter_rb.html
119
+ - src/doc/Log4r/Outputter/fileoutputter_rb.html
120
+ - src/doc/Log4r/Outputter/iooutputter_rb.html
121
+ - src/doc/Log4r/Outputter/outputter_rb.html
122
+ - src/doc/Log4r/Outputter/OutputterFactory.html
123
+ - src/doc/Log4r/Outputter/outputterfactory_rb.html
124
+ - src/doc/Log4r/Outputter/remoteoutputter_rb.html
125
+ - src/doc/Log4r/Outputter/rollingfileoutputter_rb.html
126
+ - src/doc/Log4r/Outputter/staticoutputter_rb.html
127
+ - src/doc/Log4r/Outputter/syslogoutputter_rb.html
128
+ - src/doc/Log4r/Outputter/tst_rb.html
129
+ - src/doc/Log4r/Outputter.html
130
+ - src/doc/Log4r/PatternFormatter.html
131
+ - src/doc/Log4r/rdoc/configurator.html
132
+ - src/doc/Log4r/rdoc/emailoutputter.html
133
+ - src/doc/Log4r/rdoc/formatter.html
134
+ - src/doc/Log4r/rdoc/log4r.html
135
+ - src/doc/Log4r/rdoc/logger.html
136
+ - src/doc/Log4r/rdoc/logserver.html
137
+ - src/doc/Log4r/rdoc/outputter.html
138
+ - src/doc/Log4r/rdoc/patternformatter.html
139
+ - src/doc/Log4r/rdoc/syslogoutputter.html
140
+ - src/doc/Log4r/rdoc/yamlconfigurator.html
141
+ - src/doc/Log4r/RemoteOutputter.html
142
+ - src/doc/Log4r/repository_rb.html
143
+ - src/doc/Log4r/RollingFileOutputter.html
144
+ - src/doc/Log4r/ROMPClient.html
145
+ - src/doc/Log4r/ROMPServer.html
146
+ - src/doc/Log4r/RootLogger.html
147
+ - src/doc/Log4r/SimpleFormatter.html
148
+ - src/doc/Log4r/staticlogger_rb.html
149
+ - src/doc/Log4r/StderrOutputter.html
150
+ - src/doc/Log4r/StdoutOutputter.html
151
+ - src/doc/Log4r/SyslogOutputter.html
152
+ - src/doc/Log4r/YamlConfigurator.html
153
+ - src/doc/Log4r/yamlconfigurator_rb.html
154
+ - src/doc/Log4r.html
155
+ - src/doc/rdoc.css
156
+ - src/doc/REXML.html
62
157
  - src/log4r/base.rb
63
158
  - src/log4r/config.rb
64
159
  - src/log4r/configurator.rb
@@ -81,6 +176,7 @@ files:
81
176
  - src/log4r/outputter/rollingfileoutputter.rb
82
177
  - src/log4r/outputter/staticoutputter.rb
83
178
  - src/log4r/outputter/syslogoutputter.rb
179
+ - src/log4r/outputter/tst.rb
84
180
  - src/log4r/rdoc/configurator
85
181
  - src/log4r/rdoc/emailoutputter
86
182
  - src/log4r/rdoc/formatter
@@ -1 +0,0 @@
1
- FATAL simpleconf: kaboom!