logzomg 0.1.0.7 → 0.1.0.8
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/.gitignore +1 -1
- data/lib/formatters/text_formatter.rb +4 -2
- data/lib/logzomg.rb +15 -10
- data/lib/logzomg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d264f9491f0647d35cfa53b035197f7edfa2c7f
|
4
|
+
data.tar.gz: e05ec63bf2abd4251ae7af19a83665a2841f1a15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17aef22ec720a4223cbb8b3bbf8244695114076c9febd0a0b4d12cb00f8fa11987bb70966aee9300d912217f5ed3e0d3f73e879ef585cbc483ab462d03dfd4db
|
7
|
+
data.tar.gz: c8e9f9438cf0ad8fb0516f1183fbcf7bb4aa5838912a54cd655d7abe918648f96739d1ee61cf09ca6d3eb4f0f80ebc0bf580d37ce2aa5975a7e79199faabe1d8
|
data/.gitignore
CHANGED
@@ -31,9 +31,10 @@ class TextFormatter
|
|
31
31
|
|
32
32
|
s_msg.each do |n|
|
33
33
|
str += count == 0 ? "#{add_log_level(str)}#{get_date} | " : "#{add_log_level(str)}"
|
34
|
-
str += count == 0 ? "#{n}\n" : " " * (get_date.length) + " |
|
34
|
+
str += count == 0 ? "#{n}\n" : " " * (get_date.length) + " | #{n}\n" # Indent if 2nd+ iteration
|
35
35
|
count += 1
|
36
36
|
end
|
37
|
+
|
37
38
|
str
|
38
39
|
end
|
39
40
|
|
@@ -76,6 +77,7 @@ class TextFormatter
|
|
76
77
|
def split_msg(msg)
|
77
78
|
sub_end = MAX_CHAR - 5
|
78
79
|
# Goes back to start of word if matches inside a word. If it matches inside a coloured key go back to start of word before colour
|
79
|
-
|
80
|
+
# Remove starting whitespace. Sometimes creates empty array indice so remove if length isn't long enough
|
81
|
+
arr = msg.scan(/.{0,#{Regexp.escape(sub_end.to_s)}}[\\033\[0-90-9m\w\\e\[0m\ ]{0}(?:\ |$)/mi).select { |s| s.length > 1 }.each { |n| n.slice!(0) if n[0] == " "}
|
80
82
|
end
|
81
83
|
end
|
data/lib/logzomg.rb
CHANGED
@@ -12,7 +12,7 @@ module Logzomg
|
|
12
12
|
attr_accessor :log_path
|
13
13
|
|
14
14
|
def initialize(**args, &block)
|
15
|
-
@log_path =
|
15
|
+
@log_path = get_log_path
|
16
16
|
@level = args[:level] ? args[:level] : "warning"
|
17
17
|
@formatter = args[:formatter] ? args[:formatter] : TextFormatter.new {|f| f.with_color = true}
|
18
18
|
if block_given?
|
@@ -83,10 +83,11 @@ module Logzomg
|
|
83
83
|
wild: true,
|
84
84
|
msg: "Something has been spotted!",
|
85
85
|
damn: "son",
|
86
|
-
damn2:
|
87
|
-
damn3:
|
88
|
-
|
89
|
-
|
86
|
+
damn2: "son",
|
87
|
+
damn3: "son",
|
88
|
+
object: Object.new,
|
89
|
+
damn4: "son",
|
90
|
+
damn5: "son",
|
90
91
|
level: "info"
|
91
92
|
})
|
92
93
|
self.log({
|
@@ -114,18 +115,22 @@ module Logzomg
|
|
114
115
|
File.open(@log_path + file, 'a') {|f| f.write(msg) }
|
115
116
|
end
|
116
117
|
|
117
|
-
def get_path
|
118
|
-
Dir.pwd
|
119
|
-
end
|
120
|
-
|
121
118
|
# Checks if message is hash
|
122
119
|
def valid_hash?(hash)
|
123
|
-
return hash.
|
120
|
+
return hash.is_a?(Hash)
|
124
121
|
end
|
125
122
|
|
126
123
|
# Checks if the level value is valid (part of LEVELS)
|
127
124
|
def valid_level?(level)
|
128
125
|
return !level.nil? && LEVELS.any? { |l| l == level.downcase }
|
129
126
|
end
|
127
|
+
|
128
|
+
def get_log_path
|
129
|
+
if defined?(Rails)
|
130
|
+
File.expand_path(Rails.root.to_s + '/log/')
|
131
|
+
else
|
132
|
+
File.expand_path('log/')
|
133
|
+
end
|
134
|
+
end
|
130
135
|
end
|
131
136
|
end
|
data/lib/logzomg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logzomg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rasmus
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|