GunnyLog 1.0.6 → 1.0.7
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 +36 -32
- data/lib/GunnyLog/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae15d7b7a1cd1e0f1c5708bfe22445b79e01e4f3
|
4
|
+
data.tar.gz: 3ed29da80bb39777b6b243af6f191b5a00a3567c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e999c83d931d129e626a1678628bfcb669870cf06a2f48ac6ade949053f19e529d39ad54326a68ce4422911b7f58787029eda2927374fba5d534a91aff96142f
|
7
|
+
data.tar.gz: b061e89263b61666601071ee55d2d19518ce76aa1a3924acf69cbcd09743347715ca0b196f8e1c15f06f4dd1dd482493589d2d0cf99c232aff0abeb746cbd829
|
data/lib/GunnyLog.rb
CHANGED
@@ -16,27 +16,27 @@ class GunnyLog
|
|
16
16
|
# Set logging on and off
|
17
17
|
# @param flag [bool] switch for on or off
|
18
18
|
def set_logging_enabled(flag)
|
19
|
-
@
|
19
|
+
@_is_logging_enabled = flag
|
20
20
|
end
|
21
21
|
|
22
22
|
# Set logging on and off
|
23
23
|
# @deprecated Use {#set_logging_enabled} instead
|
24
24
|
# @param flag [bool] switch for on or off
|
25
25
|
def set_switch(flag)
|
26
|
-
@
|
26
|
+
@_is_logging_enabled = flag
|
27
27
|
end
|
28
28
|
|
29
|
-
# Set message was logged from
|
30
|
-
# @param loc [string]
|
29
|
+
# Set message was logged from message_location
|
30
|
+
# @param loc [string] message_location name
|
31
31
|
def set_message_location(loc)
|
32
|
-
@
|
32
|
+
@message_location = loc
|
33
33
|
end
|
34
34
|
|
35
|
-
# Set message was logged from
|
35
|
+
# Set message was logged from message_location
|
36
36
|
# @deprecated Use {#set_message_location} instead
|
37
|
-
# @param loc [string]
|
37
|
+
# @param loc [string] message_location name
|
38
38
|
def set_location(loc)
|
39
|
-
@
|
39
|
+
@message_location = loc
|
40
40
|
end
|
41
41
|
|
42
42
|
# Set output to STDOUT, default
|
@@ -44,7 +44,7 @@ class GunnyLog
|
|
44
44
|
if @_is_file_open
|
45
45
|
self.close
|
46
46
|
end
|
47
|
-
@
|
47
|
+
@logging_file = STDOUT
|
48
48
|
end
|
49
49
|
|
50
50
|
# Set output to STDERR
|
@@ -52,24 +52,27 @@ class GunnyLog
|
|
52
52
|
if @_is_file_open
|
53
53
|
self.close
|
54
54
|
end
|
55
|
-
@
|
55
|
+
@logging_file = STDERR
|
56
56
|
end
|
57
57
|
|
58
58
|
# Open the logfile
|
59
59
|
# @param filename [string] name of the logfile
|
60
60
|
def open(filename = 'gunnylog.log')
|
61
61
|
begin
|
62
|
-
@
|
62
|
+
@logging_file = File.open(filename, 'a+')
|
63
63
|
@_is_file_open = true
|
64
64
|
rescue SystemCallError
|
65
65
|
raise GunnyLogException.new('Error opening file: ' + filename)
|
66
|
+
#STDERR.puts 'GunnyLog: Error opening file: ' + filename + ' using stdout'
|
67
|
+
#@_is_file_open = false
|
68
|
+
#@logging_file = STDOUT
|
66
69
|
end
|
67
70
|
end
|
68
71
|
|
69
72
|
# Open the logfile with path, name, and extention
|
70
73
|
# @param pathname [string] path of the logfile
|
71
74
|
# @param filename [string] name of the logfile
|
72
|
-
# @param
|
75
|
+
# @param extension [string] extension of the logfile
|
73
76
|
def open_with_info(pathname = nil,
|
74
77
|
filename = 'gunnylog',
|
75
78
|
extension = 'log')
|
@@ -92,12 +95,13 @@ class GunnyLog
|
|
92
95
|
# Close the logfile
|
93
96
|
def close
|
94
97
|
begin
|
95
|
-
@
|
96
|
-
@_is_file_open = false
|
97
|
-
@outfile = STDOUT
|
98
|
+
@logging_file.close
|
98
99
|
rescue SystemCallError
|
99
100
|
raise GunnyLogException.new('Error closing file')
|
101
|
+
#STDERR.puts 'GunnyLog: Error closing file'
|
100
102
|
end
|
103
|
+
@_is_file_open = false
|
104
|
+
@logging_file = STDOUT
|
101
105
|
end
|
102
106
|
|
103
107
|
# Write message to file
|
@@ -107,18 +111,18 @@ class GunnyLog
|
|
107
111
|
end
|
108
112
|
|
109
113
|
# Write message to file
|
110
|
-
# @param loc [string] message
|
114
|
+
# @param loc [string] message message_location, optional
|
111
115
|
# @param msg [string] message string
|
112
116
|
def message(loc = nil, msg)
|
113
117
|
#if @_is_file_open
|
114
|
-
write_msg(@
|
118
|
+
write_msg(@logging_file, loc, msg)
|
115
119
|
#else
|
116
120
|
# write_msg(STDOUT, loc, msg)
|
117
121
|
#end
|
118
122
|
end
|
119
123
|
|
120
124
|
# Write formatted message with single arg or array of args
|
121
|
-
# @param loc [string] message
|
125
|
+
# @param loc [string] message message_location, optional
|
122
126
|
# @param msg [string] message format string
|
123
127
|
# @param args [arg or array of args]
|
124
128
|
def formatted_message(loc = nil, msg, args)
|
@@ -127,7 +131,7 @@ class GunnyLog
|
|
127
131
|
end
|
128
132
|
|
129
133
|
# Write formatted message with variable number of args
|
130
|
-
# @param loc [string] message
|
134
|
+
# @param loc [string] message message_location
|
131
135
|
# @param msg [string] message format string
|
132
136
|
# @param args [variable number of args]
|
133
137
|
def formatted_message_vars(loc, msg, *args)
|
@@ -139,43 +143,43 @@ class GunnyLog
|
|
139
143
|
|
140
144
|
include Singleton
|
141
145
|
|
142
|
-
# logging off and on flag
|
143
146
|
class << self;
|
144
|
-
|
147
|
+
# Logging off and on flag
|
148
|
+
attr_accessor :_is_logging_enabled
|
145
149
|
end
|
146
150
|
|
147
|
-
# location message was logged from
|
148
151
|
class << self;
|
149
|
-
|
152
|
+
# Location message was logged from
|
153
|
+
attr_accessor :message_location
|
150
154
|
end
|
151
155
|
|
152
|
-
# is file open flag
|
153
156
|
class << self;
|
157
|
+
# Is file open flag
|
154
158
|
attr_accessor :_is_file_open
|
155
159
|
end
|
156
160
|
|
157
|
-
# log file
|
158
161
|
class << self;
|
159
|
-
|
162
|
+
# File used for the log file
|
163
|
+
attr_accessor :logging_file
|
160
164
|
end
|
161
165
|
|
162
166
|
# initailize
|
163
167
|
def initialize
|
164
|
-
@
|
165
|
-
@
|
168
|
+
@_is_logging_enabled = true
|
169
|
+
@message_location = 'MainMethod'
|
166
170
|
@_is_file_open = false
|
167
|
-
@
|
171
|
+
@logging_file = STDOUT
|
168
172
|
end
|
169
173
|
|
170
174
|
# write the msg
|
171
175
|
def write_msg(output, loc, msg)
|
172
176
|
if loc == nil
|
173
|
-
loc = @
|
177
|
+
loc = @message_location
|
174
178
|
else
|
175
179
|
# new, not sure
|
176
|
-
@
|
180
|
+
@message_location = loc
|
177
181
|
end
|
178
|
-
if @
|
182
|
+
if @_is_logging_enabled
|
179
183
|
output.puts "#{date_str}|#{$0}|#{loc}|#{msg}"
|
180
184
|
end
|
181
185
|
end
|
data/lib/GunnyLog/version.rb
CHANGED