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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ec0c09687ac4aaa3984e69afda002f3f74fece7edef8f2fc558ea8b7e65e9f5
4
- data.tar.gz: 2e124871f9609e52a0405d1e63f717c464541fe2aa51ab94e57b4bab5111115e
3
+ metadata.gz: efa575e6c8846e19b9b5984279c14445776cb0b58753be260992d175c66bac72
4
+ data.tar.gz: 53b13fd961e29f6aa223aead0ab18f53f6e516f26324e86f747530a2cdfed3cb
5
5
  SHA512:
6
- metadata.gz: e4bdfce29dd8041fa8d85d0f28db69213e32cf4616380a980cc4d6e5fac2129c03de7b3333d72bcc5479d55cf85e3107d5ba5f9d3132a6e83d4b1e7282372d00
7
- data.tar.gz: 41e3616c65fa745b12422db13fec0bee0d76a50f5440d779f0f62ba4160aa2236c50520752b5acbb6071916cf58aa9afc1fe72eed06854a71840c319871d2688
6
+ metadata.gz: d2791e1b9d517135b3174159cdf29be86c7dcc95e8248817c010c135c114ecf1191ff217528f2d4fb28172008f1be902e4412b1c8bdeebbd6b4c6de074163c53
7
+ data.tar.gz: 944c082afac20eeddc4e501a65d8e2087a40af45bc7966c75f6d5e22d6375e75a136a7da5bd931c2a060df39a77316576a280a5b88e78d53a554da5991b61538
data/lib/baselogger.rb CHANGED
@@ -1,112 +1,264 @@
1
- module BlackStack
2
- class BaseLogger
3
- METHOD_LOG = 'log'
4
- METHOD_LOGS = 'logs'
5
- METHOD_LOGF = 'logf'
6
- METHODS = [METHOD_LOG, METHOD_LOGS, METHOD_LOGF]
7
-
8
- attr_accessor :filename, :nest_level, :number_of_lines_in_current_level, :current_nest_level
9
-
10
- def initialize_attributes()
11
- self.nest_level = 0
12
- self.current_nest_level = 0
13
- self.number_of_lines_in_current_level = 0
14
- end
15
-
16
- def initialize(the_filename=nil)
17
- self.filename = the_filename
18
- self.initialize_attributes
19
- end
20
-
21
- def reset()
22
- self.initialize_attributes
23
- end
24
-
25
- def log(s, datetime=nil)
26
- t = !datetime.nil? ? datetime : Time.now
27
- ltime = t.strftime("%Y-%m-%d %H:%M:%S").to_s
28
- ltext = ltime + ": " + s + "\r\n"
29
- print ltext
30
- ltext
31
- end
32
-
33
- def logs(s, datetime=nil)
34
- t = !datetime.nil? ? datetime : Time.now
35
- ltime = t.strftime("%Y-%m-%d %H:%M:%S").to_s
36
-
37
- ltext = ""
38
- self.nest_level += 1
39
- self.number_of_lines_in_current_level = 0
40
-
41
- if self.current_nest_level != self.nest_level
42
- ltext += "\n"
43
- end
44
-
45
- ltext += ltime + ": "
46
-
47
- i=1
48
- while (i<self.nest_level)
49
- ltext += " > "
50
- i+=1
51
- end
52
-
53
- ltext += s
54
-
55
- #File.open(self.filename, 'a') { |file| file.write(ltext) }
56
- print ltext
57
-
58
- #
59
- self.current_nest_level = self.nest_level
60
-
61
- #
62
- ltext
63
- end
64
-
65
- def logf(s, datetime=nil)
66
- t = !datetime.nil? ? datetime : Time.now
67
- ltime = t.strftime("%Y-%m-%d %H:%M:%S").to_s
68
-
69
- ltext = ''
70
-
71
- if self.number_of_lines_in_current_level > 0
72
- ltext = ltime + ": "
73
-
74
- i=1
75
- while (i<self.nest_level)
76
- ltext += " > "
77
- i+=1
78
- end
79
- end # if self.number_of_lines_in_current_level == 0
80
-
81
- self.nest_level -= 1
82
- self.number_of_lines_in_current_level += 1
83
-
84
- ltext += s + "\n"
85
-
86
- print ltext
87
-
88
- ltext
89
- end
90
-
91
- def release()
92
- raise "This is an abstract method."
93
- end
94
-
95
- def done()
96
- self.logf("done")
97
- end
98
-
99
- def error(e=nil)
100
- self.logf("error") if e.nil?
101
- self.logf("error: #{e.to_console}.") if !e.nil?
102
- end
103
-
104
- def yes()
105
- self.logf("yes")
106
- end
107
-
108
- def no()
109
- self.logf("no")
110
- end
111
- end # class BaseLogger
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
- require_relative './baselogger'
3
- class DummyLogger < BlackStack::BaseLogger
4
-
5
- # call the parent class to set the attributes
6
- # call the save method to store the new attributes into the data file
7
- def reset()
8
- super
9
- end
10
-
11
- def log(s, datetime=nil)
12
- end
13
-
14
- #
15
- def logs(s, datetime=nil)
16
- end # def logs
17
-
18
- #
19
- def logf(s, datetime=nil)
20
- end # def logf
21
-
22
- #
23
- def release()
24
- end
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
- require_relative './baselogger'
3
- class LocalLogger < BlackStack::BaseLogger
4
-
5
- # call the parent class to set the attributes
6
- # call the save method to store the new attributes into the data file
7
- def reset()
8
- super
9
- BlackStack::LocalLoggerFactory::save(self.filename, self)
10
- end
11
-
12
- def log(s, datetime=nil)
13
- ltext = super(s, datetime)
14
- File.open(self.filename, 'a') { |file| file.write(ltext) }
15
- ltext
16
- end
17
-
18
- #
19
- def logs(s, datetime=nil)
20
- ltext = super(s, datetime)
21
- File.open(self.filename, 'a') { |file| file.write(ltext) }
22
- ltext
23
- end # def logs
24
-
25
- #
26
- def logf(s, datetime=nil)
27
- ltext = super(s, datetime)
28
- File.open(self.filename, 'a') { |file| file.write(ltext) }
29
- ltext
30
- end # def logf
31
-
32
- #
33
- def release()
34
- BlackStack::LocalLoggerFactory.release(self.filename)
35
- end
36
-
37
- end # class LocalLogger
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
@@ -1,51 +1,36 @@
1
- require 'blackstack-core'
2
- require_relative './dummylogger'
3
- require_relative './locallogger'
4
- require_relative './remotelogger'
5
-
6
- module BlackStack
7
-
8
-
9
-
10
- class LocalLoggerFactory
11
- def self.lock()
12
- @@fd.flock(File::LOCK_EX)
13
- end
14
-
15
- def self.release()
16
- @@fd.flock(File::LOCK_UN)
17
- end
18
-
19
- #
20
- def self.create(filename)
21
- data_filename = "#{filename}.data"
22
- ret = BlackStack::LocalLogger.new(filename)
23
- if File.exist?(data_filename)
24
- f = File.open(data_filename,"r")
25
- data = f.read.split(/,/)
26
- ret.nest_level = data[0].to_i
27
- ret.number_of_lines_in_current_level = data[1].to_i
28
- ret.current_nest_level = data[2].to_i
29
- f.close
30
- end
31
- ret
32
- end
33
-
34
- #
35
- def self.save(filename, locallogger)
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.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: 2022-05-25 00:00:00.000000000 Z
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.1
39
+ version: 1.2.16
20
40
  - - ">="
21
41
  - !ruby/object:Gem::Version
22
- version: 1.2.1
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.1
49
+ version: 1.2.16
30
50
  - - ">="
31
51
  - !ruby/object:Gem::Version
32
- version: 1.2.1
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
@@ -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')
@@ -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
@@ -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
@@ -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