public
Rubygem
Description: JSON Web App Framework
Homepage: http://halcyon.rubyforge.org/
Clone URL: git://github.com/mtodd/halcyon.git
Search Repo:
Click here to lend your support to: halcyon and make a donation at www.pledgie.com !
Finished implementing the Log4r and Logging loggers.
mtodd (author)
Fri Apr 04 15:05:26 -0700 2008
commit  1ac4e4b19dc3be4b25fcf79df14b1721f5aca72c
tree    4b215300b258beb03170c64e80a8a27bbd39ef34
parent  3b89d6794cdc1256081b079afc364254b4487fd2
...
57
58
59
60
 
61
62
63
...
57
58
59
 
60
61
62
63
0
@@ -57,7 +57,7 @@
0
   }
0
   s.requirements << project[:requirements]
0
   s.required_ruby_version = project[:ruby_version_required]
0
- s.files = (project[:rdoc_files] + %w[Rakefile README LICENSE AUTHORS] + Dir["{spec,lib,example,support,clients}/**/*"]).uniq
0
+ s.files = (project[:rdoc_files] + %w[Rakefile README LICENSE AUTHORS] + Dir["{spec,lib,example,support}/**/*"]).uniq
0
 end
0
 
0
 Rake::GemPackageTask.new(spec) do |p|
...
1
 
2
3
4
5
...
6
7
8
9
10
11
 
 
 
 
 
 
 
12
13
14
...
1
2
3
4
5
6
...
7
8
9
 
10
 
11
12
13
14
15
16
17
18
19
20
0
@@ -1,4 +1,5 @@
0
 require 'log4r'
0
+include Log4r
0
 module Halcyon
0
   module Logging
0
     class Log4r < Log4r::Logger
0
0
@@ -6,9 +7,14 @@
0
       class << self
0
         
0
         def setup(config)
0
- raise NotImplementedError
0
           logger = self.new(config[:label] || Halcyon.app)
0
- logger.outputters = Log4r::Outputter.stdout # TODO: Expand this
0
+ if config[:file]
0
+ logger.outputters = Log4r::FileOutputter.new(:filename => config[:file])
0
+ else
0
+ logger.outputters = Log4r::Outputter.stdout
0
+ end
0
+ logger.level = Object.const_get((config[:level] || 'debug').upcase.to_sym)
0
+ logger.outputters[0].formatter = Log4r::PatternFormatter.new(:pattern => "%5l [%d] (#{$$}) #{Halcyon.app} :: %m\n", :date_pattern => "%Y-%m-%d %H:%M:%S")
0
           logger
0
         end
0
         
...
1
2
3
4
 
5
6
7
8
9
10
11
12
 
13
 
14
15
16
...
1
2
3
 
4
5
6
7
8
 
 
 
 
9
10
11
12
13
14
0
@@ -1,16 +1,14 @@
0
 require 'logging'
0
 module Halcyon
0
   module Logging
0
- class Logging < Log4r::Logger
0
+ class Logging < Logging::Logger
0
       
0
       class << self
0
         
0
         def setup(config)
0
- raise NotImplementedError
0
- # TODO: Needs to be expanded to set up the correct params; these will cause errors
0
- logger = config[:logger] || self.logger(config[:file] || STDOUT)
0
- logger.formatter = proc{|s,t,p,m|"%5s [%s] (%s) %s :: %s\n" % [s, t.strftime("%Y-%m-%d %H:%M:%S"), $$, p, m]}
0
+ logger = config[:logger] || ::Logging.logger(config[:file] || STDOUT)
0
           logger.level = config[:level].downcase.to_sym
0
+ logger.instance_variable_get("@appenders")[0].instance_variable_set("@layout", ::Logging::Layouts::Pattern.new(:pattern => "%5l [%d] (%p) #{Halcyon.app} :: %m\n", :date_pattern => "%Y-%m-%d %H:%M:%S"))
0
           logger
0
         end
0
         

Comments

    No one has commented yet.