GunnyLog 1.1.1 → 1.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.
- checksums.yaml +4 -4
- data/lib/GunnyLog.rb +39 -35
- data/lib/GunnyLog/severity.rb +9 -0
- metadata +4 -4
- data/lib/GunnyLog/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17368c22fc5f1279827159a0bd99a59317478731
|
4
|
+
data.tar.gz: 57093350601cdf4c1b5418ae22a2a5c05bcab9e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 357dbb6aedd7b7da3ba74c76b46d05ff265edad2ecb78dfb7d95d0744e3ed536b4f9ff2d4b8a49e3818d4156ccddd39557613dcbd5e2bd771b842cf02e5c74d2
|
7
|
+
data.tar.gz: 5e8dd8e0dfa99761efc21d54dcd4c6c81296269a366d76531a0b5ca17ff3968d7d8e5906a5c245c1769c739b5706573d0c84761fa9bdd682851b0fe30faea0ce
|
data/lib/GunnyLog.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# GunnyLog class
|
2
|
-
require 'GunnyLog/version'
|
3
2
|
require 'GunnyLog/exceptions'
|
3
|
+
require 'GunnyLog/severity'
|
4
4
|
require 'singleton'
|
5
5
|
require 'date'
|
6
6
|
|
@@ -13,41 +13,31 @@ class GunnyLog
|
|
13
13
|
|
14
14
|
include Singleton
|
15
15
|
|
16
|
-
|
16
|
+
private
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
VERSION = '1.1.2'
|
19
|
+
DEBUG_FLAG = false
|
20
|
+
|
21
|
+
# public class attributes
|
22
|
+
public
|
23
23
|
|
24
24
|
# @return [bool] is logging enabled
|
25
25
|
attr_reader :logging_enabled
|
26
26
|
|
27
|
-
class << self;
|
28
|
-
# The location that the message was from
|
29
|
-
private
|
30
|
-
attr_accessor :message_location
|
31
|
-
end
|
32
|
-
|
33
27
|
# @return [string] message location
|
34
28
|
attr_reader :message_location
|
35
29
|
|
36
30
|
# private class attributes
|
31
|
+
private
|
37
32
|
|
38
|
-
|
39
|
-
|
40
|
-
private
|
41
|
-
attr_accessor :file_open
|
42
|
-
end
|
33
|
+
# Is file open flag
|
34
|
+
attr_accessor :file_open
|
43
35
|
|
44
|
-
|
45
|
-
|
46
|
-
private
|
47
|
-
attr_accessor :logging_file
|
48
|
-
end
|
36
|
+
# File used for the log file
|
37
|
+
attr_accessor :logging_file
|
49
38
|
|
50
39
|
# public instance methods
|
40
|
+
public
|
51
41
|
|
52
42
|
# Set logging on and off
|
53
43
|
# @param flag [bool] switch for on or off
|
@@ -59,7 +49,7 @@ class GunnyLog
|
|
59
49
|
# @deprecated Use {#set_logging_enabled} instead
|
60
50
|
# @param flag [bool] switch for on or off
|
61
51
|
def set_switch(flag)
|
62
|
-
|
52
|
+
@logging_enabled = flag
|
63
53
|
end
|
64
54
|
|
65
55
|
# Set message was logged from message_location
|
@@ -200,9 +190,12 @@ class GunnyLog
|
|
200
190
|
# private instance methods
|
201
191
|
private
|
202
192
|
|
203
|
-
#
|
193
|
+
# initialize
|
204
194
|
def initialize
|
195
|
+
local_debug('initialize')
|
205
196
|
@logging_enabled = true
|
197
|
+
@logging_severity = GunnyLogSeverity::DEBUG
|
198
|
+
local_debug('initialize', sprintf('Log level = %d',@logging_severity) )
|
206
199
|
@message_location = 'MainMethod'
|
207
200
|
@file_open = false
|
208
201
|
@logging_file = STDOUT
|
@@ -210,20 +203,20 @@ class GunnyLog
|
|
210
203
|
|
211
204
|
# write the msg
|
212
205
|
def write_msg(output, loc, msg)
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
206
|
+
if loc == nil
|
207
|
+
loc = @message_location
|
208
|
+
else
|
209
|
+
@message_location = loc
|
210
|
+
end
|
211
|
+
if @logging_enabled
|
212
|
+
output.puts "#{date_str}|#{$0}|#{loc}|#{msg}"
|
213
|
+
end
|
221
214
|
end
|
222
215
|
|
223
216
|
# get the date time stamp
|
224
217
|
def date_str
|
225
|
-
|
226
|
-
|
218
|
+
d = DateTime.now
|
219
|
+
d.strftime('%m/%d/%Y|%I:%M:%S%p')
|
227
220
|
end
|
228
221
|
|
229
222
|
# log exception and raise
|
@@ -232,6 +225,17 @@ class GunnyLog
|
|
232
225
|
raise GunnyLogException.new(exc.message)
|
233
226
|
end
|
234
227
|
|
228
|
+
# used for debugging GunnyLog
|
229
|
+
def local_debug(loc, msg = nil)
|
230
|
+
if DEBUG_FLAG
|
231
|
+
if msg == nil
|
232
|
+
puts 'GunnyLog::' + loc
|
233
|
+
else
|
234
|
+
puts 'GunnyLog::' + loc + '|' + msg
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
235
239
|
end
|
236
240
|
|
237
241
|
|
metadata
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: GunnyLog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GunnyHwy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Ruby class for logging to
|
13
|
+
description: Ruby class for logging to stdout, stderr, or a file
|
14
14
|
email: gunnyhwy21@yahoo.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/GunnyLog.rb
|
20
|
-
- lib/GunnyLog/version.rb
|
21
20
|
- lib/GunnyLog/exceptions.rb
|
21
|
+
- lib/GunnyLog/severity.rb
|
22
22
|
- README.md
|
23
23
|
homepage: http://rubygems.org/gems/GunnyLog
|
24
24
|
licenses:
|
data/lib/GunnyLog/version.rb
DELETED