log4r 1.0.6 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL +18 -0
- data/LICENSE +90 -0
- data/LICENSE.LGPLv3 +165 -0
- data/README +91 -0
- data/Rakefile +70 -0
- data/TODO +35 -0
- data/bin/CVS/Entries +7 -0
- data/bin/CVS/Repository +1 -0
- data/bin/CVS/Root +1 -0
- data/bin/README +8 -0
- data/bin/devconfig.rb +22 -0
- data/bin/makedist.rb +94 -0
- data/bin/makehtml.rb +71 -0
- data/bin/makerdoc.rb +30 -0
- data/bin/prune.rb +37 -0
- data/doc/CVS/Entries +5 -0
- data/doc/CVS/Repository +1 -0
- data/doc/CVS/Root +1 -0
- data/doc/content/CVS/Entries +6 -0
- data/doc/content/CVS/Repository +1 -0
- data/doc/content/CVS/Root +1 -0
- data/doc/dev/CVS/Entries +4 -0
- data/doc/dev/CVS/Repository +1 -0
- data/doc/dev/CVS/Root +1 -0
- data/doc/images/CVS/Entries +3 -0
- data/doc/images/CVS/Repository +1 -0
- data/doc/images/CVS/Root +1 -0
- data/doc/templates/CVS/Entries +2 -0
- data/doc/templates/CVS/Repository +1 -0
- data/doc/templates/CVS/Root +1 -0
- data/examples/CVS/Entries +17 -0
- data/examples/CVS/Repository +1 -0
- data/examples/CVS/Root +1 -0
- data/examples/syslogcustom.rb +47 -0
- data/src/CVS/Entries +2 -0
- data/src/CVS/Repository +1 -0
- data/src/CVS/Root +1 -0
- data/src/log4r.rb +2 -2
- data/src/log4r/CVS/Entries +14 -0
- data/src/log4r/CVS/Repository +1 -0
- data/src/log4r/CVS/Root +1 -0
- data/src/log4r/formatter/CVS/Entries +3 -0
- data/src/log4r/formatter/CVS/Repository +1 -0
- data/src/log4r/formatter/CVS/Root +1 -0
- data/src/log4r/lib/CVS/Entries +3 -0
- data/src/log4r/lib/CVS/Repository +1 -0
- data/src/log4r/lib/CVS/Root +1 -0
- data/src/log4r/outputter/CVS/Entries +12 -0
- data/src/log4r/outputter/CVS/Repository +1 -0
- data/src/log4r/outputter/CVS/Root +1 -0
- data/src/log4r/outputter/syslogoutputter.rb +57 -22
- data/src/log4r/rdoc/CVS/Entries +11 -0
- data/src/log4r/rdoc/CVS/Repository +1 -0
- data/src/log4r/rdoc/CVS/Root +1 -0
- data/src/tst.rb +21 -0
- data/tests/CVS/Entries +11 -0
- data/tests/CVS/Repository +1 -0
- data/tests/CVS/Root +1 -0
- metadata +93 -35
data/bin/CVS/Entries
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
/README/1.1.1.1/Fri Mar 19 03:30:59 2004//
|
2
|
+
/devconfig.rb/1.1.1.1/Fri Mar 19 03:30:59 2004//
|
3
|
+
/makedist.rb/1.1.1.1/Fri Mar 19 03:30:59 2004//
|
4
|
+
/makehtml.rb/1.1.1.1/Fri Mar 19 03:30:59 2004//
|
5
|
+
/makerdoc.rb/1.1.1.1/Fri Mar 19 03:30:59 2004//
|
6
|
+
/prune.rb/1.1.1.1/Fri Mar 19 03:30:59 2004//
|
7
|
+
D
|
data/bin/CVS/Repository
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
log4r/bin
|
data/bin/CVS/Root
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
:ext:colbygk@rubyforge.org:/var/cvs/log4r
|
data/bin/README
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
How to build a release using these scripts:
|
2
|
+
|
3
|
+
1. When running a script, be in bin/
|
4
|
+
2. Edit devconfig.rb to match your setup
|
5
|
+
3. Run each script without arguments to see how it's used
|
6
|
+
4. 'ruby makedist.rb <version>' to build a distribution
|
7
|
+
|
8
|
+
These files work only on unix.
|
data/bin/devconfig.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# This is the developer's config file. Modify for your system.
|
2
|
+
|
3
|
+
# when testing, the CVS release tag is not used, allowing tuning of package
|
4
|
+
$test = true # set to false when final build is to be done
|
5
|
+
# cvs root (-d flag) to use -- don't forget to log in first!
|
6
|
+
$cvsroot = "-d:ext:fando@rubyforge.org:/var/cvs/log4r"
|
7
|
+
# prepdir is where the build process puts working files
|
8
|
+
$prepdir = '/home/cepheus/projects/prep'
|
9
|
+
# releasedir is where the final tarballs are put
|
10
|
+
$releasedir = '/home/cepheus/projects/releases'
|
11
|
+
# quiet = true sends most output to /dev/null
|
12
|
+
$quiet = false
|
13
|
+
|
14
|
+
# These are for removing unneeded developer files from the cvs co
|
15
|
+
|
16
|
+
# delete these directories from toplevel (except bin!)
|
17
|
+
$deletedirs = %w{
|
18
|
+
doc/content doc/templates doc/dev
|
19
|
+
}
|
20
|
+
# delete these files (needs path from toplevel)
|
21
|
+
$deletefiles = %w{
|
22
|
+
}
|
data/bin/makedist.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Run this file to prepare a distribution. Make sure the variables in
|
4
|
+
# devconfig.rb reflects your setup.
|
5
|
+
#
|
6
|
+
# Run from the bin directory and specify the version number as the first
|
7
|
+
# and only argument
|
8
|
+
|
9
|
+
require 'ftools'
|
10
|
+
require 'devconfig'
|
11
|
+
|
12
|
+
$cvsname = 'log4r' # name of log4r module, shouldn't be changed
|
13
|
+
|
14
|
+
# read version from input
|
15
|
+
if ARGV.size == 0
|
16
|
+
puts "Usage: makedist.rb <version>"
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
|
20
|
+
$version = ARGV[0].split(".")
|
21
|
+
puts "makedist.rb: Building Log4r distribution #{$version.join '.'}"
|
22
|
+
|
23
|
+
##### Rest is standard package config
|
24
|
+
|
25
|
+
$dotver = $version.join '.'
|
26
|
+
$dashver = $version.join '-'
|
27
|
+
|
28
|
+
$package = $cvsname + '-' + $dotver
|
29
|
+
$packagedash = $cvsname + '-' + $dashver
|
30
|
+
$tarball = $package + '.tgz'
|
31
|
+
$zipfile = $packagedash + '.zip'
|
32
|
+
$docball = $cvsname + '-doc-' + $dotver + '.tgz'
|
33
|
+
$projdir = $prepdir + "/" + $package
|
34
|
+
|
35
|
+
##### Start program
|
36
|
+
|
37
|
+
# try the dirs out and die if they don't exist
|
38
|
+
unless File.directory? $prepdir
|
39
|
+
raise TypeError, "#{prepdir} is not a dir."
|
40
|
+
end
|
41
|
+
unless File.directory? $releasedir
|
42
|
+
raise TypeError, "#{releasedir} is not a dir."
|
43
|
+
end
|
44
|
+
|
45
|
+
# system commands
|
46
|
+
def run(cmd)
|
47
|
+
unless system cmd + ($quiet ? "> /dev/null 2>&1" : "")
|
48
|
+
raise RuntimeError, "unable to finish '#{cmd}'", caller
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
puts "makedist.rb: checking out #{$cvsname}"
|
54
|
+
Dir.chdir $prepdir
|
55
|
+
# remove any previous instance of auto build
|
56
|
+
run "rm -rf #{$package}"
|
57
|
+
|
58
|
+
# check out the latest if testing, otherwise check out the cvstag version
|
59
|
+
system "cvs #{$cvsroot} co -d #{$package} #{$cvsname}"
|
60
|
+
|
61
|
+
Dir.chdir $package + "/bin"
|
62
|
+
|
63
|
+
# Now run each of the other files in bin to build documents and prune
|
64
|
+
# the cvs of junk for release
|
65
|
+
puts "makedist.rb: running makehtml.rb"
|
66
|
+
run "ruby makehtml.rb #{$dotver} #{$projdir}/doc"
|
67
|
+
puts "makedist.rb: runing prune.rb"
|
68
|
+
run "ruby prune.rb #{$projdir}"
|
69
|
+
puts "makedist.rb: running makerdoc.rb"
|
70
|
+
run "ruby makerdoc.rb #{$dotver} #{$projdir}/src #{$projdir}/doc"
|
71
|
+
puts "makedist.rb: removing #{$projdir}/bin"
|
72
|
+
run "rm -rf #{$projdir}/bin"
|
73
|
+
|
74
|
+
### Release is ready, so zip it up
|
75
|
+
|
76
|
+
Dir.chdir $prepdir
|
77
|
+
|
78
|
+
puts "makedist.rb: making tarball"
|
79
|
+
run "tar -czf #{$tarball} #{$package}"
|
80
|
+
puts "makedist.rb: making zipfile"
|
81
|
+
run "zip -r #{$zipfile} #{$package}"
|
82
|
+
puts "makedist.rb: making documentation tarball"
|
83
|
+
run "tar -czvf #{$docball} #{$package}/doc"
|
84
|
+
|
85
|
+
puts "makedist.rb: moving results to #{$releasedir}"
|
86
|
+
File.mv $tarball, $releasedir
|
87
|
+
File.mv $zipfile, $releasedir
|
88
|
+
File.mv $docball, $releasedir
|
89
|
+
|
90
|
+
# make gemfile last
|
91
|
+
Dir.chdir $package
|
92
|
+
puts "makedist.rb: building gemfile in #{$releasedir}"
|
93
|
+
run "ruby log4r.gemspec"
|
94
|
+
File.mv $package + ".gem", $releasedir
|
data/bin/makehtml.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Builds the html. Can be called independently
|
2
|
+
# For each page in ../doc/content, build the corresponding page
|
3
|
+
# using template from ../doc/templates
|
4
|
+
|
5
|
+
if ARGV.size == 0
|
6
|
+
puts "Usage: makehtml.rb <version> [path-to-docs]"
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
Version = ARGV[0]
|
10
|
+
|
11
|
+
dir = (ARGV[1] or ".")
|
12
|
+
Targetdir = dir.chomp("/")
|
13
|
+
|
14
|
+
# paranoid validation
|
15
|
+
if not FileTest.directory? Targetdir
|
16
|
+
puts "First argument must be path to doc directory"
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
if not FileTest.directory? File.join(Targetdir, "templates")
|
20
|
+
puts "Can't find doc/templates!"
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
if not FileTest.directory? File.join(Targetdir, "content")
|
24
|
+
puts "Can't find doc/content!"
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
|
28
|
+
Templates = Hash.new
|
29
|
+
|
30
|
+
def load(fname)
|
31
|
+
str = ""
|
32
|
+
IO.foreach(fname) {|line|
|
33
|
+
str += line
|
34
|
+
}
|
35
|
+
Templates[fname] = str
|
36
|
+
end
|
37
|
+
|
38
|
+
def parse(fname)
|
39
|
+
title, template, id, cont = nil, nil, nil, ""
|
40
|
+
IO.foreach(fname) {|line|
|
41
|
+
if title.nil? and line =~ /^Title:(.*)/
|
42
|
+
title = "<title>" + ($1).chomp.strip + "</title>"
|
43
|
+
elsif template.nil? and line =~ /^Template:\s*(\S+\.html)/
|
44
|
+
template = $1
|
45
|
+
elsif id.nil? and line=~ /^Id:(.*)/
|
46
|
+
id = $1
|
47
|
+
else
|
48
|
+
cont += line
|
49
|
+
end
|
50
|
+
}
|
51
|
+
temp = Templates[template].clone
|
52
|
+
temp.sub!("<!-- TITLE -->", title)
|
53
|
+
temp.sub!("<!-- CVSID -->", id)
|
54
|
+
# join the content with the template
|
55
|
+
temp.sub!("<!-- CONTENT -->", cont)
|
56
|
+
# replaces #{version} everywhere with Version
|
57
|
+
temp.gsub!('#{version}', Version)
|
58
|
+
out = File.new("../" + fname, "w+")
|
59
|
+
out.print temp
|
60
|
+
out.flush
|
61
|
+
out.close
|
62
|
+
end
|
63
|
+
|
64
|
+
Dir.chdir(File.join(Targetdir, "templates"))
|
65
|
+
Dir.foreach(".") {|fname|
|
66
|
+
load(fname) if fname =~ /html$/
|
67
|
+
}
|
68
|
+
Dir.chdir("../content")
|
69
|
+
Dir.foreach(".") {|fname|
|
70
|
+
parse(fname) if fname =~ /html$/
|
71
|
+
}
|
data/bin/makerdoc.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
if ARGV.size == 0
|
2
|
+
puts "Usage: makerdoc.rb <version> [path-to-log4r.rb] [path-to-docs]"
|
3
|
+
exit
|
4
|
+
end
|
5
|
+
|
6
|
+
Version = ARGV[0]
|
7
|
+
Src = (ARGV[1] or ".").chomp("/")
|
8
|
+
Docs = File.join((ARGV[2] or ".").chomp("/"), "rdoc")
|
9
|
+
|
10
|
+
file = File.join(Src, "log4r.rb")
|
11
|
+
if not FileTest.exist? file
|
12
|
+
puts "Can't find log4r.rb in #{Src}!"
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
|
16
|
+
def run(cmd)
|
17
|
+
unless system cmd
|
18
|
+
raise RuntimeError, "unable to finish '#{cmd}'", caller
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
title = "#{Version} Log4r API"
|
24
|
+
run "cd #{Src}; rdoc --op #{Docs} --template kilmer --main log4r.rb --title '#{title}'"
|
25
|
+
|
26
|
+
# sub the version into the log4r_rb.html file
|
27
|
+
html = IO.readlines(Docs+"/files/log4r_rb.html")
|
28
|
+
f = File.open(Docs+"/files/log4r_rb.html", "w")
|
29
|
+
f.write((html.join).gsub!('#{version}', Version))
|
30
|
+
f.close
|
data/bin/prune.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Cleans up a CVS co of log4r for distribution
|
2
|
+
|
3
|
+
require 'ftools'
|
4
|
+
require 'devconfig'
|
5
|
+
|
6
|
+
if ARGV.size != 1
|
7
|
+
puts "Usage: prune.rb <projectdir>"
|
8
|
+
exit
|
9
|
+
end
|
10
|
+
|
11
|
+
$projhome = (ARGV[0] or ".")
|
12
|
+
$echo = nil # change to "echo" if need to debug, otherwise nil
|
13
|
+
|
14
|
+
# recursively delete any such directory or file with rm -rf
|
15
|
+
recursedel = %w{ CVS }
|
16
|
+
# some dirs aren't checked out with -r, so create them
|
17
|
+
mkdirs = %w{ tests/logs examples/logs }
|
18
|
+
|
19
|
+
def run(cmd)
|
20
|
+
unless system cmd
|
21
|
+
raise RuntimeError, "unable to finish '#{cmd}'", caller
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Dir.chdir $projhome
|
27
|
+
|
28
|
+
for dir in recursedel
|
29
|
+
run "find . -name #{dir} -exec #{$echo} rm -rf {} \\; -prune"
|
30
|
+
end
|
31
|
+
for dir in $deletedirs
|
32
|
+
run "#{$echo} rm -rf #{dir}"
|
33
|
+
end
|
34
|
+
for file in $deletefiles
|
35
|
+
run "#{$echo} rm -f #{file}"
|
36
|
+
end
|
37
|
+
File.makedirs *mkdirs
|
data/doc/CVS/Entries
ADDED
data/doc/CVS/Repository
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
log4r/doc
|
data/doc/CVS/Root
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
:ext:colbygk@rubyforge.org:/var/cvs/log4r
|
@@ -0,0 +1 @@
|
|
1
|
+
log4r/doc/content
|
@@ -0,0 +1 @@
|
|
1
|
+
:ext:colbygk@rubyforge.org:/var/cvs/log4r
|
data/doc/dev/CVS/Entries
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
log4r/doc/dev
|
data/doc/dev/CVS/Root
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
:ext:colbygk@rubyforge.org:/var/cvs/log4r
|
@@ -0,0 +1 @@
|
|
1
|
+
log4r/doc/images
|
data/doc/images/CVS/Root
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
:ext:colbygk@rubyforge.org:/var/cvs/log4r
|
@@ -0,0 +1 @@
|
|
1
|
+
log4r/doc/templates
|
@@ -0,0 +1 @@
|
|
1
|
+
:ext:colbygk@rubyforge.org:/var/cvs/log4r
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/README/1.1.1.1/Fri Mar 19 03:31:05 2004//
|
2
|
+
/customlevels.rb/1.1.1.1/Fri Mar 19 03:31:05 2004//
|
3
|
+
/fileroll.rb/1.1.1.1/Fri Mar 19 03:31:05 2004//
|
4
|
+
/log4r_yaml.yaml/1.1.1.1/Fri Mar 19 03:31:05 2004//
|
5
|
+
/logclient.rb/1.1.1.1/Fri Mar 19 03:31:05 2004//
|
6
|
+
/logserver.rb/1.1.1.1/Fri Mar 19 03:31:05 2004//
|
7
|
+
/moderate.xml/1.1.1.1/Fri Mar 19 03:31:05 2004//
|
8
|
+
/moderateconfig.rb/1.1.1.1/Fri Mar 19 03:31:05 2004//
|
9
|
+
/myformatter.rb/1.1.1.1/Fri Mar 19 03:31:05 2004//
|
10
|
+
/outofthebox.rb/1.1.1.1/Fri Mar 19 03:31:05 2004//
|
11
|
+
/rrconfig.xml/1.1.1.1/Fri Mar 19 03:31:06 2004//
|
12
|
+
/rrsetup.rb/1.1.1.1/Fri Mar 19 03:31:06 2004//
|
13
|
+
/simpleconfig.rb/1.1.1.1/Fri Mar 19 03:31:06 2004//
|
14
|
+
/xmlconfig.rb/1.1.1.1/Fri Mar 19 03:31:06 2004//
|
15
|
+
/yaml.rb/1.1.1.1/Fri Mar 19 03:31:06 2004//
|
16
|
+
/syslogcustom.rb/1.1/Wed Sep 23 06:09:17 2009//
|
17
|
+
D
|
@@ -0,0 +1 @@
|
|
1
|
+
log4r/examples
|
data/examples/CVS/Root
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
:ext:colbygk@rubyforge.org:/var/cvs/log4r
|
@@ -0,0 +1,47 @@
|
|
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
|
+
# Suppose we'd like to use these with syslog
|
4
|
+
# Log4r allows you to rename the levels and their corresponding methods
|
5
|
+
# in a painless way and then map those to corrisponding syslog levels
|
6
|
+
# or have them all default to LOG_INFO
|
7
|
+
# This file provides an example
|
8
|
+
|
9
|
+
$: << '../src'
|
10
|
+
|
11
|
+
require 'log4r'
|
12
|
+
require 'log4r/configurator'
|
13
|
+
require 'log4r/formatter/patternformatter'
|
14
|
+
require 'log4r/outputter/syslogoutputter'
|
15
|
+
require 'syslog'
|
16
|
+
include Log4r
|
17
|
+
include Syslog::Constants
|
18
|
+
|
19
|
+
# This is how we specify our levels
|
20
|
+
Configurator.custom_levels "Foo", "Bar", "Baz"
|
21
|
+
|
22
|
+
l = Logger.new('custom levels')
|
23
|
+
slp = PatternFormatter.new( :pattern => '{%d} {%l} {%C} {%m}', :date_method => 'usec' )
|
24
|
+
sl = SyslogOutputter.new( 'sysloggertest',
|
25
|
+
{ :logopt => LOG_CONS | LOG_PID | LOG_PERROR,
|
26
|
+
:facility => LOG_LOCAL7,
|
27
|
+
:formatter => slp } )
|
28
|
+
sl.map_levels_by_name_to_syslog( { "Foo" => "DEBUG", "Bar" => "INFO", "Baz" => "ALERT" } )
|
29
|
+
l.add sl
|
30
|
+
|
31
|
+
l.level = Foo
|
32
|
+
puts l.foo?
|
33
|
+
l.foo "This is foo"
|
34
|
+
puts l.bar?
|
35
|
+
l.bar "this is bar"
|
36
|
+
puts l.baz?
|
37
|
+
l.baz "this is baz"
|
38
|
+
|
39
|
+
puts "Now change to Baz"
|
40
|
+
|
41
|
+
l.level = Baz
|
42
|
+
puts l.foo?
|
43
|
+
l.foo {"This is foo"}
|
44
|
+
puts l.bar?
|
45
|
+
l.bar {"this is bar"}
|
46
|
+
puts l.baz?
|
47
|
+
l.baz {"this is baz"}
|
data/src/CVS/Entries
ADDED
data/src/CVS/Repository
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
log4r/src
|
data/src/CVS/Root
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
:ext:colbygk@rubyforge.org:/var/cvs/log4r
|
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.
|
6
|
+
# Version:: $Id: log4r.rb,v 1.2 2009/09/22 19:51:46 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,
|
16
|
+
Log4rVersion = [1, 1, 0].join '.'
|
17
17
|
end
|