simple_cloud_logging 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/baselogger.rb +263 -111
- data/lib/dummylogger.rb +25 -26
- data/lib/locallogger.rb +63 -37
- data/lib/simple_cloud_logging.rb +35 -50
- metadata +29 -14
- data/examples/example01.rb +0 -27
- data/examples/example02.rb +0 -20
- data/examples/example03.rb +0 -24
- data/examples/example04.rb +0 -40
- data/lib/remotelogger.rb +0 -85
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efa575e6c8846e19b9b5984279c14445776cb0b58753be260992d175c66bac72
|
4
|
+
data.tar.gz: 53b13fd961e29f6aa223aead0ab18f53f6e516f26324e86f747530a2cdfed3cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2791e1b9d517135b3174159cdf29be86c7dcc95e8248817c010c135c114ecf1191ff217528f2d4fb28172008f1be902e4412b1c8bdeebbd6b4c6de074163c53
|
7
|
+
data.tar.gz: 944c082afac20eeddc4e501a65d8e2087a40af45bc7966c75f6d5e22d6375e75a136a7da5bd931c2a060df39a77316576a280a5b88e78d53a554da5991b61538
|
data/lib/baselogger.rb
CHANGED
@@ -1,112 +1,264 @@
|
|
1
|
-
module BlackStack
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
self.
|
110
|
-
|
111
|
-
|
1
|
+
module BlackStack
|
2
|
+
|
3
|
+
module Logger
|
4
|
+
DEFAULT_MIN_SIZE = 10*1024*1024
|
5
|
+
DEFAULT_MAX_SIZE = 20*1024*1024
|
6
|
+
DEFAULT_SHOW_NESTING_LEVEL = false
|
7
|
+
DEFAULT_SHOW_NESTING_CALLER = false
|
8
|
+
DEFAULT_COLORIZE = true
|
9
|
+
DEFAULT_NESTING_ASSERTION = true
|
10
|
+
|
11
|
+
@@min_size = DEFAULT_MIN_SIZE
|
12
|
+
@@max_size = DEFAULT_MAX_SIZE
|
13
|
+
@@show_nesting_level = DEFAULT_SHOW_NESTING_LEVEL
|
14
|
+
@@show_nesting_caller = DEFAULT_SHOW_NESTING_CALLER
|
15
|
+
@@colorize = DEFAULT_COLORIZE
|
16
|
+
@@nesting_assertion = DEFAULT_NESTING_ASSERTION
|
17
|
+
|
18
|
+
def self.set(
|
19
|
+
min_size: DEFAULT_MIN_SIZE,
|
20
|
+
max_size: DEFAULT_MAX_SIZE,
|
21
|
+
show_nesting_level: DEFAULT_SHOW_NESTING_LEVEL,
|
22
|
+
show_nesting_caller: DEFAULT_SHOW_NESTING_CALLER,
|
23
|
+
colorize: DEFAULT_COLORIZE,
|
24
|
+
nesting_assertion: DEFAULT_NESTING_ASSERTION
|
25
|
+
)
|
26
|
+
err = []
|
27
|
+
|
28
|
+
# min_size must be a positive integer
|
29
|
+
err << "min_byes must be apositive integer." if !min_size.is_a?(Integer) || min_size.to_i < 0
|
30
|
+
err << "max_byes must be apositive integer." if !max_size.is_a?(Integer) || max_size.to_i < 0
|
31
|
+
err << "min_byes must be lower than max_size." if min_size.is_a?(Integer) && max_size.is_a?(Integer) && !(min_size < max_size)
|
32
|
+
err << "show_nesting_level must be a boolean." if ![true, false].include?(show_nesting_level)
|
33
|
+
err << "show_nesting_caller must be a boolean." if ![true, false].include?(show_nesting_caller)
|
34
|
+
err << "colorize must be a boolean." if ![true, false].include?(colorize)
|
35
|
+
err << "nesting_assertion must be a boolean." if ![true, false].include?(nesting_assertion)
|
36
|
+
|
37
|
+
@@min_size = min_size
|
38
|
+
@@max_size = max_size
|
39
|
+
@@show_nesting_level = show_nesting_level
|
40
|
+
@@show_nesting_caller = show_nesting_caller
|
41
|
+
@@colorize = colorize
|
42
|
+
@@nesting_assertion = nesting_assertion
|
43
|
+
|
44
|
+
if !colorize
|
45
|
+
# overwrite the instance methods green, red, blue and yellow of the class String from inside the constructor of another class, to make them non-effect.
|
46
|
+
String.class_eval do
|
47
|
+
define_method(:green) do
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
define_method(:red) do
|
52
|
+
self
|
53
|
+
end
|
54
|
+
|
55
|
+
define_method(:blue) do
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
59
|
+
define_method(:yellow) do
|
60
|
+
self
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.min_size()
|
67
|
+
@@min_size
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.max_size()
|
71
|
+
@@max_size
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.show_nesting_level()
|
75
|
+
@@show_nesting_level
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.show_nesting_caller()
|
79
|
+
@@show_nesting_caller
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.colorize()
|
83
|
+
@@colorize
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.nesting_assertion()
|
87
|
+
@@nesting_assertion
|
88
|
+
end
|
89
|
+
end # module Logger
|
90
|
+
|
91
|
+
class LogNestingError < StandardError
|
92
|
+
attr_reader :message
|
93
|
+
|
94
|
+
def initialize(message)
|
95
|
+
@message = message
|
96
|
+
end
|
97
|
+
def to_s
|
98
|
+
@message
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class BaseLogger
|
103
|
+
NEWLINE = "\n\r"
|
104
|
+
attr_accessor :filename, :level, :level_children_lines, :level_open_callers
|
105
|
+
|
106
|
+
def initialize_attributes()
|
107
|
+
self.level = 0
|
108
|
+
self.level_children_lines = {}
|
109
|
+
self.level_open_callers = {}
|
110
|
+
end
|
111
|
+
|
112
|
+
def initialize(the_filename=nil)
|
113
|
+
self.filename = the_filename
|
114
|
+
self.initialize_attributes
|
115
|
+
end
|
116
|
+
|
117
|
+
def reset()
|
118
|
+
self.initialize_attributes
|
119
|
+
end
|
120
|
+
|
121
|
+
def log(s, datetime=nil)
|
122
|
+
t = !datetime.nil? ? datetime : Time.now
|
123
|
+
ltime = t.strftime("%Y-%m-%d %H:%M:%S").to_s
|
124
|
+
ltime += " - level #{self.level.to_s.blue}" if Logger.show_nesting_level
|
125
|
+
ltext = ltime + ": " + s + NEWLINE
|
126
|
+
# print
|
127
|
+
print ltext
|
128
|
+
# return
|
129
|
+
ltext
|
130
|
+
end
|
131
|
+
|
132
|
+
def blank_line
|
133
|
+
self.log('')
|
134
|
+
end
|
135
|
+
|
136
|
+
def logs(s, datetime=nil)
|
137
|
+
|
138
|
+
# Nesting assertion:
|
139
|
+
# - How to find out from which line number the method was called in Ruby?
|
140
|
+
# - Referneces:
|
141
|
+
# - https://stackoverflow.com/questions/37564928/how-to-find-out-from-which-line-number-the-method-was-called-in-ruby
|
142
|
+
# - https://ruby-doc.org/core-2.2.3/Thread/Backtrace/Location.html
|
143
|
+
#binding.pry if s == "Looking for number 3... "
|
144
|
+
caller = caller_locations(0..).last
|
145
|
+
#binding.pry if s == '1... '
|
146
|
+
#binding.pry if s == '4... '
|
147
|
+
# if the parent level was called from the same line, I am missing to close the parent.
|
148
|
+
if self.level_open_callers[self.level-1].to_s == caller.to_s
|
149
|
+
if Logger.nesting_assertion
|
150
|
+
raise LogNestingError.new("Log nesting assertion: You missed to close the log-level that you opened at #{caller.to_s}.")
|
151
|
+
end
|
152
|
+
else
|
153
|
+
self.level_open_callers[self.level] = caller.to_s
|
154
|
+
end
|
155
|
+
|
156
|
+
t = !datetime.nil? ? datetime : Time.now
|
157
|
+
ltime = t.strftime("%Y-%m-%d %H:%M:%S").to_s
|
158
|
+
ltime += " - level #{self.level.to_s.blue}" if Logger.show_nesting_level
|
159
|
+
ltime += " - caller #{caller.to_s.blue}" if Logger.show_nesting_caller
|
160
|
+
|
161
|
+
#binding.pry if self.level>0
|
162
|
+
# start in a new line, if this line is the first child of the parent level has opened lines
|
163
|
+
ltext = ""
|
164
|
+
ltext += NEWLINE if self.level > 0 && self.level_children_lines[self.level].to_i == 0
|
165
|
+
ltext += ltime + ": "
|
166
|
+
|
167
|
+
# increase the number of children of the parent level
|
168
|
+
self.level_children_lines[self.level] = self.level_children_lines[self.level].to_i + 1
|
169
|
+
|
170
|
+
self.level += 1
|
171
|
+
|
172
|
+
i=1
|
173
|
+
while (i<self.level)
|
174
|
+
ltext += "> "
|
175
|
+
i+=1
|
176
|
+
end
|
177
|
+
|
178
|
+
ltext += s
|
179
|
+
|
180
|
+
# print
|
181
|
+
print ltext
|
182
|
+
|
183
|
+
# return
|
184
|
+
ltext
|
185
|
+
end
|
186
|
+
|
187
|
+
def logf(s, datetime=nil)
|
188
|
+
ltext = ""
|
189
|
+
|
190
|
+
# clear the caller who opened the level that I am closing
|
191
|
+
self.level_open_callers[self.level-1] = nil
|
192
|
+
|
193
|
+
# if the parent level has children
|
194
|
+
if self.level_children_lines[self.level].to_i > 0
|
195
|
+
t = !datetime.nil? ? datetime : Time.now
|
196
|
+
ltime = t.strftime("%Y-%m-%d %H:%M:%S").to_s
|
197
|
+
ltime += " - level #{self.level.to_s.blue}" if Logger.show_nesting_level
|
198
|
+
|
199
|
+
ltext += "#{ltime}: "
|
200
|
+
|
201
|
+
i=1
|
202
|
+
while (i<self.level)
|
203
|
+
ltext += "> "
|
204
|
+
i+=1
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
# since I am closing a level, set the number of children to 0
|
210
|
+
self.level_children_lines[self.level] = 0
|
211
|
+
|
212
|
+
# nesting assertion
|
213
|
+
if self.level <= 0
|
214
|
+
# force the level to 2, so I can use the loger to trace the error after raising the exceptiopn.
|
215
|
+
self.level = 1
|
216
|
+
# raise the exception
|
217
|
+
if Logger.nesting_assertion
|
218
|
+
raise LogNestingError.new("Log nesting assertion: You are closing 2 times the level started, or you missed to open that lavel, or you closed the another level in the middle 2 times.")
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
self.level -= 1
|
223
|
+
ltext += s + NEWLINE
|
224
|
+
|
225
|
+
# print
|
226
|
+
print ltext
|
227
|
+
# return
|
228
|
+
ltext
|
229
|
+
end
|
230
|
+
|
231
|
+
def done(details: nil)
|
232
|
+
if details.nil?
|
233
|
+
self.logf("done".green)
|
234
|
+
else
|
235
|
+
self.logf("done".green + " (#{details.to_s})")
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
def skip(details: nil)
|
240
|
+
if details.nil?
|
241
|
+
self.logf("skip".yellow)
|
242
|
+
else
|
243
|
+
self.logf("skip".yellow + " (#{details.to_s})")
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
def error(e=nil)
|
248
|
+
self.logf("error".red) if e.nil?
|
249
|
+
self.logf("error: #{e.to_console}.".red) if !e.nil?
|
250
|
+
end
|
251
|
+
|
252
|
+
def yes()
|
253
|
+
self.logf("yes".green)
|
254
|
+
end
|
255
|
+
|
256
|
+
def ok()
|
257
|
+
self.logf("ok".green)
|
258
|
+
end
|
259
|
+
|
260
|
+
def no()
|
261
|
+
self.logf("no".yellow)
|
262
|
+
end
|
263
|
+
end # class BaseLogger
|
112
264
|
end # module BlackStack
|
data/lib/dummylogger.rb
CHANGED
@@ -1,27 +1,26 @@
|
|
1
|
-
module BlackStack
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# call the
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def logs
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def logf
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end # class LocalLogger
|
1
|
+
module BlackStack
|
2
|
+
class DummyLogger < BaseLogger
|
3
|
+
|
4
|
+
# call the parent class to set the attributes
|
5
|
+
# call the save method to store the new attributes into the data file
|
6
|
+
def reset()
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def log(s, datetime=nil)
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
def logs(s, datetime=nil)
|
15
|
+
end # def logs
|
16
|
+
|
17
|
+
#
|
18
|
+
def logf(s, datetime=nil)
|
19
|
+
end # def logf
|
20
|
+
|
21
|
+
#
|
22
|
+
def release()
|
23
|
+
end
|
24
|
+
|
25
|
+
end # class LocalLogger
|
27
26
|
end # module BlackStack
|
data/lib/locallogger.rb
CHANGED
@@ -1,38 +1,64 @@
|
|
1
|
-
module BlackStack
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# call the
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
1
|
+
module BlackStack
|
2
|
+
class LocalLogger < BaseLogger
|
3
|
+
|
4
|
+
# call the parent class to set the attributes
|
5
|
+
# call the save method to store the new attributes into the data file
|
6
|
+
def reset()
|
7
|
+
super
|
8
|
+
BlackStack::LocalLoggerFactory::save(self.filename, self)
|
9
|
+
end
|
10
|
+
|
11
|
+
# store the min allowed bytes in the variable min
|
12
|
+
# store the max allowed bytes in the variable max
|
13
|
+
# get number of bytes of filename and store it the variable n
|
14
|
+
# if number of bytes (n) is higer than max, then truncate the first (max-min) bytes in the file.
|
15
|
+
# finally, add the text into the variable s at the end of the file.
|
16
|
+
def write(s)
|
17
|
+
# store the min allowed bytes in the variable min
|
18
|
+
min = Logger.min_size
|
19
|
+
# store the max allowed bytes in the variable max
|
20
|
+
max = Logger.max_size
|
21
|
+
# get number of bytes of filename and store it the variable n
|
22
|
+
n = File.exists?(self.filename) ? File.size(self.filename) : 0
|
23
|
+
# if number of bytes (n) is higer than max, then truncate the first (max-min) bytes in the file.
|
24
|
+
if n > max
|
25
|
+
# Read the content of the file
|
26
|
+
content = File.read(self.filename)
|
27
|
+
# Calculate the number of bytes to truncate
|
28
|
+
truncate_bytes = n - (max - min)
|
29
|
+
# Truncate the first (max-min) bytes in the file
|
30
|
+
truncated_content = content[truncate_bytes..-1]
|
31
|
+
# Write the truncated content back to the file
|
32
|
+
File.open(self.filename, 'w') { |file| file.write(truncated_content) }
|
33
|
+
end
|
34
|
+
#
|
35
|
+
File.open(self.filename, 'a') { |file| file.write(s) }
|
36
|
+
end
|
37
|
+
|
38
|
+
def log(s, datetime=nil)
|
39
|
+
ltext = super(s, datetime)
|
40
|
+
self.write(ltext)
|
41
|
+
ltext
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
def logs(s, datetime=nil)
|
46
|
+
ltext = super(s, datetime)
|
47
|
+
self.write(ltext)
|
48
|
+
ltext
|
49
|
+
end # def logs
|
50
|
+
|
51
|
+
#
|
52
|
+
def logf(s, datetime=nil)
|
53
|
+
ltext = super(s, datetime)
|
54
|
+
self.write(ltext)
|
55
|
+
ltext
|
56
|
+
end # def logf
|
57
|
+
|
58
|
+
#
|
59
|
+
def release()
|
60
|
+
BlackStack::LocalLoggerFactory.release(self.filename)
|
61
|
+
end
|
62
|
+
|
63
|
+
end # class LocalLogger
|
38
64
|
end # module BlackStack
|
data/lib/simple_cloud_logging.rb
CHANGED
@@ -1,51 +1,36 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
require_relative './
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def self.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
ret
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
data_filename = "#{filename}.data"
|
37
|
-
ret = BlackStack::LocalLogger.new(filename)
|
38
|
-
f = File.open(data_filename,"w")
|
39
|
-
f.write "#{locallogger.nest_level.to_s},#{locallogger.number_of_lines_in_current_level.to_s},#{locallogger.current_nest_level.to_s}"
|
40
|
-
f.close
|
41
|
-
end
|
42
|
-
|
43
|
-
#
|
44
|
-
def self.release(filename)
|
45
|
-
data_filename = "#{filename}.data"
|
46
|
-
File.delete(data_filename) if File.exist?(data_filename)
|
47
|
-
end
|
48
|
-
|
49
|
-
end # class LocalLoggerFactory
|
50
|
-
|
1
|
+
#require 'pry'
|
2
|
+
require 'colorize'
|
3
|
+
require 'blackstack-core'
|
4
|
+
require_relative './baselogger'
|
5
|
+
require_relative './dummylogger'
|
6
|
+
require_relative './locallogger'
|
7
|
+
|
8
|
+
module BlackStack
|
9
|
+
class LocalLoggerFactory
|
10
|
+
#
|
11
|
+
def self.create(filename)
|
12
|
+
data_filename = "#{filename}.data"
|
13
|
+
ret = BlackStack::LocalLogger.new(filename)
|
14
|
+
if File.exist?(data_filename)
|
15
|
+
f = File.open(data_filename,"r")
|
16
|
+
data = f.read.split(/,/)
|
17
|
+
ret.nest_level = data[0].to_i
|
18
|
+
ret.number_of_lines_in_current_level = data[1].to_i
|
19
|
+
ret.current_nest_level = data[2].to_i
|
20
|
+
f.close
|
21
|
+
end
|
22
|
+
ret
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
def self.save(filename, locallogger)
|
27
|
+
data_filename = "#{filename}.data"
|
28
|
+
ret = BlackStack::LocalLogger.new(filename)
|
29
|
+
f = File.open(data_filename,"w")
|
30
|
+
f.write "#{locallogger.nest_level.to_s},#{locallogger.number_of_lines_in_current_level.to_s},#{locallogger.current_nest_level.to_s}"
|
31
|
+
f.close
|
32
|
+
end
|
33
|
+
|
34
|
+
end # class LocalLoggerFactory
|
35
|
+
|
51
36
|
end # module BlackStack
|
metadata
CHANGED
@@ -1,55 +1,70 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_cloud_logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.1
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.8.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.8.1
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.8.1
|
13
33
|
- !ruby/object:Gem::Dependency
|
14
34
|
name: blackstack-core
|
15
35
|
requirement: !ruby/object:Gem::Requirement
|
16
36
|
requirements:
|
17
37
|
- - "~>"
|
18
38
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.2.
|
39
|
+
version: 1.2.16
|
20
40
|
- - ">="
|
21
41
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.2.
|
42
|
+
version: 1.2.16
|
23
43
|
type: :runtime
|
24
44
|
prerelease: false
|
25
45
|
version_requirements: !ruby/object:Gem::Requirement
|
26
46
|
requirements:
|
27
47
|
- - "~>"
|
28
48
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.2.
|
49
|
+
version: 1.2.16
|
30
50
|
- - ">="
|
31
51
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.2.
|
52
|
+
version: 1.2.16
|
33
53
|
description: 'THIS GEM IS STILL IN DEVELOPMENT STAGE. Find documentation here: https://github.com/leandrosardi/simple_cloud_logging.'
|
34
54
|
email: leandro.sardi@expandedventure.com
|
35
55
|
executables: []
|
36
56
|
extensions: []
|
37
57
|
extra_rdoc_files: []
|
38
58
|
files:
|
39
|
-
- examples/example01.rb
|
40
|
-
- examples/example02.rb
|
41
|
-
- examples/example03.rb
|
42
|
-
- examples/example04.rb
|
43
59
|
- lib/baselogger.rb
|
44
60
|
- lib/dummylogger.rb
|
45
61
|
- lib/locallogger.rb
|
46
|
-
- lib/remotelogger.rb
|
47
62
|
- lib/simple_cloud_logging.rb
|
48
63
|
homepage: https://rubygems.org/gems/simple_cloud_logging
|
49
64
|
licenses:
|
50
65
|
- MIT
|
51
66
|
metadata: {}
|
52
|
-
post_install_message:
|
67
|
+
post_install_message:
|
53
68
|
rdoc_options: []
|
54
69
|
require_paths:
|
55
70
|
- lib
|
@@ -65,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
80
|
version: '0'
|
66
81
|
requirements: []
|
67
82
|
rubygems_version: 3.3.7
|
68
|
-
signing_key:
|
83
|
+
signing_key:
|
69
84
|
specification_version: 4
|
70
85
|
summary: THIS GEM IS STILL IN DEVELOPMENT STAGE. Easy library to write log files in
|
71
86
|
the cloud, watch them anywhere, and enbed the log in any website. The remote-logging
|
data/examples/example01.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require_relative '../lib/simple_cloud_logging'
|
2
|
-
|
3
|
-
# Testing a simple local log.
|
4
|
-
|
5
|
-
logger = BlackStack::LocalLoggerFactory.create('./example01.log')
|
6
|
-
|
7
|
-
logger.reset()
|
8
|
-
|
9
|
-
while (true)
|
10
|
-
logger.logs("Declare variable... ")
|
11
|
-
@n = 5
|
12
|
-
logger.done
|
13
|
-
|
14
|
-
logger.logs("Check if #{@n.to_s}>5... ")
|
15
|
-
if @n>5
|
16
|
-
logger.yes
|
17
|
-
else
|
18
|
-
logger.no
|
19
|
-
end
|
20
|
-
|
21
|
-
logger.logs("Sleep 60 seconds... ")
|
22
|
-
sleep(60)
|
23
|
-
logger.done
|
24
|
-
end
|
25
|
-
|
26
|
-
#BlackStack::LocalLoggerFactory.save('./example01.log', logger)
|
27
|
-
#BlackStack::LocalLoggerFactory.release('./example01.log')
|
data/examples/example02.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require_relative '../lib/simple_cloud_logging'
|
2
|
-
|
3
|
-
# Testing a local log, with 1-level nesting.
|
4
|
-
|
5
|
-
logger = BlackStack::LocalLoggerFactory.create('./example02.log')
|
6
|
-
|
7
|
-
logger.logs("Declare array of numbers... ")
|
8
|
-
@a = [1,2,3,4,5,6,7,8,9,10]
|
9
|
-
logger.done
|
10
|
-
|
11
|
-
logger.logs("Process array elements... ")
|
12
|
-
@a.each { |n|
|
13
|
-
logger.logs("Check if n>5... ")
|
14
|
-
if n>5
|
15
|
-
logger.yes
|
16
|
-
else
|
17
|
-
logger.no
|
18
|
-
end
|
19
|
-
}
|
20
|
-
logger.done
|
data/examples/example03.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative '../lib/simple_cloud_logging'
|
2
|
-
|
3
|
-
# Testing a local log, with 2-levels of nesting.
|
4
|
-
|
5
|
-
logger = BlackStack::LocalLoggerFactory.create('./example03.log')
|
6
|
-
|
7
|
-
logger.logs("Declare array of array of numbers... ")
|
8
|
-
@a = [[1,2,3],[4,5,6],[7,8,9,10]]
|
9
|
-
logger.done
|
10
|
-
|
11
|
-
logger.logs("Process array of array elements... ")
|
12
|
-
@a.each { |b|
|
13
|
-
logger.logs("Process array of numbers... ")
|
14
|
-
b.each { |n|
|
15
|
-
logger.logs("Check if #{n.to_s}>5... ")
|
16
|
-
if n>5
|
17
|
-
logger.yes
|
18
|
-
else
|
19
|
-
logger.no
|
20
|
-
end
|
21
|
-
}
|
22
|
-
logger.done
|
23
|
-
}
|
24
|
-
logger.done
|
data/examples/example04.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require_relative '../lib/simple_cloud_logging'
|
2
|
-
|
3
|
-
# Testing the LocalLoggerFactory, getting the logger object before each log action.
|
4
|
-
# The log should keep congruent, like it happens in example03.rb
|
5
|
-
|
6
|
-
logger = BlackStack::LocalLoggerFactory.create('./example04.log')
|
7
|
-
logger.logs("Declare array of array of numbers... ")
|
8
|
-
@a = [[1,2,3],[4,5,6],[7,8,9,10]]
|
9
|
-
BlackStack::LocalLoggerFactory.save('./example04.log', logger)
|
10
|
-
logger = BlackStack::LocalLoggerFactory.create('./example04.log')
|
11
|
-
logger.done
|
12
|
-
|
13
|
-
BlackStack::LocalLoggerFactory.save('./example04.log', logger)
|
14
|
-
logger = BlackStack::LocalLoggerFactory.create('./example04.log')
|
15
|
-
logger.logs("Process array of array elements... ")
|
16
|
-
@a.each { |b|
|
17
|
-
BlackStack::LocalLoggerFactory.save('./example04.log', logger)
|
18
|
-
logger = BlackStack::LocalLoggerFactory.create('./example04.log')
|
19
|
-
logger.logs("Process array of numbers... ")
|
20
|
-
b.each { |n|
|
21
|
-
BlackStack::LocalLoggerFactory.save('./example04.log', logger)
|
22
|
-
logger = BlackStack::LocalLoggerFactory.create('./example04.log')
|
23
|
-
logger.logs("Check if #{n.to_s}>5... ")
|
24
|
-
if n>5
|
25
|
-
BlackStack::LocalLoggerFactory.save('./example04.log', logger)
|
26
|
-
logger = BlackStack::LocalLoggerFactory.create('./example04.log')
|
27
|
-
logger.yes
|
28
|
-
else
|
29
|
-
BlackStack::LocalLoggerFactory.save('./example04.log', logger)
|
30
|
-
logger = BlackStack::LocalLoggerFactory.create('./example04.log')
|
31
|
-
logger.no
|
32
|
-
end
|
33
|
-
}
|
34
|
-
BlackStack::LocalLoggerFactory.save('./example04.log', logger)
|
35
|
-
logger = BlackStack::LocalLoggerFactory.create('./example04.log')
|
36
|
-
logger.done
|
37
|
-
}
|
38
|
-
BlackStack::LocalLoggerFactory.save('./example04.log', logger)
|
39
|
-
logger = BlackStack::LocalLoggerFactory.create('./example04.log')
|
40
|
-
logger.done
|
data/lib/remotelogger.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
module BlackStack
|
2
|
-
require_relative './baselogger'
|
3
|
-
class RemoteLogger < BlackStack::BaseLogger
|
4
|
-
attr_accessor :api_protocol, :api_domain, :api_port, :api_key, :id_client
|
5
|
-
|
6
|
-
def initialize(the_filename, the_api_protocol, the_api_domain, the_api_port, the_api_key, the_id_client=nil)
|
7
|
-
super(the_filename)
|
8
|
-
self.api_protocol = the_api_protocol
|
9
|
-
self.api_domain = the_api_domain
|
10
|
-
self.api_port = the_api_port
|
11
|
-
self.api_key = the_api_key
|
12
|
-
self.id_client = the_id_client
|
13
|
-
end
|
14
|
-
|
15
|
-
# call the parent class to set the attributes
|
16
|
-
# call the save method to store the new attributes into the data file
|
17
|
-
def reset()
|
18
|
-
super
|
19
|
-
=begin
|
20
|
-
url = "#{self.api_protocol}://#{self.api_domain}:#{self.api_port.to_s}/api1.3/threads/reset.json"
|
21
|
-
res = BlackStack::Netting::api_call(url, {
|
22
|
-
'api_key' => self.api_key,
|
23
|
-
'filename' => self.filename,
|
24
|
-
'id_client' => self.id_client,
|
25
|
-
})
|
26
|
-
=end
|
27
|
-
end
|
28
|
-
|
29
|
-
def log(s, datetime=nil)
|
30
|
-
ltext = super(s, datetime)
|
31
|
-
=begin
|
32
|
-
url = "#{self.api_protocol}://#{self.api_domain}:#{self.api_port.to_s}/api1.3/threads/log.json"
|
33
|
-
res = BlackStack::Netting::api_call(url, {
|
34
|
-
'api_key' => self.api_key,
|
35
|
-
'filename' => self.filename,
|
36
|
-
'text' => s,
|
37
|
-
'method' => BlackStack::BaseLogger::METHOD_LOG,
|
38
|
-
'id_client' => self.id_client,
|
39
|
-
})
|
40
|
-
=end
|
41
|
-
ltext
|
42
|
-
end
|
43
|
-
|
44
|
-
def logs(s, datetime=nil)
|
45
|
-
ltext = super(s, datetime)
|
46
|
-
=begin
|
47
|
-
url = "#{self.api_protocol}://#{self.api_domain}:#{self.api_port.to_s}/api1.3/threads/log.json"
|
48
|
-
res = BlackStack::Netting::api_call(url, {
|
49
|
-
'api_key' => self.api_key,
|
50
|
-
'filename' => self.filename,
|
51
|
-
'text' => s,
|
52
|
-
'method' => BlackStack::BaseLogger::METHOD_LOGS,
|
53
|
-
'id_client' => self.id_client,
|
54
|
-
})
|
55
|
-
=end
|
56
|
-
ltext
|
57
|
-
end
|
58
|
-
|
59
|
-
def logf(s, datetime=nil)
|
60
|
-
ltext = super(s, datetime)
|
61
|
-
=begin
|
62
|
-
url = "#{self.api_protocol}://#{self.api_domain}:#{self.api_port.to_s}/api1.3/threads/log.json"
|
63
|
-
res = BlackStack::Netting::api_call(url, {
|
64
|
-
'api_key' => self.api_key,
|
65
|
-
'filename' => self.filename,
|
66
|
-
'text' => s,
|
67
|
-
'method' => BlackStack::BaseLogger::METHOD_LOGF,
|
68
|
-
'id_client' => self.id_client,
|
69
|
-
})
|
70
|
-
=end
|
71
|
-
ltext
|
72
|
-
end
|
73
|
-
|
74
|
-
def release()
|
75
|
-
=begin
|
76
|
-
url = "#{self.api_url}:#{self.api_port.to_s}/api1.3/threads/release.json"
|
77
|
-
res = BlackStack::Netting::api_call(url, {
|
78
|
-
'api_key' => self.api_key,
|
79
|
-
'filename' => self.filename,
|
80
|
-
'id_client' => self.id_client,
|
81
|
-
})
|
82
|
-
=end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end # module BlackStack
|