debug_logger 0.0.4.1 → 0.0.5

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/debug_logger.rb +32 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 690e37e85ff91ea12767873db8c67b5a77a87e2ccf5ccfee871060408b022c40
4
- data.tar.gz: f657b870ad5e1078c311aa585c0a8005013924353b6516220a7dc9b84a4a6b6f
3
+ metadata.gz: d0c00a7f02d36a283ad28d736e7f646a956c76ce2924ccf2ccb8a3ff0b53edc9
4
+ data.tar.gz: 3512e086f7fc599768e0ca46c6540fff37a5b466ccbd89f9a4c7dfb4193744dc
5
5
  SHA512:
6
- metadata.gz: ab670cb34fd6b1f604450cdbd273fc6cf7b6a0226388ef9c249be54ab5b3223551c140f0c94665d47a7892391744f56f3a8831cbc502ada5dab81c5d866c6ad1
7
- data.tar.gz: ac844829eae9fc24fbfcf7f3b6ac2aa6e6c05dafe768986adfed16da1931b22d42cbd6bfd50e5d0118971fc8d2d677f93d8ee263686c3d5312128b032be90b2f
6
+ metadata.gz: 970aaa84c6ea2186bafa178fa116c2f219331a8e4ca9cae23e50f7ccd1084348a6c4a3d2bd44690edc036c20fa70cdd8cd5c031ac804c4dd59ee8a830980a174
7
+ data.tar.gz: 96fd43dd8f767987be6bcd3427bf896997b01d059fc023d2f06d401070a1af2dd9479363004b7553a03bc592e546312e032f9f793bc71d50aab649647b16170f
@@ -1,11 +1,14 @@
1
1
  class DebugLogger
2
- def self.log(color, text, variables = nil, space = nil)
2
+ def self.log(color, text, variables = nil, storage = nil, space = nil)
3
3
  requires = Requires.new(color, space)
4
4
  if variables
5
- puts "#{requires.space_signification} \e[#{requires.color_signification}m #{text}====================>#{variables}====================\e[0m #{requires.space_signification}"
5
+ log_text = "#{requires.space_signification} \e[#{requires.color_signification}m #{text}====================>#{variables}====================\e[0m #{requires.space_signification}"
6
6
  else
7
- puts "#{requires.space_signification} \e[#{requires.color_signification}m #{text}\e[0m #{requires.space_signification}"
7
+ log_text = "#{requires.space_signification} \e[#{requires.color_signification}m #{text}\e[0m #{requires.space_signification}"
8
8
  end
9
+
10
+ DebugLogger::DataStore.new(log_text).save_log if storage
11
+ puts log_text
9
12
  end
10
13
 
11
14
  def self.color_lists
@@ -62,3 +65,29 @@ class DebugLogger::Requires
62
65
  [:black, :red, :green, :orange, :blue, :pink, :cyan, :white, :normal, :bold, :italic, :underline]
63
66
  end
64
67
  end
68
+
69
+ class DebugLogger::DataStore
70
+
71
+ attr_accessor :log
72
+
73
+ def initialize(log)
74
+ @log = log
75
+ end
76
+
77
+ def self.logs
78
+ File.open('data_store/data.txt', 'r') do |f|
79
+ f.each_line do |line|
80
+ puts line
81
+ end
82
+ end
83
+ end
84
+
85
+ def self.reset_logs
86
+ File.open('data_store/data.txt', 'w') { |file| file.truncate(0) }
87
+ end
88
+
89
+ def save_log
90
+ File.write('data_store/data.txt', log, mode: 'a')
91
+ File.write('data_store/data.txt', "\n", mode: 'a')
92
+ end
93
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debug_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.1
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antonin Touron