path-log4r 1.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/INSTALL +11 -0
  2. data/LICENSE +90 -0
  3. data/LICENSE.LGPLv3 +165 -0
  4. data/README +95 -0
  5. data/Rakefile +74 -0
  6. data/TODO +2 -0
  7. data/doc/content/contact.html +22 -0
  8. data/doc/content/contribute.html +21 -0
  9. data/doc/content/index.html +90 -0
  10. data/doc/content/license.html +56 -0
  11. data/doc/content/manual.html +449 -0
  12. data/doc/dev/README.developers +55 -0
  13. data/doc/dev/checklist +23 -0
  14. data/doc/dev/things-to-do +5 -0
  15. data/doc/images/log4r-logo.png +0 -0
  16. data/doc/images/logo2.png +0 -0
  17. data/doc/log4r.css +111 -0
  18. data/doc/rdoc-log4r.css +696 -0
  19. data/doc/templates/main.html +147 -0
  20. data/examples/README +19 -0
  21. data/examples/ancestors.rb +53 -0
  22. data/examples/chainsaw_settings.xml +7 -0
  23. data/examples/customlevels.rb +34 -0
  24. data/examples/filelog.rb +25 -0
  25. data/examples/fileroll.rb +40 -0
  26. data/examples/gmail.rb +30 -0
  27. data/examples/gmail.yaml +95 -0
  28. data/examples/log4r_yaml.yaml +0 -0
  29. data/examples/logclient.rb +25 -0
  30. data/examples/logserver.rb +18 -0
  31. data/examples/moderate.xml +29 -0
  32. data/examples/moderateconfig.rb +66 -0
  33. data/examples/myformatter.rb +23 -0
  34. data/examples/outofthebox.rb +21 -0
  35. data/examples/rdoc-gen +2 -0
  36. data/examples/rrconfig.xml +63 -0
  37. data/examples/rrsetup.rb +42 -0
  38. data/examples/simpleconfig.rb +39 -0
  39. data/examples/syslogcustom.rb +52 -0
  40. data/examples/xmlconfig.rb +25 -0
  41. data/examples/yaml.rb +30 -0
  42. data/lib/log4r.rb +20 -0
  43. data/lib/log4r/GDC.rb +41 -0
  44. data/lib/log4r/MDC.rb +59 -0
  45. data/lib/log4r/NDC.rb +86 -0
  46. data/lib/log4r/base.rb +74 -0
  47. data/lib/log4r/config.rb +9 -0
  48. data/lib/log4r/configurator.rb +224 -0
  49. data/lib/log4r/formatter/formatter.rb +105 -0
  50. data/lib/log4r/formatter/log4jxmlformatter.rb +61 -0
  51. data/lib/log4r/formatter/patternformatter.rb +145 -0
  52. data/lib/log4r/lib/drbloader.rb +52 -0
  53. data/lib/log4r/lib/xmlloader.rb +24 -0
  54. data/lib/log4r/logevent.rb +28 -0
  55. data/lib/log4r/logger.rb +199 -0
  56. data/lib/log4r/loggerfactory.rb +89 -0
  57. data/lib/log4r/logserver.rb +28 -0
  58. data/lib/log4r/outputter/consoleoutputters.rb +18 -0
  59. data/lib/log4r/outputter/datefileoutputter.rb +117 -0
  60. data/lib/log4r/outputter/emailoutputter.rb +143 -0
  61. data/lib/log4r/outputter/fileoutputter.rb +56 -0
  62. data/lib/log4r/outputter/iooutputter.rb +55 -0
  63. data/lib/log4r/outputter/outputter.rb +134 -0
  64. data/lib/log4r/outputter/outputterfactory.rb +61 -0
  65. data/lib/log4r/outputter/remoteoutputter.rb +40 -0
  66. data/lib/log4r/outputter/rollingfileoutputter.rb +234 -0
  67. data/lib/log4r/outputter/scribeoutputter.rb +37 -0
  68. data/lib/log4r/outputter/staticoutputter.rb +30 -0
  69. data/lib/log4r/outputter/syslogoutputter.rb +130 -0
  70. data/lib/log4r/outputter/udpoutputter.rb +53 -0
  71. data/lib/log4r/rdoc/GDC +14 -0
  72. data/lib/log4r/rdoc/MDC +16 -0
  73. data/lib/log4r/rdoc/NDC +41 -0
  74. data/lib/log4r/rdoc/configurator +243 -0
  75. data/lib/log4r/rdoc/emailoutputter +103 -0
  76. data/lib/log4r/rdoc/formatter +39 -0
  77. data/lib/log4r/rdoc/log4r +89 -0
  78. data/lib/log4r/rdoc/logger +175 -0
  79. data/lib/log4r/rdoc/logserver +85 -0
  80. data/lib/log4r/rdoc/outputter +108 -0
  81. data/lib/log4r/rdoc/patternformatter +128 -0
  82. data/lib/log4r/rdoc/scribeoutputter +16 -0
  83. data/lib/log4r/rdoc/syslogoutputter +29 -0
  84. data/lib/log4r/rdoc/win32eventoutputter +7 -0
  85. data/lib/log4r/rdoc/yamlconfigurator +20 -0
  86. data/lib/log4r/repository.rb +88 -0
  87. data/lib/log4r/staticlogger.rb +49 -0
  88. data/lib/log4r/yamlconfigurator.rb +196 -0
  89. data/tests/README +10 -0
  90. data/tests/testGDC.rb +26 -0
  91. data/tests/testMDC.rb +42 -0
  92. data/tests/testNDC.rb +27 -0
  93. data/tests/testall.rb +6 -0
  94. data/tests/testbase.rb +49 -0
  95. data/tests/testchainsaw.rb +48 -0
  96. data/tests/testconf.xml +37 -0
  97. data/tests/testcustom.rb +27 -0
  98. data/tests/testformatter.rb +27 -0
  99. data/tests/testlogger.rb +196 -0
  100. data/tests/testoutputter.rb +132 -0
  101. data/tests/testpatternformatter.rb +78 -0
  102. data/tests/testthreads.rb +35 -0
  103. data/tests/testxmlconf.rb +45 -0
  104. metadata +184 -0
@@ -0,0 +1,147 @@
1
+ <html>
2
+ <head>
3
+ <!-- TITLE -->
4
+ <link rel="stylesheet" type="text/css" href="log4r.css">
5
+ </head>
6
+ <body>
7
+
8
+ <div align="right"><img src="images/log4r-logo.png"/></div>
9
+ <hr noshade>
10
+
11
+ <table border="0" cellspacing="3" cellpadding="0" width="100%">
12
+ <tr>
13
+
14
+ <!-- Sidebar -->
15
+ <td width="15%" valign="top">
16
+ <table cellspacing="0" cellpadding="0" width=100%" nowrap="true">
17
+
18
+ <!-- Log4r Box -->
19
+ <tr><td >
20
+ <table width="100%" cellspacing="0" cellpadding="0" align="center" >
21
+ <tr><td width="100%" class="menutitle">Log4r</td></tr>
22
+ <tr><td width="100%" class="menubuff">&nbsp;</td></tr>
23
+ <!-- list -->
24
+ <table class="menu" cellspacing="3" cellpadding="0" width="100%"
25
+ align="center">
26
+ <tr><td ><a href="index.html">Home Page</a></tr></td>
27
+ <tr><td><a href="http://sourceforge.net/project/showfiles.php?group_id=43396">
28
+ Download</a></td></tr>
29
+ <tr><td nowrap="true">
30
+ <a href="http://rubyforge.org/projects/log4r/">@ RubyForge</a>
31
+ </td></tr>
32
+ <tr><td>
33
+ <a href="license.html">License</a>
34
+ </td></tr>
35
+ <tr><td>
36
+ <a href="contact.html">Contact</a>
37
+ </td></tr>
38
+ </table>
39
+ </td></tr>
40
+
41
+ <tr><td height=15>&nbsp;</td></tr>
42
+
43
+ <!-- Doc Box -->
44
+ <tr><td >
45
+ <table cellspacing="0" cellpadding="0" align="center" width="100%">
46
+ <tr><td width="100%" class="menutitle">Documents</td></tr>
47
+ <tr><td width="100%" class="menubuff">&nbsp;</td></tr>
48
+ <!-- list -->
49
+ <table class="menu" cellspacing="3" cellpadding="0" width="100%"
50
+ align="center">
51
+ <tr><td>
52
+ <a href="manual.html">#{version} Manual</a>
53
+ </tr></tr>
54
+ <tr><td>
55
+ <a href="rdoc/index.html">#{version} RDoc API</a>
56
+ </td></tr>
57
+
58
+ </table>
59
+ </td></tr>
60
+
61
+ <tr><td height=15>&nbsp;</td></tr>
62
+
63
+ <!-- Development Box -->
64
+ <tr><td >
65
+ <table cellspacing="0" cellpadding="0" align="center" width="100%">
66
+ <tr><td width="100%" class="menutitle">Development</td></tr>
67
+ <tr><td width="100%" class="menubuff">&nbsp;</td></tr>
68
+ <!-- list -->
69
+ <table class="menu" cellspacing="3" cellpadding="0" width="100%"
70
+ align="center">
71
+ <tr><td>
72
+ <a
73
+ href="http://sourceforge.net/tracker/?atid=436181&group_id=43396&func=browse">
74
+ Bugs</a>
75
+ </tr></tr>
76
+ <tr><td>
77
+ <a
78
+ href="http://sourceforge.net/tracker/?atid=436184&group_id=43396&func=browse">
79
+ Requests</a>
80
+ </td></tr>
81
+ <tr><td>
82
+ <a href="contribute.html">Contribute</a>
83
+ </td></tr>
84
+
85
+ </table>
86
+ </td></tr>
87
+
88
+ <tr><td height=15>&nbsp;</td></tr>
89
+
90
+
91
+ <!-- Link Box -->
92
+ <tr><td >
93
+ <table cellspacing="0" cellpadding="0" align="center" width="100%">
94
+ <tr><td width="100%" class="menutitle">Links</td></tr>
95
+ <tr><td width="100%" class="menubuff">&nbsp;</td></tr>
96
+ <!-- list -->
97
+ <table class="menu" cellspacing="3" cellpadding="0" width="100%"
98
+ align="center">
99
+ <tr><td>
100
+ <a href="http://www.ruby-lang.org/en/index.html">Ruby</a>
101
+ </td></tr>
102
+ <tr><td>
103
+ <a href="http://jakarta.apache.org/log4j/docs/index.html">Apache Log4j</a>
104
+ </tr></tr>
105
+ <tr><td>
106
+ <a href="http://www.ruby-lang.org/en/raa-list.rhtml?name=REXML">REXML</a>
107
+ </td></tr>
108
+ <tr><td>
109
+ <a href="http://rm-f.net/~cout/ruby/romp/">ROMP</a>
110
+ </td></tr>
111
+ <tr><td height="5">&nbsp;</td></tr>
112
+ <tr><td align="center">
113
+ <a href="http://rubyforge.org">
114
+ <!-- rubyforge image goes here -->
115
+ </a>
116
+ </a>
117
+ </td></tr>
118
+
119
+ </table>
120
+ </td></tr>
121
+
122
+ </table>
123
+ </td>
124
+
125
+ <!-- Main column -->
126
+ <td width="85%" align="left" valign="top">
127
+ <center>
128
+ <table cellspacing="0" cellpadding="0" align="center" width="95%">
129
+
130
+ <!-- CONTENT -->
131
+
132
+ </table>
133
+ </center>
134
+ </td>
135
+
136
+
137
+ </tr>
138
+ </table>
139
+ <hr noshade>
140
+ <div align="right">
141
+ <font color="#888888" size="-1">
142
+ <i>
143
+ <!-- CVSID -->
144
+ </i></font>
145
+ </div>
146
+ </body>
147
+ </html>
@@ -0,0 +1,19 @@
1
+ The examples are:
2
+
3
+ 1. outofthebox.rb - How to get started with minimal setup
4
+ 2. simpleconfig.rb - Using Log4r casually
5
+ 3. moderateconfig.rb - A more sophisticated config
6
+ 4. xmlconfig.rb and moderate.xml - XML configuration example based on #3
7
+ 5. rrsetup.rb and rrconfig.xml - A real example (or used to be ;-)
8
+ 6. logserver.rb and logclient.rb - Remote logging example
9
+ 7. fileroll.rb - Using RollingFileOutputter
10
+ 8. yaml.rb and log4r_yaml.yaml - YAML configuration example
11
+
12
+ The output will go to screen and to files in the directory logs/.
13
+
14
+ Note to RubyGems users: The syntax to require log4r as a gem is as follows:
15
+
16
+ require 'rubygems'
17
+ require_gem 'log4r'
18
+
19
+ Obviously, the examples will need to be modified to follow this.
@@ -0,0 +1,53 @@
1
+ $: << File.join("..","lib")
2
+
3
+ # This file demonstrates how inheritence works in log4r
4
+ #
5
+ require 'rubygems'
6
+ require 'log4r'
7
+ include Log4r
8
+
9
+ Logger.global.level = ALL
10
+ formatter = PatternFormatter.new(:pattern => "%l - %m - %c")
11
+ StdoutOutputter.new('console', :formatter => formatter)
12
+
13
+
14
+ # By default, the root logger is the top ancestor to the
15
+ # immediate descendants
16
+ # However, any descendants below the top ancestors will
17
+ # have the ancestor as their RootLogger, which dictates
18
+ # (among other things) the lowest level of log messages
19
+ Logger.new('grandparent', FATAL).add('console')
20
+ Logger.new('grandparent::parent', DEBUG)
21
+ Logger.new('grandparent::parent::child', DEBUG)
22
+
23
+
24
+ def do_logging(log)
25
+ puts "--"
26
+ log.debug "This is debug"
27
+ log.info "This is info"
28
+ log.warn "This is warn"
29
+ log.error "This is error"
30
+ log.fatal "This is fatal"
31
+ end
32
+
33
+ # This logger is configured to log at FATAL, and it does
34
+ do_logging Logger['grandparent']
35
+
36
+ # This logger is configured to log at DEBUG level, but it logs
37
+ # at FATAL because grandparent is now the RootLogger for parent
38
+ do_logging Logger['grandparent::parent']
39
+
40
+ # 'child' logger is configured to log at DEBUG level, but it logs
41
+ # at FATAL because of grandparent
42
+ do_logging Logger['grandparent::parent::child']
43
+
44
+
45
+ Logger['grandparent'].level = DEBUG
46
+ # Now that the grandparent's level is set to DEBUG, the child
47
+ # will log at that level
48
+ do_logging Logger['grandparent::parent::child']
49
+
50
+ Logger['grandparent'].level = OFF
51
+ puts "off?"
52
+ do_logging Logger['grandparent::parent::child']
53
+
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3
+ <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
4
+ <plugin name="log4r_test" class="org.apache.log4j.net.UDPReceiver">
5
+ <param name="Port" value="8071" />
6
+ </plugin>
7
+ </log4j:configuration>
@@ -0,0 +1,34 @@
1
+ # Suppose we don't like having 5 levels named DEBUG, INFO, etc.
2
+ # Suppose we'd rather use 3 levels named Foo, Bar, and Baz.
3
+ # Log4r allows you to rename the levels and their corresponding methods
4
+ # in a painless way. This file provides and example
5
+
6
+ $: << '../lib'
7
+
8
+ require 'log4r'
9
+ require 'log4r/configurator'
10
+ include Log4r
11
+
12
+ # This is how we specify our levels
13
+ Configurator.custom_levels "Foo", "Bar", "Baz"
14
+
15
+ l = Logger.new('custom levels')
16
+ l.add StdoutOutputter.new('console')
17
+
18
+ l.level = Foo
19
+ puts l.foo?
20
+ l.foo "This is foo"
21
+ puts l.bar?
22
+ l.bar "this is bar"
23
+ puts l.baz?
24
+ l.baz "this is baz"
25
+
26
+ puts "Now change to Baz"
27
+
28
+ l.level = Baz
29
+ puts l.foo?
30
+ l.foo {"This is foo"}
31
+ puts l.bar?
32
+ l.bar {"this is bar"}
33
+ puts l.baz?
34
+ l.baz {"this is baz"}
@@ -0,0 +1,25 @@
1
+ # Here's how to start using log4r right away
2
+ $: << File.join('..','lib') # path if log4r not installed
3
+ require "log4r"
4
+
5
+ Log = Log4r::Logger.new("filelog") # create a logger
6
+ # add FileOutputter
7
+ Log.add Log4r::FileOutputter.new( "filelog", {:filename=>"file.log"} )
8
+
9
+ # See book keeping logger events
10
+ iLog = Log4r::Logger.new("log4r")
11
+ iLog.add Log4r::Outputter.stderr
12
+
13
+ # do some logging
14
+ def do_logging
15
+ Log.debug "debugging"
16
+ Log.info "a piece of info"
17
+ Log.warn "Danger, Will Robinson, danger!"
18
+ Log.error "I dropped my Wookie! :("
19
+ Log.fatal "kaboom!"
20
+ end
21
+ do_logging
22
+
23
+ # now let's filter anything below WARN level (DEBUG and INFO)
24
+ Log.level = Log4r::WARN
25
+ do_logging
@@ -0,0 +1,40 @@
1
+ # How to use RollingFileOutputter
2
+
3
+ $: << "../lib"
4
+ require 'log4r'
5
+ include Log4r
6
+
7
+ puts "this will take a while"
8
+
9
+ # example of log file being split by time constraint 'maxtime'
10
+ config = {
11
+ "filename" => "logs/TestTime.log",
12
+ "maxtime" => 10,
13
+ "trunc" => true
14
+ }
15
+ timeLog = Logger.new 'WbExplorer'
16
+ timeLog.outputters = RollingFileOutputter.new("WbExplorer", config)
17
+ timeLog.level = DEBUG
18
+
19
+ # log something once a second for 100 seconds
20
+ 100.times { |t|
21
+ timeLog.info "blah #{t}"
22
+ sleep(1.0)
23
+ }
24
+
25
+ # example of log file being split by space constraint 'maxsize'
26
+ config = {
27
+ "filename" => "logs/TestSize.log",
28
+ "maxsize" => 16000,
29
+ "trunc" => true
30
+ }
31
+ sizeLog = Logger.new 'WbExplorer'
32
+ sizeLog.outputters = RollingFileOutputter.new("WbExplorer", config)
33
+ sizeLog.level = DEBUG
34
+
35
+ # log a large number of times
36
+ 100000.times { |t|
37
+ sizeLog.info "blah #{t}"
38
+ }
39
+
40
+ puts "done! check the two sets of log files in logs/ (TestTime and TestSize)"
@@ -0,0 +1,30 @@
1
+ # Log4r can be configured using YAML to email using STARTTLS. This example uses gmail.yaml
2
+
3
+ $: << File.join('..','lib') # path if log4r is not installed
4
+ require 'log4r'
5
+ require 'log4r/yamlconfigurator'
6
+ # we use various outputters, so require them, otherwise config chokes
7
+ require 'log4r/outputter/datefileoutputter'
8
+ require 'log4r/outputter/emailoutputter'
9
+ include Log4r
10
+
11
+ cfg = YamlConfigurator # shorthand
12
+ cfg['HOME'] = '.' # the only parameter in the YAML, our HOME directory
13
+
14
+ # load the YAML file with this
15
+ cfg.load_yaml_file('gmail.yaml')
16
+
17
+ # Method to log each of the custom levels
18
+ def do_logging(log)
19
+ log.deb "This is DEB"
20
+ log.inf "This is INF"
21
+ log.prt "This is PRT"
22
+ log.wrn "This is WRN"
23
+ log.err "This is ERR"
24
+ log.fat "This is FAT"
25
+ end
26
+
27
+ # turn off the email outputter
28
+ Outputter['email'].level = WRN
29
+ # the other two outputters log to stderr and a timestamped file in ./logs
30
+ do_logging( Logger['mylogger'])
@@ -0,0 +1,95 @@
1
+
2
+
3
+ purpose : Test Mailing to Gmail
4
+ description: Provides configuration info for login to email servers via STARTTLS, e.g. gmail.com
5
+ say : gmail is nice
6
+
7
+ ---
8
+ # *** YAML2LOG4R ***
9
+ log4r_config:
10
+ # define all pre config ...
11
+ pre_config:
12
+ custom_levels:
13
+ - DEB
14
+ - INF
15
+ - PRT
16
+ - WRN
17
+ - ERR
18
+ - FAT
19
+ global:
20
+ level: DEB
21
+ root :
22
+ level: DEB
23
+ parameters:
24
+ - name : x
25
+ value : aaa
26
+ - name : y
27
+ value : bbb
28
+
29
+ # define all loggers ...
30
+ loggers:
31
+ - name : mylogger
32
+ level : DEB
33
+ additive : 'false'
34
+ trace : 'false'
35
+ outputters:
36
+ - stderr
37
+ - logfile
38
+ - email
39
+
40
+ - name : yourlogger
41
+ level : INF
42
+ outputters:
43
+ - stderr
44
+ - logfile
45
+
46
+ # define all outputters (incl. formatters)
47
+ outputters:
48
+ - type : StderrOutputter
49
+ name : stderr
50
+ level : DEB
51
+ only_at :
52
+ - INF
53
+ - WRN
54
+ - FAT
55
+ formatter:
56
+ date_pattern: '%y%m%d %H:%M:%S'
57
+ pattern : '%d %l: %m '
58
+ type : PatternFormatter
59
+
60
+ - type : DateFileOutputter
61
+ name : logfile
62
+ level : DEB
63
+ date_pattern: '%Y%m%d'
64
+ trunc : 'false'
65
+ dirname : "#{HOME}/logs"
66
+ formatter :
67
+ date_pattern: '%y%m%d %H:%M:%S'
68
+ pattern : '%d %l: %m'
69
+ type : PatternFormatter
70
+
71
+ - type : EmailOutputter
72
+ name : email
73
+ level : FAT
74
+ tls : 'true'
75
+ domain : gmail.com
76
+ server : smtp.gmail.com
77
+ port : '587'
78
+ subject : 'Message from testing:'
79
+ from : INSERT_YOUR_FROM_ADDRESS
80
+ to : INSERT_YOUR_TO_ADDRESS
81
+ acct : INSERT_YOUR_GMAIL_ACCOUNTNAME
82
+ passwd : INSERT_YOUR_GMAIL_PASSWORD
83
+ authtype : plain
84
+ immediate_at: FAT
85
+ formatfirst : 'true'
86
+ formatter :
87
+ date_pattern: '%y%m%d %H:%M:%S'
88
+ pattern : '%d %l: %m'
89
+ type : PatternFormatter
90
+
91
+ ---
92
+ purpose : TestB
93
+ description: This is the last YAML doc
94
+ say : Bye
95
+