public
Description: A Ruby web application framework
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/mack.git
Click here to lend your support to: mack and make a donation at www.pledgie.com !
Log colors for the console are now configurable per log level. [#103 
state:resolved]
markbates (author)
Mon Aug 18 12:24:24 -0700 2008
commit  7c790f0be79d372d6e0c8409d539bfa0c830afcd
tree    d8b46c41a23ff5ab207c4cdb209a5792662d5d8f
parent  8410e68e7edfa7d7dbec9b8c34cb58ebdeb76ab7
...
 
1
2
3
...
1
2
3
4
0
@@ -1,3 +1,4 @@
0
+* [#103] Log colors for the console are now configurable per log level.
0
 * [#102] New association method in data_factory
0
 * [#101] Update to file upload testing (build_file -> file_for_upload, and multipart support in put)
0
 * [#100] Inline routing parameters are being mutated
...
1
2
 
3
4
5
6
 
 
7
8
9
...
1
2
3
4
5
6
 
7
8
9
10
11
0
@@ -1,9 +1,11 @@
0
 class Symbol
0
   
0
+  # See Mack::ViewHelpers::FormHelpers date_time_select for more information
0
   def date_time_select(*args)
0
     Thread.current[:view_template].date_time_select(self, *args)
0
   end
0
-
0
+  
0
+  # See Mack::ViewHelpers::FormHelpers date_select for more information
0
   def date_select(*args)
0
     Thread.current[:view_template].date_select(self, *args)
0
   end
...
81
82
83
84
 
85
86
 
 
 
87
88
89
...
81
82
83
 
84
85
 
86
87
88
89
90
91
0
@@ -81,9 +81,11 @@ module Mack
0
         "mack::default_respository_name" => "default",
0
         "mack::testing_framework" => "rspec",
0
         "log::detailed_requests" => true,
0
-        "log::db_color" => "yellow",
0
+        "log::db_color" => "cyan",
0
         "log::error_color" => "red",
0
-        "log::completed_color" => "green",
0
+        "log::fatal_color" => "red",
0
+        "log::warn_color" => "yellow",
0
+        "log::completed_color" => "purple",
0
         "log_level" => "info"
0
       }#.merge(eval("DEFAULTS_#{Mack.env.upcase}"))
0
     end
...
1
2
3
4
 
5
6
7
...
45
46
47
48
49
50
51
 
 
 
 
 
 
 
52
53
54
...
1
2
3
 
4
5
6
7
...
45
46
47
 
 
48
 
49
50
51
52
53
54
55
56
57
58
0
@@ -1,7 +1,7 @@
0
 #--
0
 # Configure logging
0
 #++
0
-
0
+require File.join(File.dirname(__FILE__), "..", "utils", "ansi", "ansi_color")
0
 module Mack
0
   
0
   def self.logger
0
@@ -45,10 +45,14 @@ unless Mack.logger
0
           case data
0
           when /^(DEBUG:|INFO:|WARN:|ERROR:|FATAL:)\s\[.*\]\s(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP)/
0
             old_write(Mack::Utils::Ansi::Color.wrap(app_config.log.db_color, data))
0
-          when /^(ERROR:|FATAL:)/
0
-            old_write(Mack::Utils::Ansi::Color.wrap(app_config.log.error_color, data))
0
           else
0
-            old_write(data)
0
+            level = data.match(/^\w+/).to_s
0
+            color = app_config.log.send("#{level.downcase}_color")
0
+            if color
0
+              old_write(Mack::Utils::Ansi::Color.wrap(color, data))
0
+            else
0
+              old_write(data)
0
+            end
0
           end
0
         end
0
 
...
17
18
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
21
22
...
27
28
29
30
 
31
32
33
...
51
52
53
54
 
55
56
57
 
58
59
60
61
62
63
64
 
 
65
 
 
 
 
66
67
68
...
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
...
44
45
46
 
47
48
49
50
...
68
69
70
 
71
72
73
 
74
75
76
77
78
79
 
 
80
81
82
83
84
85
86
87
88
89
0
@@ -17,6 +17,23 @@ module Mack
0
         MINUTES << [(m < 10 ? "0#{m}" : m), m]
0
       end
0
       
0
+      # This will create a series of select boxes that compromise a time object. By default boxes will be
0
+      # created for day/month/year hour:minute. You can optionally turn on or off any of these boxes, including
0
+      # seconds by setting them to true/false. For example:
0
+      #   <%= date_time_select :some_time, :days => false %>
0
+      # will not produce a select box for days, and so on...
0
+      # 
0
+      # You can pass in an array of arrays to represent the options for any of the boxes like such:
0
+      #   <%= date_time_select :some_time, :day_options => [[1,"one"], [2,"two"]] %>
0
+      # Will produce a day select box with only two options. Alternatively you can pass in an array of values
0
+      # and the options will be done for you. Like such:
0
+      #   <%= date_time_select :some_time, :day_values => 1..60 %>
0
+      # Will produce a day select box with 60 options whose values and keys will be the same.
0
+      # 
0
+      # The separators for dates and times can be set with the date_separator and time_separator options. By
0
+      # default they are:
0
+      #   :date_separator => '/'
0
+      #   :time_separator => ':'
0
       def date_time_select(name, *args)
0
         var = instance_variable_get("@#{name}")
0
         fe = FormElement.new(*args)
0
@@ -27,7 +44,7 @@ module Mack
0
         years = []
0
         (time.year - 5).upto(time.year + 5) { |y| years << [y, y]}
0
         
0
-        options = {:years => true, :months => true, :days => true, :hours => true, :minutes => true, :seconds => false, :year_options => years, :month_options => MONTHS, :day_options => DAYS, :hour_options => HOURS, :minute_options => MINUTES, :second_options => MINUTES}.merge(fe.options)
0
+        options = {:years => true, :months => true, :days => true, :hours => true, :minutes => true, :seconds => false, :year_options => years, :month_options => MONTHS, :day_options => DAYS, :hour_options => HOURS, :minute_options => MINUTES, :second_options => MINUTES, :date_separator => '/', :time_separator => ':'}.merge(fe.options)
0
         
0
         [:year, :month, :day, :hour, :minute, :second].each do |v|
0
           if options["#{v}_values".to_sym]
0
@@ -51,18 +68,22 @@ module Mack
0
         time_boxes << dt_select(:minute, name, fe, time.min, options[:minute_options]) if options[:minutes]
0
         time_boxes << dt_select(:second, name, fe, time.sec, options[:second_options]) if options[:seconds]
0
         
0
-        boxes = date_boxes.join("/")
0
+        boxes = date_boxes.join(options[:date_separator])
0
         
0
         unless time_boxes.empty?
0
-          boxes << " " << time_boxes.join(":")
0
+          boxes << " " << time_boxes.join(options[:time_separator])
0
         end
0
         
0
         return label + boxes
0
       end
0
       
0
-      # Used just like date_time_select, but it has hours, minutes, and seconds turned off.
0
-      # 
0
+      # Used just like date_time_select, but it has hours, minutes, and seconds turned off. See date_time_select
0
+      # for more options.
0
       # 
0
+      #   @user = User.new
0
+      #   <%= :user.date_select :birth_date %>
0
+      #   @some_time = Time.new
0
+      #   <%= :date_select :some_time, :label => true %>
0
       def date_select(name, *args)
0
         fe = FormElement.new(*args)
0
         date_time_select(name, fe.calling_method, {:hours => false, :minutes => false, :seconds => false}.merge(fe.options))

Comments