rbatch 2.1.1 → 2.1.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/README.ja.md +14 -5
- data/README.md +164 -154
- data/bin/rbatch-init +21 -13
- data/doc/RBatch/Cmd.html +300 -316
- data/doc/RBatch/CmdException.html +146 -141
- data/doc/RBatch/CmdResult.html +467 -470
- data/doc/RBatch/Config.html +392 -433
- data/doc/RBatch/Controller.html +374 -0
- data/doc/RBatch/DoubleRunCheckException.html +146 -141
- data/doc/RBatch/DoubleRunChecker.html +258 -256
- data/doc/RBatch/Journal.html +332 -0
- data/doc/RBatch/Log.html +636 -805
- data/doc/RBatch/LogException.html +164 -0
- data/doc/RBatch/RBatch/RBatch/ConfigException.html +164 -0
- data/doc/RBatch/RBatch/RBatch.html +163 -0
- data/doc/RBatch/RBatch/VariablesException.html +164 -0
- data/doc/RBatch/RBatch.html +165 -0
- data/doc/RBatch/RunConf/Exception.html +146 -141
- data/doc/RBatch/RunConf.html +478 -532
- data/doc/RBatch/Variables.html +437 -0
- data/doc/RBatch.html +388 -862
- data/doc/created.rid +11 -9
- data/doc/index.html +178 -184
- data/doc/js/darkfish.js +9 -7
- data/doc/lib/rbatch/cmd_rb.html +46 -44
- data/doc/lib/rbatch/config_rb.html +42 -42
- data/doc/lib/rbatch/controller_rb.html +66 -0
- data/doc/lib/rbatch/double_run_checker_rb.html +42 -42
- data/doc/lib/rbatch/journal_rb.html +52 -0
- data/doc/lib/rbatch/log_rb.html +46 -46
- data/doc/lib/rbatch/run_conf_rb.html +42 -42
- data/doc/lib/rbatch/variables_rb.html +54 -0
- data/doc/lib/rbatch/version_rb.html +38 -38
- data/doc/lib/rbatch_rb.html +40 -52
- data/doc/rdoc.css +365 -308
- data/lib/rbatch/cmd.rb +15 -58
- data/lib/rbatch/config.rb +7 -7
- data/lib/rbatch/controller.rb +37 -61
- data/lib/rbatch/double_run_checker.rb +0 -0
- data/lib/rbatch/journal.rb +40 -0
- data/lib/rbatch/log.rb +71 -129
- data/lib/rbatch/run_conf.rb +13 -24
- data/lib/rbatch/variables.rb +82 -0
- data/lib/rbatch/version.rb +1 -1
- data/lib/rbatch.rb +7 -36
- data/sample/.rbatchrc +41 -7
- data/spec/01_rbach_spec.rb +99 -0
- data/spec/{cmd_spec.rb → rbatch/cmd_spec.rb} +40 -43
- data/spec/rbatch/config_spec.rb +67 -0
- data/spec/rbatch/controller_spec.rb +18 -0
- data/spec/{double_run_checker_spec.rb → rbatch/double_run_checker_spec.rb} +3 -0
- data/spec/rbatch/journal_spec.rb +29 -0
- data/spec/rbatch/log_spec.rb +350 -0
- data/spec/{run_conf_spec.rb → rbatch/run_conf_spec.rb} +13 -5
- data/spec/rbatch/variables_spec.rb +68 -0
- data/spec/spec_helper.rb +4 -5
- metadata +33 -17
- data/lib/rbatch/common_config.rb +0 -0
- data/spec/common_config_spec.rb +0 -85
- data/spec/config_spec.rb +0 -79
- data/spec/log_spec.rb +0 -430
- data/spec/rbatch_spec.rb +0 -22
data/doc/RBatch/Log.html
CHANGED
@@ -1,835 +1,666 @@
|
|
1
|
-
<?xml version="1.0" encoding="
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
-
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
4
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
5
|
<head>
|
6
|
-
|
6
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
7
7
|
|
8
|
-
|
8
|
+
<title>Class: RBatch::Log</title>
|
9
9
|
|
10
|
-
|
10
|
+
<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<script src="../js/quicksearch.js" type="text/javascript"
|
17
|
-
charset="utf-8"></script>
|
18
|
-
<script src="../js/darkfish.js" type="text/javascript"
|
19
|
-
charset="utf-8"></script>
|
12
|
+
<script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
20
16
|
|
21
17
|
</head>
|
22
|
-
<body class="class">
|
18
|
+
<body id="top" class="class">
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
<div id="metadata">
|
21
|
+
<div id="home-metadata">
|
22
|
+
<div id="home-section" class="section">
|
27
23
|
<h3 class="section-header">
|
28
24
|
<a href="../index.html">Home</a>
|
29
25
|
<a href="../index.html#classes">Classes</a>
|
30
26
|
<a href="../index.html#methods">Methods</a>
|
31
27
|
</h3>
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
</
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
</
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
<
|
177
|
-
|
178
|
-
|
179
|
-
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div id="file-metadata">
|
32
|
+
<div id="file-list-section" class="section">
|
33
|
+
<h3 class="section-header">In Files</h3>
|
34
|
+
<div class="section-body">
|
35
|
+
<ul>
|
36
|
+
|
37
|
+
<li><a href="../lib/rbatch/log_rb.html?TB_iframe=true&height=550&width=785"
|
38
|
+
class="thickbox" title="lib/rbatch/log.rb">lib/rbatch/log.rb</a></li>
|
39
|
+
|
40
|
+
</ul>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div id="class-metadata">
|
48
|
+
|
49
|
+
<!-- Parent Class -->
|
50
|
+
<div id="parent-class-section" class="section">
|
51
|
+
<h3 class="section-header">Parent</h3>
|
52
|
+
|
53
|
+
<p class="link">Object</p>
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Method Quickref -->
|
64
|
+
<div id="method-list-section" class="section">
|
65
|
+
<h3 class="section-header">Methods</h3>
|
66
|
+
<ul class="link-list">
|
67
|
+
|
68
|
+
<li><a href="#method-c-def_vars">::def_vars</a></li>
|
69
|
+
|
70
|
+
<li><a href="#method-c-def_vars-3D">::def_vars=</a></li>
|
71
|
+
|
72
|
+
<li><a href="#method-c-journal-3D">::journal=</a></li>
|
73
|
+
|
74
|
+
<li><a href="#method-c-new">::new</a></li>
|
75
|
+
|
76
|
+
<li><a href="#method-i-close">#close</a></li>
|
77
|
+
|
78
|
+
<li><a href="#method-i-debug">#debug</a></li>
|
79
|
+
|
80
|
+
<li><a href="#method-i-delete_old_log">#delete_old_log</a></li>
|
81
|
+
|
82
|
+
<li><a href="#method-i-error">#error</a></li>
|
83
|
+
|
84
|
+
<li><a href="#method-i-fatal">#fatal</a></li>
|
85
|
+
|
86
|
+
<li><a href="#method-i-info">#info</a></li>
|
87
|
+
|
88
|
+
<li><a href="#method-i-journal">#journal</a></li>
|
89
|
+
|
90
|
+
<li><a href="#method-i-warn">#warn</a></li>
|
91
|
+
|
92
|
+
</ul>
|
93
|
+
</div>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
</div>
|
98
|
+
|
99
|
+
<div id="project-metadata">
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<div id="classindex-section" class="section project-section">
|
104
|
+
<h3 class="section-header">Class/Module Index
|
105
|
+
<span class="search-toggle"><img src="../images/find.png"
|
106
|
+
height="16" width="16" alt="[+]"
|
107
|
+
title="show/hide quicksearch" /></span></h3>
|
108
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
109
|
+
<fieldset>
|
110
|
+
<legend>Quicksearch</legend>
|
111
|
+
<input type="text" name="quicksearch" value=""
|
112
|
+
class="quicksearch-field" />
|
113
|
+
</fieldset>
|
114
|
+
</form>
|
115
|
+
|
116
|
+
<ul class="link-list">
|
117
|
+
|
118
|
+
<li><a href="../RBatch.html">RBatch</a></li>
|
119
|
+
|
120
|
+
<li><a href="../RBatch/Cmd.html">RBatch::Cmd</a></li>
|
121
|
+
|
122
|
+
<li><a href="../RBatch/CmdException.html">RBatch::CmdException</a></li>
|
123
|
+
|
124
|
+
<li><a href="../RBatch/CmdResult.html">RBatch::CmdResult</a></li>
|
125
|
+
|
126
|
+
<li><a href="../RBatch/Config.html">RBatch::Config</a></li>
|
127
|
+
|
128
|
+
<li><a href="../RBatch/Controller.html">RBatch::Controller</a></li>
|
129
|
+
|
130
|
+
<li><a href="../RBatch/DoubleRunCheckException.html">RBatch::DoubleRunCheckException</a></li>
|
131
|
+
|
132
|
+
<li><a href="../RBatch/DoubleRunChecker.html">RBatch::DoubleRunChecker</a></li>
|
133
|
+
|
134
|
+
<li><a href="../RBatch/Journal.html">RBatch::Journal</a></li>
|
135
|
+
|
136
|
+
<li><a href="../RBatch/Log.html">RBatch::Log</a></li>
|
137
|
+
|
138
|
+
<li><a href="../RBatch/LogException.html">RBatch::LogException</a></li>
|
139
|
+
|
140
|
+
<li><a href="../RBatch/RBatch.html">RBatch::RBatch</a></li>
|
141
|
+
|
142
|
+
<li><a href="../RBatch/RBatch/RBatch.html">RBatch::RBatch::RBatch</a></li>
|
143
|
+
|
144
|
+
<li><a href="../RBatch/RBatch/RBatch/ConfigException.html">RBatch::RBatch::RBatch::ConfigException</a></li>
|
145
|
+
|
146
|
+
<li><a href="../RBatch/RBatch/VariablesException.html">RBatch::RBatch::VariablesException</a></li>
|
147
|
+
|
148
|
+
<li><a href="../RBatch/RunConf.html">RBatch::RunConf</a></li>
|
149
|
+
|
150
|
+
<li><a href="../RBatch/RunConf/Exception.html">RBatch::RunConf::Exception</a></li>
|
151
|
+
|
152
|
+
<li><a href="../RBatch/Variables.html">RBatch::Variables</a></li>
|
153
|
+
|
154
|
+
</ul>
|
155
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
156
|
+
</div>
|
157
|
+
|
158
|
+
|
159
|
+
</div>
|
160
|
+
</div>
|
161
|
+
|
162
|
+
<div id="documentation">
|
163
|
+
<h1 class="class">RBatch::Log</h1>
|
164
|
+
|
165
|
+
<div id="description" class="description">
|
166
|
+
|
167
|
+
</div><!-- description -->
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
<div id="5Buntitled-5D" class="documentation-section">
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<!-- Methods -->
|
182
|
+
|
183
|
+
<div id="public-class-method-details" class="method-section section">
|
184
|
+
<h3 class="section-header">Public Class Methods</h3>
|
185
|
+
|
186
|
+
|
187
|
+
<div id="def_vars-method" class="method-detail ">
|
188
|
+
<a name="method-c-def_vars"></a>
|
189
|
+
|
190
|
+
|
191
|
+
<div class="method-heading">
|
192
|
+
<span class="method-name">def_vars</span><span
|
193
|
+
class="method-args">()</span>
|
194
|
+
<span class="method-click-advice">click to toggle source</span>
|
195
|
+
</div>
|
196
|
+
|
197
|
+
|
198
|
+
<div class="method-description">
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
<div class="method-source-code" id="def_vars-source">
|
180
205
|
<pre>
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
206
|
+
<span class="ruby-comment"># File lib/rbatch/log.rb, line 37</span>
|
207
|
+
<span class="ruby-keyword">def</span> <span class="ruby-constant">Log</span>.<span class="ruby-identifier">def_vars</span> ; <span class="ruby-identifier">@@def_vars</span> ; <span class="ruby-keyword">end</span></pre>
|
208
|
+
</div><!-- def_vars-source -->
|
209
|
+
|
210
|
+
</div>
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
</div><!-- def_vars-method -->
|
216
|
+
|
217
|
+
|
218
|
+
<div id="def_vars-3D-method" class="method-detail ">
|
219
|
+
<a name="method-c-def_vars-3D"></a>
|
220
|
+
|
221
|
+
|
222
|
+
<div class="method-heading">
|
223
|
+
<span class="method-name">def_vars=</span><span
|
224
|
+
class="method-args">(a)</span>
|
225
|
+
<span class="method-click-advice">click to toggle source</span>
|
226
|
+
</div>
|
227
|
+
|
228
|
+
|
229
|
+
<div class="method-description">
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
<div class="method-source-code" id="def_vars-3D-source">
|
192
236
|
<pre>
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
<div class="method-description">
|
228
|
-
|
229
|
-
<p>
|
230
|
-
Logging Block.
|
231
|
-
</p>
|
232
|
-
<h4>Params</h4>
|
233
|
-
<p>
|
234
|
-
<tt>opt</tt> = Option hash object.
|
235
|
-
</p>
|
236
|
-
<ul>
|
237
|
-
<li><p>
|
238
|
-
<tt>:name</tt> (String) = name of log file. Default is
|
239
|
-
“<date>_<time>_<prog>.log”. Reservation-words are
|
240
|
-
“<date>”,”<time>”,”<prog>”,”<host>”.
|
241
|
-
“<date>” is replaced YYYYMMDD. “<time>” is replaced
|
242
|
-
HHMMSS. “<prog>” is replaced a base-name of program file.
|
243
|
-
</p>
|
244
|
-
</li>
|
245
|
-
<li><p>
|
246
|
-
<tt>:dir</tt> (String) = log direcotry. Default is
|
247
|
-
“${RB_HOME}/log“
|
248
|
-
</p>
|
249
|
-
</li>
|
250
|
-
<li><p>
|
251
|
-
<tt>:level</tt> (String) = log level. Default is “info”.
|
252
|
-
[“debug”|“info”|“warn”|“error”|“fatal”]
|
253
|
-
.
|
254
|
-
</p>
|
255
|
-
</li>
|
256
|
-
<li><p>
|
257
|
-
<tt>:append</tt> (Boolean) = appned to log or not(=overwrite). Default is
|
258
|
-
ture.
|
259
|
-
</p>
|
260
|
-
</li>
|
261
|
-
<li><p>
|
262
|
-
<tt>:stdout</tt> (Boolean) = output both the log file and STDOUT. Default
|
263
|
-
is false.
|
264
|
-
</p>
|
265
|
-
</li>
|
266
|
-
</ul>
|
267
|
-
<h4>Block params</h4>
|
268
|
-
<p>
|
269
|
-
<tt>log</tt> = Instance of <tt>Logger</tt>
|
270
|
-
</p>
|
271
|
-
<h4>Sample</h4>
|
272
|
-
<pre>
|
273
|
-
RBatch::Log.new({:dir => "/tmp", :level => "info"}){ |log|
|
274
|
-
log.info "info string"
|
275
|
-
}</pre>
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
<div class="method-source-code"
|
280
|
-
id="new-source">
|
237
|
+
<span class="ruby-comment"># File lib/rbatch/log.rb, line 33</span>
|
238
|
+
<span class="ruby-keyword">def</span> <span class="ruby-constant">Log</span>.<span class="ruby-identifier">def_vars=</span>(<span class="ruby-identifier">a</span>)
|
239
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"type mismatch: #{a} for #RBatch::Variables"</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">RBatch</span><span class="ruby-operator">::</span><span class="ruby-constant">Variables</span>)
|
240
|
+
<span class="ruby-identifier">@@def_vars</span>=<span class="ruby-identifier">a</span>
|
241
|
+
<span class="ruby-keyword">end</span></pre>
|
242
|
+
</div><!-- def_vars-3D-source -->
|
243
|
+
|
244
|
+
</div>
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
</div><!-- def_vars-3D-method -->
|
250
|
+
|
251
|
+
|
252
|
+
<div id="journal-3D-method" class="method-detail ">
|
253
|
+
<a name="method-c-journal-3D"></a>
|
254
|
+
|
255
|
+
|
256
|
+
<div class="method-heading">
|
257
|
+
<span class="method-name">journal=</span><span
|
258
|
+
class="method-args">(a)</span>
|
259
|
+
<span class="method-click-advice">click to toggle source</span>
|
260
|
+
</div>
|
261
|
+
|
262
|
+
|
263
|
+
<div class="method-description">
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
<div class="method-source-code" id="journal-3D-source">
|
281
270
|
<pre>
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
109: <span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">journal</span> <span class="ruby-value">:error</span>, <span class="ruby-node">"Can not open log file - #{path}"</span>
|
313
|
-
110: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>
|
314
|
-
111: <span class="ruby-keyword kw">end</span>
|
315
|
-
112: <span class="ruby-comment cmt"># set logger option</span>
|
316
|
-
113: <span class="ruby-identifier">formatter</span> = <span class="ruby-identifier">proc</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">severity</span>, <span class="ruby-identifier">datetime</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-identifier">msg</span><span class="ruby-operator">|</span>
|
317
|
-
114: <span class="ruby-identifier">head</span> = <span class="ruby-node">"[#{datetime}] ["</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">sprintf</span>(<span class="ruby-value str">"%-5s"</span>,<span class="ruby-identifier">severity</span>) <span class="ruby-operator">+</span><span class="ruby-value str">"]"</span>
|
318
|
-
115: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">msg</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Exception</span>
|
319
|
-
116: <span class="ruby-node">"#{head} #{msg}\n"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">msg</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-node">" [backtrace] #{s}"</span>}.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">"\n"</span>
|
320
|
-
117: <span class="ruby-keyword kw">else</span>
|
321
|
-
118: <span class="ruby-node">"#{head} #{msg}\n"</span>
|
322
|
-
119: <span class="ruby-keyword kw">end</span>
|
323
|
-
120: <span class="ruby-keyword kw">end</span>
|
324
|
-
121: <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">level</span> = <span class="ruby-identifier">@@log_level_map</span>[<span class="ruby-ivar">@opt</span>[<span class="ruby-value">:log_level</span>]]
|
325
|
-
122: <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">formatter</span> = <span class="ruby-identifier">formatter</span>
|
326
|
-
123: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:log_stdout</span>]
|
327
|
-
124: <span class="ruby-comment cmt"># ccreate Logger instance for STDOUT</span>
|
328
|
-
125: <span class="ruby-ivar">@stdout_log</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">STDOUT</span>)
|
329
|
-
126: <span class="ruby-ivar">@stdout_log</span>.<span class="ruby-identifier">level</span> = <span class="ruby-identifier">@@log_level_map</span>[<span class="ruby-ivar">@opt</span>[<span class="ruby-value">:log_level</span>]]
|
330
|
-
127: <span class="ruby-ivar">@stdout_log</span>.<span class="ruby-identifier">formatter</span> = <span class="ruby-identifier">formatter</span>
|
331
|
-
128: <span class="ruby-keyword kw">end</span>
|
332
|
-
129: <span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">journal</span> <span class="ruby-value">:info</span>,<span class="ruby-node">"Start Logging: \"#{path}\""</span>
|
333
|
-
130: <span class="ruby-comment cmt"># delete old log</span>
|
334
|
-
131: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">delete_old_log</span>(<span class="ruby-ivar">@opt</span>[<span class="ruby-value">:log_delete_old_log_date</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:log_delete_old_log</span>]
|
335
|
-
132: <span class="ruby-comment cmt"># Firstly write journal to log</span>
|
336
|
-
133: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">run_conf</span>[<span class="ruby-value">:mix_rbatch_msg_to_log</span>]
|
337
|
-
134: <span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">journals</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">str</span><span class="ruby-operator">|</span>
|
338
|
-
135: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">journal</span>(<span class="ruby-identifier">str</span>)
|
339
|
-
136: <span class="ruby-keyword kw">end</span>
|
340
|
-
137: <span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">add_log</span>(<span class="ruby-keyword kw">self</span>)
|
341
|
-
138: <span class="ruby-keyword kw">end</span>
|
342
|
-
139: <span class="ruby-comment cmt"># Start logging</span>
|
343
|
-
140: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
344
|
-
141: <span class="ruby-keyword kw">begin</span>
|
345
|
-
142: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span>
|
346
|
-
143: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
347
|
-
144: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fatal</span>(<span class="ruby-identifier">e</span>)
|
348
|
-
145: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fatal</span>(<span class="ruby-value str">"Caught exception. Exit 1"</span>)
|
349
|
-
146: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
|
350
|
-
147: <span class="ruby-keyword kw">ensure</span>
|
351
|
-
148: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">close</span>
|
352
|
-
149: <span class="ruby-keyword kw">end</span>
|
353
|
-
150: <span class="ruby-keyword kw">end</span>
|
354
|
-
151: <span class="ruby-keyword kw">end</span></pre>
|
355
|
-
</div>
|
356
|
-
|
357
|
-
</div>
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
</div>
|
363
|
-
|
364
|
-
|
365
|
-
<div id="verbose-method" class="method-detail ">
|
366
|
-
<a name="method-c-verbose"></a>
|
367
|
-
|
368
|
-
<div class="method-heading">
|
369
|
-
|
370
|
-
<span class="method-name">verbose</span><span
|
371
|
-
class="method-args">()</span>
|
372
|
-
<span class="method-click-advice">click to toggle source</span>
|
373
|
-
|
374
|
-
</div>
|
375
|
-
|
376
|
-
<div class="method-description">
|
377
|
-
|
378
|
-
<p>
|
379
|
-
Get verbose mode flag.
|
380
|
-
</p>
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
<div class="method-source-code"
|
385
|
-
id="verbose-source">
|
271
|
+
<span class="ruby-comment"># File lib/rbatch/log.rb, line 39</span>
|
272
|
+
<span class="ruby-keyword">def</span> <span class="ruby-constant">Log</span>.<span class="ruby-identifier">journal=</span>(<span class="ruby-identifier">a</span>) ; <span class="ruby-identifier">@@journal</span>=<span class="ruby-identifier">a</span> ; <span class="ruby-keyword">end</span></pre>
|
273
|
+
</div><!-- journal-3D-source -->
|
274
|
+
|
275
|
+
</div>
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
</div><!-- journal-3D-method -->
|
281
|
+
|
282
|
+
|
283
|
+
<div id="new-method" class="method-detail ">
|
284
|
+
<a name="method-c-new"></a>
|
285
|
+
|
286
|
+
|
287
|
+
<div class="method-heading">
|
288
|
+
<span class="method-name">new</span><span
|
289
|
+
class="method-args">(opt=nil)</span>
|
290
|
+
<span class="method-click-advice">click to toggle source</span>
|
291
|
+
</div>
|
292
|
+
|
293
|
+
|
294
|
+
<div class="method-description">
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
<div class="method-source-code" id="new-source">
|
386
301
|
<pre>
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
</
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
302
|
+
<span class="ruby-comment"># File lib/rbatch/log.rb, line 46</span>
|
303
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">opt</span>=<span class="ruby-keyword">nil</span>)
|
304
|
+
<span class="ruby-ivar">@opt</span> = <span class="ruby-identifier">opt</span>
|
305
|
+
<span class="ruby-ivar">@vars</span> = <span class="ruby-identifier">@@def_vars</span>.<span class="ruby-identifier">clone</span>
|
306
|
+
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">nil?</span>
|
307
|
+
<span class="ruby-comment"># change opt key from "hoge" to "log_hoge"</span>
|
308
|
+
<span class="ruby-identifier">tmp</span> = {}
|
309
|
+
<span class="ruby-identifier">opt</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
310
|
+
<span class="ruby-identifier">tmp</span>[(<span class="ruby-string">"log_"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">opt</span>[<span class="ruby-identifier">key</span>]
|
311
|
+
<span class="ruby-keyword">end</span>
|
312
|
+
<span class="ruby-ivar">@vars</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">tmp</span>)
|
313
|
+
<span class="ruby-keyword">end</span>
|
314
|
+
<span class="ruby-ivar">@path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_dir</span>],<span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_name</span>])
|
315
|
+
<span class="ruby-comment"># create Logger instance</span>
|
316
|
+
<span class="ruby-keyword">begin</span>
|
317
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_append</span>] <span class="ruby-operator">&&</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-ivar">@path</span>)
|
318
|
+
<span class="ruby-ivar">@log</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">open</span>(<span class="ruby-ivar">@path</span>,<span class="ruby-string">"a"</span>))
|
319
|
+
<span class="ruby-keyword">else</span>
|
320
|
+
<span class="ruby-ivar">@log</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">open</span>(<span class="ruby-ivar">@path</span>,<span class="ruby-string">"w"</span>))
|
321
|
+
<span class="ruby-keyword">end</span>
|
322
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
323
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">LogException</span>,<span class="ruby-node">"Can not open log file - #{@path}"</span>
|
324
|
+
<span class="ruby-keyword">end</span>
|
325
|
+
<span class="ruby-comment"># set logger option</span>
|
326
|
+
<span class="ruby-ivar">@log</span>.<span class="ruby-identifier">level</span> = <span class="ruby-identifier">@@LOG_LEVEL_MAP</span>[<span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_level</span>]]
|
327
|
+
<span class="ruby-ivar">@log</span>.<span class="ruby-identifier">formatter</span> = <span class="ruby-identifier">@@FORMATTER</span>
|
328
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_stdout</span>]
|
329
|
+
<span class="ruby-comment"># ccreate Logger instance for STDOUT</span>
|
330
|
+
<span class="ruby-ivar">@stdout_log</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">STDOUT</span>)
|
331
|
+
<span class="ruby-ivar">@stdout_log</span>.<span class="ruby-identifier">level</span> = <span class="ruby-identifier">@@LOG_LEVEL_MAP</span>[<span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_level</span>]]
|
332
|
+
<span class="ruby-ivar">@stdout_log</span>.<span class="ruby-identifier">formatter</span> = <span class="ruby-identifier">@@STDOUT_FORMATTER</span>
|
333
|
+
<span class="ruby-keyword">end</span>
|
334
|
+
<span class="ruby-comment"># delete old log</span>
|
335
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">delete_old_log</span>(<span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_delete_old_log_date</span>]) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_delete_old_log</span>]
|
336
|
+
<span class="ruby-comment"># Start logging</span>
|
337
|
+
<span class="ruby-identifier">@@journal</span>.<span class="ruby-identifier">put</span> <span class="ruby-value">1</span>,<span class="ruby-node">"Logging Start: \"#{@path}\""</span>
|
338
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
|
339
|
+
<span class="ruby-keyword">begin</span>
|
340
|
+
<span class="ruby-keyword">yield</span> <span class="ruby-keyword">self</span>
|
341
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
342
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">fatal</span>(<span class="ruby-identifier">e</span>)
|
343
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">fatal</span>(<span class="ruby-string">"Caught exception. Exit 1"</span>)
|
344
|
+
<span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
|
345
|
+
<span class="ruby-keyword">ensure</span>
|
346
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">close</span>
|
347
|
+
<span class="ruby-keyword">end</span>
|
348
|
+
<span class="ruby-keyword">end</span>
|
349
|
+
<span class="ruby-keyword">end</span></pre>
|
350
|
+
</div><!-- new-source -->
|
351
|
+
|
352
|
+
</div>
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
</div><!-- new-method -->
|
358
|
+
|
359
|
+
|
360
|
+
</div><!-- public-class-method-details -->
|
361
|
+
|
362
|
+
<div id="public-instance-method-details" class="method-section section">
|
363
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
364
|
+
|
365
|
+
|
366
|
+
<div id="close-method" class="method-detail ">
|
367
|
+
<a name="method-i-close"></a>
|
368
|
+
|
369
|
+
|
370
|
+
<div class="method-heading">
|
371
|
+
<span class="method-name">close</span><span
|
372
|
+
class="method-args">()</span>
|
373
|
+
<span class="method-click-advice">click to toggle source</span>
|
374
|
+
</div>
|
375
|
+
|
376
|
+
|
377
|
+
<div class="method-description">
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
<div class="method-source-code" id="close-source">
|
420
384
|
<pre>
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
<div class="method-source-code"
|
457
|
-
id="close-source">
|
385
|
+
<span class="ruby-comment"># File lib/rbatch/log.rb, line 125</span>
|
386
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">close</span>
|
387
|
+
<span class="ruby-ivar">@stdout_log</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_stdout</span>]
|
388
|
+
<span class="ruby-ivar">@log</span>.<span class="ruby-identifier">close</span>
|
389
|
+
<span class="ruby-keyword">end</span></pre>
|
390
|
+
</div><!-- close-source -->
|
391
|
+
|
392
|
+
</div>
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
</div><!-- close-method -->
|
398
|
+
|
399
|
+
|
400
|
+
<div id="debug-method" class="method-detail ">
|
401
|
+
<a name="method-i-debug"></a>
|
402
|
+
|
403
|
+
|
404
|
+
<div class="method-heading">
|
405
|
+
<span class="method-name">debug</span><span
|
406
|
+
class="method-args">(a)</span>
|
407
|
+
<span class="method-click-advice">click to toggle source</span>
|
408
|
+
</div>
|
409
|
+
|
410
|
+
|
411
|
+
<div class="method-description">
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
<div class="method-source-code" id="debug-source">
|
458
418
|
<pre>
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
<div class="method-source-code"
|
492
|
-
id="debug-source">
|
493
|
-
<pre>
|
494
|
-
<span class="ruby-comment cmt"># File lib/rbatch/log.rb, line 175</span>
|
495
|
-
175: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug</span>(<span class="ruby-identifier">a</span>)
|
496
|
-
176: <span class="ruby-ivar">@stdout_log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-identifier">a</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:log_stdout</span>]
|
497
|
-
177: <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-identifier">a</span>)
|
498
|
-
178: <span class="ruby-keyword kw">end</span></pre>
|
499
|
-
</div>
|
500
|
-
|
501
|
-
</div>
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
</div>
|
507
|
-
|
508
|
-
|
509
|
-
<div id="delete-old-log-method" class="method-detail ">
|
510
|
-
<a name="method-i-delete_old_log"></a>
|
511
|
-
|
512
|
-
<div class="method-heading">
|
513
|
-
|
514
|
-
<span class="method-name">delete_old_log</span><span
|
515
|
-
class="method-args">(date = 7)</span>
|
516
|
-
<span class="method-click-advice">click to toggle source</span>
|
517
|
-
|
518
|
-
</div>
|
519
|
-
|
520
|
-
<div class="method-description">
|
521
|
-
|
522
|
-
<p>
|
523
|
-
Delete old log files. If @opt[:log_name] is not include
|
524
|
-
“<date>”, then do nothing.
|
525
|
-
</p>
|
419
|
+
<span class="ruby-comment"># File lib/rbatch/log.rb, line 116</span>
|
420
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">debug</span>(<span class="ruby-identifier">a</span>)
|
421
|
+
<span class="ruby-ivar">@stdout_log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-identifier">a</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_stdout</span>]
|
422
|
+
<span class="ruby-ivar">@log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-identifier">a</span>)
|
423
|
+
<span class="ruby-keyword">end</span></pre>
|
424
|
+
</div><!-- debug-source -->
|
425
|
+
|
426
|
+
</div>
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
</div><!-- debug-method -->
|
432
|
+
|
433
|
+
|
434
|
+
<div id="delete_old_log-method" class="method-detail ">
|
435
|
+
<a name="method-i-delete_old_log"></a>
|
436
|
+
|
437
|
+
|
438
|
+
<div class="method-heading">
|
439
|
+
<span class="method-name">delete_old_log</span><span
|
440
|
+
class="method-args">(date = 7)</span>
|
441
|
+
<span class="method-click-advice">click to toggle source</span>
|
442
|
+
</div>
|
443
|
+
|
444
|
+
|
445
|
+
<div class="method-description">
|
446
|
+
|
447
|
+
<p>Delete old log files. If @<a href="http://:log_name">vars</a> is not
|
448
|
+
include “<date>”, then do nothing.</p>
|
449
|
+
|
526
450
|
<h4>Params</h4>
|
527
|
-
<ul>
|
528
|
-
<
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
<div class="method-source-code"
|
537
|
-
id="delete-old-log-source">
|
538
|
-
<pre>
|
539
|
-
<span class="ruby-comment cmt"># File lib/rbatch/log.rb, line 195</span>
|
540
|
-
195: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_old_log</span>(<span class="ruby-identifier">date</span> = <span class="ruby-value">7</span>)
|
541
|
-
196: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-ivar">@log_dir</span>) <span class="ruby-operator">&&</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:log_name</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-value str">"<date>"</span>)
|
542
|
-
197: <span class="ruby-constant">Dir</span><span class="ruby-operator">::</span><span class="ruby-identifier">foreach</span>(<span class="ruby-ivar">@log_dir</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
|
543
|
-
198: <span class="ruby-identifier">r</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"^"</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:log_name</span>].<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">"<prog>"</span>,<span class="ruby-ivar">@prog_base</span>) .<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">"<time>"</span>,<span class="ruby-value str">"[0-2][0-9][0-5][0-9][0-5][0-9]"</span>) .<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">"<date>"</span>,<span class="ruby-value str">"([0-9][0-9][0-9][0-9][0-1][0-9][0-3][0-9])"</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">"$"</span>)
|
544
|
-
199: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">&&</span> <span class="ruby-constant">Date</span>.<span class="ruby-identifier">strptime</span>(<span class="ruby-node">$1</span>,<span class="ruby-value str">"%Y%m%d"</span>) <span class="ruby-operator"><=</span> <span class="ruby-constant">Date</span>.<span class="ruby-identifier">today</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">date</span>
|
545
|
-
200: <span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">journal</span> <span class="ruby-value">:info</span>, <span class="ruby-value str">"Delete old log file: "</span> <span class="ruby-operator">+</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@log_dir</span> , <span class="ruby-identifier">file</span>)
|
546
|
-
201: <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-identifier">delete</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@log_dir</span> , <span class="ruby-identifier">file</span>))
|
547
|
-
202: <span class="ruby-keyword kw">end</span>
|
548
|
-
203: <span class="ruby-keyword kw">end</span>
|
549
|
-
204: <span class="ruby-keyword kw">end</span>
|
550
|
-
205: <span class="ruby-keyword kw">end</span></pre>
|
551
|
-
</div>
|
552
|
-
|
553
|
-
</div>
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
</div>
|
559
|
-
|
560
|
-
|
561
|
-
<div id="error-method" class="method-detail ">
|
562
|
-
<a name="method-i-error"></a>
|
563
|
-
|
564
|
-
<div class="method-heading">
|
565
|
-
|
566
|
-
<span class="method-name">error</span><span
|
567
|
-
class="method-args">(a)</span>
|
568
|
-
<span class="method-click-advice">click to toggle source</span>
|
569
|
-
|
570
|
-
</div>
|
571
|
-
|
572
|
-
<div class="method-description">
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
<div class="method-source-code"
|
579
|
-
id="error-source">
|
580
|
-
<pre>
|
581
|
-
<span class="ruby-comment cmt"># File lib/rbatch/log.rb, line 159</span>
|
582
|
-
159: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">error</span>(<span class="ruby-identifier">a</span>)
|
583
|
-
160: <span class="ruby-ivar">@stdout_log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-identifier">a</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:log_stdout</span>]
|
584
|
-
161: <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-identifier">a</span>)
|
585
|
-
162: <span class="ruby-identifier">send_mail</span>(<span class="ruby-identifier">a</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:log_send_mail</span>]
|
586
|
-
163: <span class="ruby-keyword kw">end</span></pre>
|
587
|
-
</div>
|
588
|
-
|
589
|
-
</div>
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
</div>
|
595
|
-
|
596
|
-
|
597
|
-
<div id="fatal-method" class="method-detail ">
|
598
|
-
<a name="method-i-fatal"></a>
|
599
|
-
|
600
|
-
<div class="method-heading">
|
601
|
-
|
602
|
-
<span class="method-name">fatal</span><span
|
603
|
-
class="method-args">(a)</span>
|
604
|
-
<span class="method-click-advice">click to toggle source</span>
|
605
|
-
|
606
|
-
</div>
|
607
|
-
|
608
|
-
<div class="method-description">
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
<div class="method-source-code"
|
615
|
-
id="fatal-source">
|
451
|
+
<ul><li>
|
452
|
+
<p><tt>date</tt> (Integer): The day of leaving log files</p>
|
453
|
+
</li></ul>
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
<div class="method-source-code" id="delete_old_log-source">
|
616
458
|
<pre>
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
459
|
+
<span class="ruby-comment"># File lib/rbatch/log.rb, line 136</span>
|
460
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">delete_old_log</span>(<span class="ruby-identifier">date</span> = <span class="ruby-value">7</span>)
|
461
|
+
<span class="ruby-keyword">if</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_dir</span>]) <span class="ruby-operator">&&</span> <span class="ruby-ivar">@vars</span>.<span class="ruby-identifier">raw_value</span>(<span class="ruby-value">:log_name</span>).<span class="ruby-identifier">include?</span>(<span class="ruby-string">"<date>"</span>)
|
462
|
+
<span class="ruby-constant">Dir</span><span class="ruby-operator">::</span><span class="ruby-identifier">foreach</span>(<span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_dir</span>]) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
|
463
|
+
<span class="ruby-identifier">r</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">"^"</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@vars</span>.<span class="ruby-identifier">raw_value</span>(<span class="ruby-value">:log_name</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-string">"<prog>"</span>,<span class="ruby-ivar">@vars</span>[<span class="ruby-value">:program_base</span>]) .<span class="ruby-identifier">gsub</span>(<span class="ruby-string">"<time>"</span>,<span class="ruby-string">"[0-2][0-9][0-5][0-9][0-5][0-9]"</span>) .<span class="ruby-identifier">gsub</span>(<span class="ruby-string">"<date>"</span>,<span class="ruby-string">"([0-9][0-9][0-9][0-9][0-1][0-9][0-3][0-9])"</span>) <span class="ruby-operator">+</span> <span class="ruby-string">"$"</span>)
|
464
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">r</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">&&</span> <span class="ruby-constant">Date</span>.<span class="ruby-identifier">strptime</span>(<span class="ruby-node">$1</span>,<span class="ruby-string">"%Y%m%d"</span>) <span class="ruby-operator"><=</span> <span class="ruby-constant">Date</span>.<span class="ruby-identifier">today</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">date</span>
|
465
|
+
<span class="ruby-identifier">@@journal</span>.<span class="ruby-identifier">put</span> <span class="ruby-value">1</span>, <span class="ruby-string">"Delete old log file: "</span> <span class="ruby-operator">+</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_dir</span>] , <span class="ruby-identifier">file</span>)
|
466
|
+
<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-identifier">delete</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_dir</span>] , <span class="ruby-identifier">file</span>))
|
467
|
+
<span class="ruby-keyword">end</span>
|
468
|
+
<span class="ruby-keyword">end</span>
|
469
|
+
<span class="ruby-keyword">end</span>
|
470
|
+
<span class="ruby-keyword">end</span></pre>
|
471
|
+
</div><!-- delete_old_log-source -->
|
472
|
+
|
473
|
+
</div>
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
</div><!-- delete_old_log-method -->
|
479
|
+
|
480
|
+
|
481
|
+
<div id="error-method" class="method-detail ">
|
482
|
+
<a name="method-i-error"></a>
|
483
|
+
|
484
|
+
|
485
|
+
<div class="method-heading">
|
486
|
+
<span class="method-name">error</span><span
|
487
|
+
class="method-args">(a)</span>
|
488
|
+
<span class="method-click-advice">click to toggle source</span>
|
489
|
+
</div>
|
490
|
+
|
491
|
+
|
492
|
+
<div class="method-description">
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
<div class="method-source-code" id="error-source">
|
652
499
|
<pre>
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
500
|
+
<span class="ruby-comment"># File lib/rbatch/log.rb, line 100</span>
|
501
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">error</span>(<span class="ruby-identifier">a</span>)
|
502
|
+
<span class="ruby-ivar">@stdout_log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-identifier">a</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_stdout</span>]
|
503
|
+
<span class="ruby-ivar">@log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-identifier">a</span>)
|
504
|
+
<span class="ruby-identifier">send_mail</span>(<span class="ruby-identifier">a</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_send_mail</span>]
|
505
|
+
<span class="ruby-keyword">end</span></pre>
|
506
|
+
</div><!-- error-source -->
|
507
|
+
|
508
|
+
</div>
|
509
|
+
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
</div><!-- error-method -->
|
514
|
+
|
515
|
+
|
516
|
+
<div id="fatal-method" class="method-detail ">
|
517
|
+
<a name="method-i-fatal"></a>
|
518
|
+
|
519
|
+
|
520
|
+
<div class="method-heading">
|
521
|
+
<span class="method-name">fatal</span><span
|
522
|
+
class="method-args">(a)</span>
|
523
|
+
<span class="method-click-advice">click to toggle source</span>
|
524
|
+
</div>
|
525
|
+
|
526
|
+
|
527
|
+
<div class="method-description">
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
<div class="method-source-code" id="fatal-source">
|
687
534
|
<pre>
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
id="opt-source">
|
535
|
+
<span class="ruby-comment"># File lib/rbatch/log.rb, line 94</span>
|
536
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fatal</span>(<span class="ruby-identifier">a</span>)
|
537
|
+
<span class="ruby-ivar">@stdout_log</span>.<span class="ruby-identifier">fatal</span>(<span class="ruby-identifier">a</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_stdout</span>]
|
538
|
+
<span class="ruby-ivar">@log</span>.<span class="ruby-identifier">fatal</span>(<span class="ruby-identifier">a</span>)
|
539
|
+
<span class="ruby-identifier">send_mail</span>(<span class="ruby-identifier">a</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_send_mail</span>]
|
540
|
+
<span class="ruby-keyword">end</span></pre>
|
541
|
+
</div><!-- fatal-source -->
|
542
|
+
|
543
|
+
</div>
|
544
|
+
|
545
|
+
|
546
|
+
|
547
|
+
|
548
|
+
</div><!-- fatal-method -->
|
549
|
+
|
550
|
+
|
551
|
+
<div id="info-method" class="method-detail ">
|
552
|
+
<a name="method-i-info"></a>
|
553
|
+
|
554
|
+
|
555
|
+
<div class="method-heading">
|
556
|
+
<span class="method-name">info</span><span
|
557
|
+
class="method-args">(a)</span>
|
558
|
+
<span class="method-click-advice">click to toggle source</span>
|
559
|
+
</div>
|
560
|
+
|
561
|
+
|
562
|
+
<div class="method-description">
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
<div class="method-source-code" id="info-source">
|
723
569
|
<pre>
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
570
|
+
<span class="ruby-comment"># File lib/rbatch/log.rb, line 111</span>
|
571
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">info</span>(<span class="ruby-identifier">a</span>)
|
572
|
+
<span class="ruby-ivar">@stdout_log</span>.<span class="ruby-identifier">info</span>(<span class="ruby-identifier">a</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_stdout</span>]
|
573
|
+
<span class="ruby-ivar">@log</span>.<span class="ruby-identifier">info</span>(<span class="ruby-identifier">a</span>)
|
574
|
+
<span class="ruby-keyword">end</span></pre>
|
575
|
+
</div><!-- info-source -->
|
576
|
+
|
577
|
+
</div>
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
|
582
|
+
</div><!-- info-method -->
|
583
|
+
|
584
|
+
|
585
|
+
<div id="journal-method" class="method-detail ">
|
586
|
+
<a name="method-i-journal"></a>
|
587
|
+
|
588
|
+
|
589
|
+
<div class="method-heading">
|
590
|
+
<span class="method-name">journal</span><span
|
591
|
+
class="method-args">(a)</span>
|
592
|
+
<span class="method-click-advice">click to toggle source</span>
|
593
|
+
</div>
|
594
|
+
|
595
|
+
|
596
|
+
<div class="method-description">
|
597
|
+
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
|
602
|
+
<div class="method-source-code" id="journal-source">
|
755
603
|
<pre>
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
<div class="method-description">
|
789
|
-
|
790
|
-
<p>
|
791
|
-
send mail
|
792
|
-
</p>
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
<div class="method-source-code"
|
797
|
-
id="send-mail-source">
|
604
|
+
<span class="ruby-comment"># File lib/rbatch/log.rb, line 121</span>
|
605
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">journal</span>(<span class="ruby-identifier">a</span>)
|
606
|
+
<span class="ruby-ivar">@log</span>.<span class="ruby-identifier">info</span>(<span class="ruby-identifier">a</span>)
|
607
|
+
<span class="ruby-keyword">end</span></pre>
|
608
|
+
</div><!-- journal-source -->
|
609
|
+
|
610
|
+
</div>
|
611
|
+
|
612
|
+
|
613
|
+
|
614
|
+
|
615
|
+
</div><!-- journal-method -->
|
616
|
+
|
617
|
+
|
618
|
+
<div id="warn-method" class="method-detail ">
|
619
|
+
<a name="method-i-warn"></a>
|
620
|
+
|
621
|
+
|
622
|
+
<div class="method-heading">
|
623
|
+
<span class="method-name">warn</span><span
|
624
|
+
class="method-args">(a)</span>
|
625
|
+
<span class="method-click-advice">click to toggle source</span>
|
626
|
+
</div>
|
627
|
+
|
628
|
+
|
629
|
+
<div class="method-description">
|
630
|
+
|
631
|
+
|
632
|
+
|
633
|
+
|
634
|
+
|
635
|
+
<div class="method-source-code" id="warn-source">
|
798
636
|
<pre>
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
</div>
|
827
|
-
|
828
|
-
<div id="validator-badges">
|
829
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
830
|
-
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
831
|
-
Rdoc Generator</a> 1.1.6</small>.</p>
|
832
|
-
</div>
|
637
|
+
<span class="ruby-comment"># File lib/rbatch/log.rb, line 106</span>
|
638
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">warn</span>(<span class="ruby-identifier">a</span>)
|
639
|
+
<span class="ruby-ivar">@stdout_log</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-identifier">a</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:log_stdout</span>]
|
640
|
+
<span class="ruby-ivar">@log</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-identifier">a</span>)
|
641
|
+
<span class="ruby-keyword">end</span></pre>
|
642
|
+
</div><!-- warn-source -->
|
643
|
+
|
644
|
+
</div>
|
645
|
+
|
646
|
+
|
647
|
+
|
648
|
+
|
649
|
+
</div><!-- warn-method -->
|
650
|
+
|
651
|
+
|
652
|
+
</div><!-- public-instance-method-details -->
|
653
|
+
|
654
|
+
</div><!-- 5Buntitled-5D -->
|
655
|
+
|
656
|
+
|
657
|
+
</div><!-- documentation -->
|
658
|
+
|
659
|
+
<div id="validator-badges">
|
660
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
661
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
662
|
+
Rdoc Generator</a> 2</small>.</p>
|
663
|
+
</div>
|
833
664
|
|
834
665
|
</body>
|
835
666
|
</html>
|