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.
- checksums.yaml +4 -4
- data/lib/debug_logger.rb +32 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0c00a7f02d36a283ad28d736e7f646a956c76ce2924ccf2ccb8a3ff0b53edc9
|
4
|
+
data.tar.gz: 3512e086f7fc599768e0ca46c6540fff37a5b466ccbd89f9a4c7dfb4193744dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 970aaa84c6ea2186bafa178fa116c2f219331a8e4ca9cae23e50f7ccd1084348a6c4a3d2bd44690edc036c20fa70cdd8cd5c031ac804c4dd59ee8a830980a174
|
7
|
+
data.tar.gz: 96fd43dd8f767987be6bcd3427bf896997b01d059fc023d2f06d401070a1af2dd9479363004b7553a03bc592e546312e032f9f793bc71d50aab649647b16170f
|
data/lib/debug_logger.rb
CHANGED
@@ -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
|
-
|
5
|
+
log_text = "#{requires.space_signification} \e[#{requires.color_signification}m #{text}====================>#{variables}====================\e[0m #{requires.space_signification}"
|
6
6
|
else
|
7
|
-
|
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
|