public
Fork of mojombo/god
Description: Ruby process monitor
Homepage: http://god.rubyforge.org
Clone URL: git://github.com/Bertg/god.git
Search Repo:
flesh out simple logger
mojombo (author)
Wed Feb 20 13:47:30 -0800 2008
commit  ab3489cc21b26461fdd643dd7e0ff8d91bd40984
tree    793e379f5d8e9274af39bc15310947ec0c55c0b5
parent  d56d65969ad3ce610f7dc0789cc6408bd070960f
...
19
20
21
 
22
23
24
...
70
71
72
73
74
75
76
...
19
20
21
22
23
24
25
...
71
72
73
 
74
75
76
0
@@ -19,6 +19,7 @@ end
0
 
0
 # internal requires
0
 require 'god/errors'
0
+require 'god/simple_logger'
0
 require 'god/logger'
0
 require 'god/system/process'
0
 require 'god/dependency_graph'
0
@@ -70,7 +71,6 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. ext god])
0
 
0
 # App wide logging system
0
 LOG = God::Logger.new
0
-LOG.datetime_format = "%Y-%m-%d %H:%M:%S "
0
 
0
 def applog(watch, level, text)
0
   LOG.log(watch, level, text)
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 module God
0
   
0
- class Logger < ::Logger
0
+ class Logger < SimpleLogger
0
     SYSLOG_EQUIVALENTS = {:fatal => :crit,
0
                           :error => :err,
0
                           :warn => :debug,
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
0
@@ -0,0 +1,49 @@
0
+module God
0
+
0
+ class SimpleLogger
0
+ DEBUG = 0
0
+ INFO = 1
0
+ WARN = 2
0
+ ERROR = 3
0
+ FATAL = 4
0
+
0
+ SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL)
0
+
0
+ attr_accessor :datetime_format, :level
0
+
0
+ def initialize(io)
0
+ @io = io
0
+ @level = INFO
0
+ @datetime_format = "%Y-%m-%d %H:%M:%S"
0
+ end
0
+
0
+ def output(level, msg)
0
+ return if level < self.level
0
+
0
+ time = Time.now.strftime(self.datetime_format)
0
+ label = SEV_LABEL[level]
0
+ @io.print("#{label[0..0]} [#{time}] #{label.rjust(5)}: #{msg}\n")
0
+ end
0
+
0
+ def fatal(msg)
0
+ self.output(FATAL, msg)
0
+ end
0
+
0
+ def error(msg)
0
+ self.output(ERROR, msg)
0
+ end
0
+
0
+ def warn(msg)
0
+ self.output(WARN, msg)
0
+ end
0
+
0
+ def info(msg)
0
+ self.output(INFO, msg)
0
+ end
0
+
0
+ def debug(msg)
0
+ self.output(DEBUG, msg)
0
+ end
0
+ end
0
+
0
+end
0
\ No newline at end of file
...
1
 
2
3
4
5
 
6
7
8
...
 
1
2
3
4
 
5
6
7
8
0
@@ -1,8 +1,8 @@
0
-('01'..'40').each do |i|
0
+('01'..'08').each do |i|
0
   God.watch do |w|
0
     w.name = "stress-#{i}"
0
     w.start = "ruby " + File.join(File.dirname(__FILE__), *%w[simple_server.rb])
0
- w.interval = 1
0
+ w.interval = 0
0
     w.grace = 2
0
     w.group = 'test'
0
   

Comments

    No one has commented yet.