win32-autogui 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/HISTORY.markdown +4 -0
- data/VERSION +1 -1
- data/lib/win32/autogui/application.rb +5 -1
- data/lib/win32/autogui/logging.rb +14 -2
- data/spec/auto_gui/logging_spec.rb +11 -2
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/HISTORY.markdown
CHANGED
@@ -6,6 +6,10 @@ Most recent changes are at the top
|
|
6
6
|
Changes
|
7
7
|
-------
|
8
8
|
|
9
|
+
### 0.4.2 - 02/07/2011 ###
|
10
|
+
|
11
|
+
* Add logger.trunc attribute to control log truncation, defaults to true
|
12
|
+
|
9
13
|
### 0.4.1 - 02/03/2011 ###
|
10
14
|
|
11
15
|
* Window.wait_for_close yields if a block is given allowing callbacks during
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
@@ -103,7 +103,7 @@ class Application
|
|
103
103
|
#
|
104
104
|
# @example initialize with logging to file at the default WARN level (STDOUT logging is the default)
|
105
105
|
#
|
106
|
-
# app = Application.new :name => "calc", :logger_logfile => 'log/calc.log'
|
106
|
+
# app = Application.new :name => "calc", :logger_logfile => 'log/calc.log', :logger_trunc => false
|
107
107
|
#
|
108
108
|
# @example initialize with logging to file at DEBUG level
|
109
109
|
#
|
@@ -122,6 +122,7 @@ class Application
|
|
122
122
|
# @option options [Number] :parameters command line parameters used by Process.create
|
123
123
|
# @option options [Number] :create_process_timeout (10) timeout in seconds to wait for the create_process to return
|
124
124
|
# @option options [Number] :main_window_timeout (10) timeout in seconds to wait for main_window to appear
|
125
|
+
# @option options [String] :logger_trunc (true) truncate the logger logfile at logfile initialization
|
125
126
|
# @option options [String] :logger_logfile (nil) initialize logger's output filename
|
126
127
|
# @option options [String] :logger_level (Autogui::Logging::WARN) initialize logger's initial level
|
127
128
|
#
|
@@ -138,6 +139,9 @@ def initialize(options = {})
|
|
138
139
|
@parameters = options[:parameters]
|
139
140
|
|
140
141
|
# logger setup
|
142
|
+
if options.include?(:logger_logfile)
|
143
|
+
logger.trunc = options.include?(:logger_trunc) ? options[:logger_trunc] : true
|
144
|
+
end
|
141
145
|
logger.logfile = options[:logger_logfile] if options[:logger_logfile]
|
142
146
|
logger.level = options[:logger_level] if options[:logger_level]
|
143
147
|
|
@@ -6,23 +6,34 @@
|
|
6
6
|
#
|
7
7
|
# include Autogui::Logging
|
8
8
|
#
|
9
|
+
# logger.trunc = false
|
9
10
|
# logger.filename = 'log/autogui.log'
|
10
11
|
# logger.warn "warning message goes to log file"
|
11
12
|
#
|
12
13
|
module Log4r
|
13
14
|
class Logger
|
14
15
|
|
16
|
+
# @return [Boolean] truncate logfile
|
17
|
+
def trunc
|
18
|
+
@trunc.nil? ? true : @trunc
|
19
|
+
end
|
20
|
+
|
21
|
+
def trunc=(value)
|
22
|
+
raise "Setting trunc has no effect since logfile is already initialized" if @filename
|
23
|
+
@trunc = value
|
24
|
+
end
|
25
|
+
|
15
26
|
# @return [String] filename of the logfile
|
16
27
|
def logfile
|
17
28
|
@filename
|
18
29
|
end
|
19
30
|
|
20
31
|
def logfile=(fn)
|
32
|
+
fn = nil if fn == ''
|
21
33
|
if fn == nil
|
22
|
-
puts "removing log to file"
|
23
34
|
remove(:logfile) if @filename
|
24
35
|
else
|
25
|
-
FileOutputter.new(:logfile, :filename => fn, :trunc =>
|
36
|
+
FileOutputter.new(:logfile, :filename => fn, :trunc => @trunc)
|
26
37
|
Outputter[:logfile].formatter = Log4r::PatternFormatter.new(:pattern => "[%5l %d] %M [%t]")
|
27
38
|
add(:logfile)
|
28
39
|
end
|
@@ -73,6 +84,7 @@ def logger
|
|
73
84
|
# Initialize the logger, defaults to log4r::Warn
|
74
85
|
def init_logger
|
75
86
|
log = Log4r::Logger.new(STANDARD_LOGGER)
|
87
|
+
log.trunc = true
|
76
88
|
|
77
89
|
# sanity checks since we defined log4r's dynamic levels statically
|
78
90
|
unless (Log4r::DEBUG == DEBUG) &&
|
@@ -16,7 +16,7 @@
|
|
16
16
|
@application.close(:wait_for_close => true) if @application.running?
|
17
17
|
@application.should_not be_running
|
18
18
|
end
|
19
|
-
logger.
|
19
|
+
logger.logfile = nil
|
20
20
|
end
|
21
21
|
after(:all) do
|
22
22
|
logger.add(:console)
|
@@ -24,12 +24,19 @@
|
|
24
24
|
|
25
25
|
describe "to file" do
|
26
26
|
|
27
|
-
it "should truncate the log on create" do
|
27
|
+
it "should truncate the log on create by default" do
|
28
28
|
get_file_contents(@logfile).should == 'the quick brown fox'
|
29
29
|
@application = Calculator.new :logger_logfile => fullpath(@logfile)
|
30
30
|
get_file_contents(@logfile).should == ''
|
31
31
|
end
|
32
32
|
|
33
|
+
it "should not truncate the log on create if 'logger.trunc' is false" do
|
34
|
+
get_file_contents(@logfile).should == 'the quick brown fox'
|
35
|
+
@application = Calculator.new :logger_logfile => fullpath(@logfile), :logger_trunc => false
|
36
|
+
logger.trunc.should be_false
|
37
|
+
get_file_contents(@logfile).should == 'the quick brown fox'
|
38
|
+
end
|
39
|
+
|
33
40
|
it "should not log unless 'logger.logfile' is set" do
|
34
41
|
@application = Calculator.new
|
35
42
|
get_file_contents(@logfile).should == 'the quick brown fox'
|
@@ -45,6 +52,7 @@
|
|
45
52
|
|
46
53
|
it "should log warnings" do
|
47
54
|
@application = Calculator.new :logger_logfile => fullpath(@logfile)
|
55
|
+
logger.trunc.should be_true
|
48
56
|
get_file_contents(@logfile).should == ''
|
49
57
|
logger.warn "warning message here"
|
50
58
|
get_file_contents(@logfile).should match(/warning message here/)
|
@@ -64,6 +72,7 @@
|
|
64
72
|
level_save = logger.level
|
65
73
|
begin
|
66
74
|
logger.level = Autogui::Logging::WARN
|
75
|
+
logger.trunc.should be_true
|
67
76
|
get_file_contents(@logfile).should == ''
|
68
77
|
logger.debug "debug message here 1"
|
69
78
|
get_file_contents(@logfile).should_not match(/debug message here 1/)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: win32-autogui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Robert Wahler
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-07 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|