simple_cloud_logging 1.2.3 → 1.2.4

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: efa575e6c8846e19b9b5984279c14445776cb0b58753be260992d175c66bac72
4
- data.tar.gz: 53b13fd961e29f6aa223aead0ab18f53f6e516f26324e86f747530a2cdfed3cb
3
+ metadata.gz: 3bbe486d02c7e3d333c061314ac82a8a7e8f654ef7f731c26fb68ef556a92e57
4
+ data.tar.gz: 5422ec3e5aa4071f70b5e85d7b8930330e8635ba4f1521d5e4f34c485768e21b
5
5
  SHA512:
6
- metadata.gz: d2791e1b9d517135b3174159cdf29be86c7dcc95e8248817c010c135c114ecf1191ff217528f2d4fb28172008f1be902e4412b1c8bdeebbd6b4c6de074163c53
7
- data.tar.gz: 944c082afac20eeddc4e501a65d8e2087a40af45bc7966c75f6d5e22d6375e75a136a7da5bd931c2a060df39a77316576a280a5b88e78d53a554da5991b61538
6
+ metadata.gz: 563c894ffa0c86ba84d2998e8dee00006a409e23b8358c59d3f777c8279544b1a8f4024548a8427c39a4f0adc11844507c2928ba1d082ea9e7bab7bb0ce352a3
7
+ data.tar.gz: 13eb9ab209c45d44c79616e008a098f4123fbc05ded6cf2d3b0bf2c7551c15a60ec32debf6998aad26a054e245a3f7abed90558f3dfe00c143486701474c5f3e
data/README.md ADDED
@@ -0,0 +1,502 @@
1
+ ![Gem version](https://img.shields.io/gem/v/simple_cloud_logging) ![Gem downloads](https://img.shields.io/gem/dt/simple_cloud_logging)
2
+
3
+ # Simple Cloud Logging
4
+
5
+ **Simple** and **Colorful** logging library for Ruby, with the following features:
6
+
7
+ - :heavy_check_mark: Colorization,
8
+ - :heavy_check_mark: Log Size Control,
9
+ - :heavy_check_mark: Nesting Debug Information,
10
+ - :heavy_check_mark: Nesting Assertions; and
11
+ - :heavy_check_mark: Dummy Logger Facade.
12
+
13
+
14
+ ![screenshots](./examples/screenshots.png)
15
+
16
+ **Outline**
17
+
18
+ 1. [Installation](#1-installation)
19
+ 2. [Getting Started](#2-getting-started)
20
+ 3. [Closing Lines with Details](#3-closing-lines-with-details)
21
+ 4. [Starting and Closing in One Line](#4-starting-and-closing-in-one-line)
22
+ 5. [Writing Blank Lines](#5-writing-blank-lines)
23
+ 6. [Writing Errors](#6-writing-errors)
24
+ 7. [Abbreviations](#7-abbreviations)
25
+ 8. [Skipping With Details](#8-skipping-with-details)
26
+ 9. [Custom Line Closing](#9-custom-line-closing)
27
+ 10. [Custom Line Closing](#10-custom-line-closing)
28
+ 11. [Nesting Lines](#11-nesting-lines)
29
+ 12. [Nesting Assertions](#12-nesting-assertions)
30
+ 13. [Size Control](#13-size-control)
31
+ 14. [Disabling Colorization](#14-disabling-colorization)
32
+ 15. [Showing Nesting Level](#15-showing-nesting-level)
33
+ 16. [Showing Callers](#16-showing-callers)
34
+ 17. [Dummy Loggers](#17-dummy-loggers)
35
+ 18. [Versioning](#18-versioning)
36
+ 19. [Authors](#19-authors)
37
+ 20. [License](#20-license)
38
+
39
+ ## 1. Installation
40
+
41
+ ```
42
+ gem install simple_cloud_logging
43
+ ```
44
+
45
+ ## 2. Getting Started
46
+
47
+ Start an close a log line.
48
+
49
+ ```ruby
50
+ require 'simple_cloud_logging'
51
+
52
+ l = BlackStack::LocalLogger.new("examples.log")
53
+
54
+ l.logs "Calculate 1+1... "
55
+ n = 1 + 1
56
+ l.done
57
+ ```
58
+
59
+ ```
60
+ 2024-07-26 15:27:04: Calculate 1+1... done
61
+ ```
62
+
63
+ ## 3. Closing Lines with Details
64
+
65
+ ```ruby
66
+ l.logs "Calculate 1+1... "
67
+ n = 1 + 1
68
+ l.done(details: n)
69
+ ```
70
+
71
+ ```
72
+ 2024-07-26 15:27:04: Calculate 1+1... done (2)
73
+ ```
74
+
75
+ ## 4. Starting and Closing in One Line
76
+
77
+ ```ruby
78
+ require 'simple_cloud_logging'
79
+
80
+ l = BlackStack::LocalLogger.new("examples.log")
81
+
82
+ l.log "Example 1:"
83
+ l.logs "Calculate 1+1... "
84
+ n = 1 + 1
85
+ l.done
86
+ ```
87
+
88
+ ```
89
+ 2024-07-26 15:27:04: Example 1:
90
+ 2024-07-26 15:27:04: Calculate 1+1... done
91
+ ```
92
+
93
+ ## 5. Writing Blank Lines
94
+
95
+ ```ruby
96
+ require 'simple_cloud_logging'
97
+
98
+ l = BlackStack::LocalLogger.new("examples.log")
99
+
100
+ l.blank_line
101
+ l.logs "Calculate 1+1... "
102
+ n = 1 + 1
103
+ l.done
104
+ ```
105
+
106
+ ```
107
+ 2024-07-26 15:27:04:
108
+ 2024-07-26 15:27:04: Calculate 1+1... done
109
+ ```
110
+
111
+ ## 6. Writing Errors
112
+
113
+ ```ruby
114
+ l.logs "Calculate 4/0... "
115
+ begin
116
+ n = 4/0
117
+ l.done(details: n)
118
+ rescue => e
119
+ l.error(e)
120
+ end
121
+ ```
122
+
123
+ ```
124
+ 2024-07-26 15:27:04: Calculate 4/0... error: divided by 0
125
+ examples.rb:32:in `/'
126
+ examples.rb:32:in `<main>'.
127
+ ```
128
+
129
+ ## 7. Abbreviations
130
+
131
+ You can close a line with other `yes` or `no`.
132
+
133
+ ```ruby
134
+ i = 0
135
+ while i < 6
136
+ l.logs "Is #{i}==3?... "
137
+ if i == 3
138
+ l.yes
139
+ else
140
+ l.no
141
+ end
142
+ i += 1
143
+ end
144
+ ```
145
+
146
+ You can close a line with other `ok` or `skip` too.
147
+
148
+
149
+ ```ruby
150
+ i = 0
151
+ while i < 6
152
+ l.logs "Only even numbers: #{i}... "
153
+ if i % 2 == 0
154
+ l.ok
155
+ else
156
+ l.skip
157
+ end
158
+ i += 1
159
+ end
160
+ ```
161
+
162
+ ## 8. Skipping With Details
163
+
164
+ ```ruby
165
+ i = 0
166
+ while i < 6
167
+ l.logs "#{i}... "
168
+ if i % 2 == 0
169
+ l.ok
170
+ else
171
+ l.skip(details: 'it is an odd number')
172
+ end
173
+ i += 1
174
+ end
175
+ ```
176
+
177
+ ## 9. Custom Line Closing
178
+
179
+ As you can read above, you can start a log line with the `logs` method, and you can close it with any of the methopds `done`, `error`, `yes`, `no`, `ok` and `skip`.
180
+
181
+ Each method is printed with its own color:
182
+
183
+ - `done`: green.
184
+ - `error`: red.
185
+ - `yes`: green.
186
+ - `no`: yellow.
187
+ - `ok`: green.
188
+ - `skip`: yellow.
189
+
190
+ ## 10. Custom Line Closing
191
+
192
+ If you need to close a line with a specitic text, you can use the `logf` method.
193
+
194
+ You can also add color to your custom text.
195
+
196
+ ```ruby
197
+ i = 0
198
+ while i < 6
199
+ l.logs "#{i}... "
200
+ if i % 2 == 0
201
+ l.ok
202
+ else
203
+ l.logf("rejected".blue)
204
+ end
205
+ i += 1
206
+ end
207
+ ```
208
+
209
+ ## 11. Nesting Lines
210
+
211
+ ```ruby
212
+ l.logs "Skipping odd numbers... "
213
+ i = 0
214
+ while i < 6
215
+ l.logs "#{i}... "
216
+ if i % 2 == 0
217
+ l.ok
218
+ else
219
+ l.skip(details: 'it is an odd number')
220
+ end
221
+ i += 1
222
+ end
223
+ l.done
224
+ ```
225
+
226
+ ```
227
+ 2024-07-26 15:27:04: Skipping odd numbers...
228
+ 2024-07-26 15:27:04: > 0... ok
229
+ 2024-07-26 15:27:04: > 1... skip (it is an odd number)
230
+ 2024-07-26 15:27:04: > 2... ok
231
+ 2024-07-26 15:27:04: > 3... skip (it is an odd number)
232
+ 2024-07-26 15:27:04: > 4... ok
233
+ 2024-07-26 15:27:04: > 5... skip (it is an odd number)
234
+ 2024-07-26 15:27:04: done
235
+ ```
236
+
237
+ ## 12. Nesting Assertions
238
+
239
+ You can setup **simple_cloud_loggin** to check if you are nesting your log correctly.
240
+
241
+ ```ruby
242
+ BlackStack::Logger.set(
243
+ nesting_assertion: true,
244
+ )
245
+ ```
246
+
247
+ Below I wrote 4 diffent examples of wrong nestung usage, and the output of each one.
248
+
249
+ **Example 1:**
250
+
251
+ ```ruby
252
+ begin
253
+ l.blank_line
254
+ l.logs "Looking for number 3... "
255
+ i = 0
256
+ while i < 6
257
+ l.logs "#{i}... "
258
+ if i == 3
259
+ #l.yes # --> I missed to close the log line !
260
+ else
261
+ l.no
262
+ end
263
+ i += 1
264
+ end
265
+ l.done
266
+ rescue => e
267
+ l.error(e)
268
+ end
269
+ ```
270
+
271
+ ```
272
+ 2024-07-26 15:58:43:
273
+ 2024-07-26 15:58:43: Looking for number 3...
274
+ 2024-07-26 15:58:43: > 0... no
275
+ 2024-07-26 15:58:43: > 1... no
276
+ 2024-07-26 15:58:43: > 2... no
277
+ 2024-07-26 15:58:43: > 3... error: Log nesting assertion: You missed to close the log-level that you opened at assertion1.rb:15:in `<main>'.
278
+ /home/leandro/code/simple_cloud_logging/lib/baselogger.rb:150:in `logs'
279
+ /home/leandro/code/simple_cloud_logging/lib/locallogger.rb:46:in `logs'
280
+ assertion1.rb:15:in `<main>'.
281
+ ```
282
+
283
+ **Example 2:**
284
+
285
+ ```ruby
286
+ begin
287
+ l.blank_line
288
+ l.logs "Looking for number 3... "
289
+ i = 0
290
+ while i < 6
291
+ #l.logs "#{i}... " # --> I missed to open the log.
292
+ if i == 3
293
+ l.yes
294
+ else
295
+ l.no
296
+ end
297
+ i += 1
298
+ end
299
+ l.done
300
+ rescue => e
301
+ l.error(e)
302
+ end
303
+ ```
304
+
305
+ ```
306
+ 2024-07-26 15:59:44:
307
+ 2024-07-26 15:59:44: Looking for number 3... no
308
+ error: 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.
309
+ /home/leandro/code/simple_cloud_logging/lib/baselogger.rb:218:in `logf'
310
+ /home/leandro/code/simple_cloud_logging/lib/locallogger.rb:53:in `logf'
311
+ /home/leandro/code/simple_cloud_logging/lib/baselogger.rb:261:in `no'
312
+ assertion2.rb:19:in `<main>'.
313
+ ```
314
+
315
+ **Example 3:**
316
+
317
+ ```ruby
318
+ begin
319
+ l.blank_line
320
+ #l.logs "Looking for number 3... " # --> I missed to open the log.
321
+ i = 0
322
+ while i < 6
323
+ l.logs "#{i}... "
324
+ if i == 3
325
+ l.yes
326
+ else
327
+ l.no
328
+ end
329
+ i += 1
330
+ end
331
+ l.done
332
+ rescue => e
333
+ l.error(e)
334
+ end
335
+ ```
336
+
337
+ ```
338
+ 2024-07-26 16:00:41:
339
+ 2024-07-26 16:00:41: 0... no
340
+ 2024-07-26 16:00:41: 1... no
341
+ 2024-07-26 16:00:41: 2... no
342
+ 2024-07-26 16:00:41: 3... yes
343
+ 2024-07-26 16:00:41: 4... no
344
+ 2024-07-26 16:00:41: 5... no
345
+ error: 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.
346
+ /home/leandro/code/simple_cloud_logging/lib/baselogger.rb:218:in `logf'
347
+ /home/leandro/code/simple_cloud_logging/lib/locallogger.rb:53:in `logf'
348
+ /home/leandro/code/simple_cloud_logging/lib/baselogger.rb:233:in `done'
349
+ assertion3.rb:23:in `<main>'.
350
+ ```
351
+
352
+ **Example 4:**
353
+
354
+ ```ruby
355
+ begin
356
+ l.blank_line
357
+ l.logs "Looking for number 3... "
358
+ i = 0
359
+ while i < 6
360
+ l.logs "#{i}... "
361
+ if i == 3
362
+ l.yes
363
+ l.no # --> I closed the same level 2 times by mistake
364
+ else
365
+ l.no
366
+ end
367
+ i += 1
368
+ end
369
+ l.done
370
+ rescue => e
371
+ l.error(e)
372
+ end
373
+ ```
374
+
375
+ ```
376
+ 2024-07-26 16:01:23:
377
+ 2024-07-26 16:01:23: Looking for number 3...
378
+ 2024-07-26 16:01:23: > 0... no
379
+ 2024-07-26 16:01:23: > 1... no
380
+ 2024-07-26 16:01:23: > 2... no
381
+ 2024-07-26 16:01:23: > 3... yes
382
+ 2024-07-26 16:01:23: no
383
+ 2024-07-26 16:01:23: 4... no
384
+ 2024-07-26 16:01:23: 5... no
385
+ error: 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.
386
+ /home/leandro/code/simple_cloud_logging/lib/baselogger.rb:218:in `logf'
387
+ /home/leandro/code/simple_cloud_logging/lib/locallogger.rb:53:in `logf'
388
+ /home/leandro/code/simple_cloud_logging/lib/baselogger.rb:233:in `done'
389
+ assertion4.rb:24:in `<main>'.
390
+ ```
391
+
392
+ ## 13. Size Control
393
+
394
+ ```ruby
395
+ BlackStack::Logger.set(
396
+ min_size: 6*1024, # 6KB bytes
397
+ max_size: 10*1024 # 10KB bytes
398
+ )
399
+ ```
400
+
401
+ Each time the logfile grows over `max_size` bytes, it will be dropbed to `min_size` bytes.
402
+
403
+ The dropping is made by dropping the head lines. The tail is preserved.
404
+
405
+ ## 14. Disabling Colorization
406
+
407
+ ```ruby
408
+ BlackStack::Logger.set(
409
+ colorize: false,
410
+ )
411
+ ```
412
+
413
+ Disabling colorization gets **simple_cloud_logging** overwritting the instance methods `green`, `red`, `blue` and `yellow` of the class `String` to make them non-effect.
414
+
415
+ If you require the `colorize` gem after the logger setup, colors will be activated again.
416
+
417
+ ## 15. Showing Nesting Level
418
+
419
+ If you are working with nested logs, you can show the nesting level of the current line.
420
+
421
+ This feature is useful if you want to visualize where you open and close each loggin line.
422
+
423
+ ```ruby
424
+ BlackStack::Logger.set(
425
+ show_nesting_level: true,
426
+ )
427
+ ```
428
+
429
+ ```
430
+ 2024-07-26 16:07:43 - level 0:
431
+ 2024-07-26 16:07:43 - level 0: Looking for number 3...
432
+ 2024-07-26 16:07:43 - level 1: > 0... no
433
+ 2024-07-26 16:07:43 - level 1: > 1... no
434
+ 2024-07-26 16:07:43 - level 1: > 2... no
435
+ 2024-07-26 16:07:43 - level 1: > 3... yes
436
+ 2024-07-26 16:07:43 - level 1: > 4... no
437
+ 2024-07-26 16:07:43 - level 1: > 5... no
438
+ 2024-07-26 16:07:43 - level 1: done
439
+ ```
440
+
441
+ ## 16. Showing Callers
442
+
443
+ You can show from which like in your souce code you opened each log line.
444
+
445
+ This feature is useful if you want to visualize and fix nesting errors.
446
+
447
+ ```ruby
448
+ BlackStack::Logger.set(
449
+ show_nesting_caller: true,
450
+ )
451
+ ```
452
+
453
+ ```
454
+ 2024-07-26 16:10:59 - caller show_caller.rb:12:in `<main>': Looking for number 3...
455
+ 2024-07-26 16:10:59 - caller show_caller.rb:15:in `<main>': > 0... no
456
+ 2024-07-26 16:10:59 - caller show_caller.rb:15:in `<main>': > 1... no
457
+ 2024-07-26 16:10:59 - caller show_caller.rb:15:in `<main>': > 2... no
458
+ 2024-07-26 16:10:59 - caller show_caller.rb:15:in `<main>': > 3... yes
459
+ 2024-07-26 16:10:59 - caller show_caller.rb:15:in `<main>': > 4... no
460
+ 2024-07-26 16:10:59 - caller show_caller.rb:15:in `<main>': > 5... no
461
+ 2024-07-26 16:10:59: done
462
+ ```
463
+
464
+ ## 17. Dummy Loggers
465
+
466
+ The methods of the `DummyLogger` class just do nothing.
467
+
468
+ You can choose between `LocalLogger` or `DummyLogger` depending if you want to write log or not, dynamically.
469
+
470
+ `DummyLogger` is useful to pass or not a logger to a function, for deep-nested logging.
471
+
472
+ **Example:**
473
+
474
+ ```ruby
475
+ class FooClass
476
+ attr_accessor :logger
477
+
478
+ def initialize(the_logger=nil)
479
+ self.logger=the_logger
480
+ self.logger = BlackStack::DummyLogger.new(nil) if self.logger.nil? # assign a dummy logger that just generate output on the screen
481
+ end
482
+
483
+ def do_something()
484
+ self.logger.logs 'This log line will show up in the console only if the logger is not a DummyLogger instance...'
485
+ # do something here
486
+ self.logger.done
487
+ end
488
+ end # class FooClass
489
+ ```
490
+
491
+ ## 18. Versioning
492
+
493
+ We use [SemVer](http://semver.org/) for versioning. For the versions available, see the last [ruby gem](https://rubygems.org/gems/simple_command_line_parser).
494
+
495
+ ## 19. Authors
496
+
497
+ * **Leandro Daniel Sardi** - *Initial work* - [LeandroSardi](https://github.com/leandrosardi)
498
+
499
+ ## 20. License
500
+
501
+ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
502
+
@@ -0,0 +1,26 @@
1
+ require_relative '../lib/simple_cloud_logging'
2
+
3
+ BlackStack::Logger.set(
4
+ nesting_assertion: true,
5
+ )
6
+
7
+ # create a logger
8
+ l = BlackStack::LocalLogger.new("assertion.log")
9
+
10
+ begin
11
+ l.blank_line
12
+ l.logs "Looking for number 3... "
13
+ i = 0
14
+ while i < 6
15
+ l.logs "#{i}... "
16
+ if i == 3
17
+ #l.yes # --> I missed to close the log line !
18
+ else
19
+ l.no
20
+ end
21
+ i += 1
22
+ end
23
+ l.done
24
+ rescue => e
25
+ l.error(e)
26
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '../lib/simple_cloud_logging'
2
+
3
+ BlackStack::Logger.set(
4
+ nesting_assertion: true,
5
+ )
6
+
7
+ # create a logger
8
+ l = BlackStack::LocalLogger.new("assertion.log")
9
+
10
+ begin
11
+ l.blank_line
12
+ l.logs "Looking for number 3... "
13
+ i = 0
14
+ while i < 6
15
+ #l.logs "#{i}... " # --> I missed to open the log.
16
+ if i == 3
17
+ l.yes
18
+ else
19
+ l.no
20
+ end
21
+ i += 1
22
+ end
23
+ l.done
24
+ rescue => e
25
+ l.error(e)
26
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '../lib/simple_cloud_logging'
2
+
3
+ BlackStack::Logger.set(
4
+ nesting_assertion: true,
5
+ )
6
+
7
+ # create a logger
8
+ l = BlackStack::LocalLogger.new("assertion.log")
9
+
10
+ begin
11
+ l.blank_line
12
+ #l.logs "Looking for number 3... " # --> I missed to open the log.
13
+ i = 0
14
+ while i < 6
15
+ l.logs "#{i}... "
16
+ if i == 3
17
+ l.yes
18
+ else
19
+ l.no
20
+ end
21
+ i += 1
22
+ end
23
+ l.done
24
+ rescue => e
25
+ l.error(e)
26
+ end
@@ -0,0 +1,27 @@
1
+ require_relative '../lib/simple_cloud_logging'
2
+
3
+ BlackStack::Logger.set(
4
+ nesting_assertion: true,
5
+ )
6
+
7
+ # create a logger
8
+ l = BlackStack::LocalLogger.new("assertion.log")
9
+
10
+ begin
11
+ l.blank_line
12
+ l.logs "Looking for number 3... "
13
+ i = 0
14
+ while i < 6
15
+ l.logs "#{i}... "
16
+ if i == 3
17
+ l.yes
18
+ l.no # --> I closed the same level 2 times by mistake
19
+ else
20
+ l.no
21
+ end
22
+ i += 1
23
+ end
24
+ l.done
25
+ rescue => e
26
+ l.error(e)
27
+ end
@@ -0,0 +1,81 @@
1
+ require_relative '../lib/simple_cloud_logging'
2
+
3
+ # create a logger
4
+ l = BlackStack::LocalLogger.new("examples.log")
5
+
6
+ l.blank_line
7
+ l.log "Example 1:"
8
+ l.logs "Calculate 1+1... "
9
+ n = 1 + 1
10
+ l.done
11
+
12
+ l.blank_line
13
+ l.log "Example 2:"
14
+ l.logs "Calculate 1+1... "
15
+ n = 1 + 1
16
+ l.done(details: n)
17
+
18
+ l.blank_line
19
+ l.log "Example 3:"
20
+ l.logs "Calculate 4/2... "
21
+ begin
22
+ n = 4/2
23
+ l.done(details: n)
24
+ rescue => e
25
+ l.error(e)
26
+ end
27
+
28
+ l.blank_line
29
+ l.log "Example 4:"
30
+ l.logs "Calculate 4/0... "
31
+ begin
32
+ n = 4/0
33
+ l.done(details: n)
34
+ rescue => e
35
+ l.error(e)
36
+ end
37
+
38
+ l.blank_line
39
+ l.log "Example 5:"
40
+ l.logs "Looking for number 3... "
41
+ i = 0
42
+ while i < 6
43
+ l.logs "#{i}... "
44
+ if i == 3
45
+ l.yes
46
+ else
47
+ l.no
48
+ end
49
+ i += 1
50
+ end
51
+ l.done
52
+
53
+ l.blank_line
54
+ l.log "Example 6:"
55
+ l.logs "Skipping odd numbers... "
56
+ i = 0
57
+ while i < 6
58
+ l.logs "#{i}... "
59
+ if i % 2 == 0
60
+ l.ok
61
+ else
62
+ l.skip
63
+ end
64
+ i += 1
65
+ end
66
+ l.done
67
+
68
+ l.blank_line
69
+ l.log "Example 7:"
70
+ l.logs "Skipping odd numbers... "
71
+ i = 0
72
+ while i < 6
73
+ l.logs "#{i}... "
74
+ if i % 2 == 0
75
+ l.ok
76
+ else
77
+ l.skip(details: 'it is an odd number')
78
+ end
79
+ i += 1
80
+ end
81
+ l.done
@@ -0,0 +1,18 @@
1
+ require_relative '../lib/simple_cloud_logging'
2
+
3
+ BlackStack::Logger.set(
4
+ min_size: 6*1024, # 6KB bytes
5
+ max_size: 10*1024, # 10KB bytes
6
+ show_nesting_level: true,
7
+ show_nesting_caller: true,
8
+ colorize: true
9
+ )
10
+
11
+ # create a logger
12
+ l = BlackStack::LocalLogger.new("max_size.log")
13
+
14
+ i=0
15
+ while i<100000
16
+ l.log "number:#{i}"
17
+ i += 1
18
+ end
@@ -0,0 +1,29 @@
1
+ # overwrite the instance methods green, red, blue and yellow of the class String to make them non-effect.
2
+ # if you require the colorize gem after the logger setup, colors will be activated again.
3
+
4
+ require_relative '../lib/simple_cloud_logging'
5
+
6
+ # create a logger
7
+ l = BlackStack::LocalLogger.new("no-colors.log")
8
+
9
+ BlackStack::Logger.set(
10
+ colorize: false,
11
+ )
12
+
13
+ begin
14
+ l.blank_line
15
+ l.logs "Looking for number 3... "
16
+ i = 0
17
+ while i < 6
18
+ l.logs "#{i}... "
19
+ if i == 3
20
+ l.yes
21
+ else
22
+ l.no
23
+ end
24
+ i += 1
25
+ end
26
+ l.done
27
+ rescue => e
28
+ l.error(e)
29
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '../lib/simple_cloud_logging'
2
+
3
+ # create a logger
4
+ l = BlackStack::LocalLogger.new("show_caller.log")
5
+
6
+ BlackStack::Logger.set(
7
+ show_nesting_caller: true,
8
+ )
9
+
10
+ begin
11
+ l.blank_line
12
+ l.logs "Looking for number 3... "
13
+ i = 0
14
+ while i < 6
15
+ l.logs "#{i}... "
16
+ if i == 3
17
+ l.yes
18
+ else
19
+ l.no
20
+ end
21
+ i += 1
22
+ end
23
+ l.done
24
+ rescue => e
25
+ l.error(e)
26
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '../lib/simple_cloud_logging'
2
+
3
+ # create a logger
4
+ l = BlackStack::LocalLogger.new("show_level.log")
5
+
6
+ BlackStack::Logger.set(
7
+ show_nesting_level: true,
8
+ )
9
+
10
+ begin
11
+ l.blank_line
12
+ l.logs "Looking for number 3... "
13
+ i = 0
14
+ while i < 6
15
+ l.logs "#{i}... "
16
+ if i == 3
17
+ l.yes
18
+ else
19
+ l.no
20
+ end
21
+ i += 1
22
+ end
23
+ l.done
24
+ rescue => e
25
+ l.error(e)
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_cloud_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
@@ -56,6 +56,16 @@ executables: []
56
56
  extensions: []
57
57
  extra_rdoc_files: []
58
58
  files:
59
+ - README.md
60
+ - examples/assertion1.rb
61
+ - examples/assertion2.rb
62
+ - examples/assertion3.rb
63
+ - examples/assertion4.rb
64
+ - examples/examples.rb
65
+ - examples/max_size.rb
66
+ - examples/no-colors.rb
67
+ - examples/show_caller.rb
68
+ - examples/show_level.rb
59
69
  - lib/baselogger.rb
60
70
  - lib/dummylogger.rb
61
71
  - lib/locallogger.rb