pretty_logger 1.2.4 → 1.3.1

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: adb0a8da769a0e1e2f0bf33548dd9e77cd501164f51bcbc808b49a1821fe949f
4
- data.tar.gz: '06680f5e6a34db9fe08b86bf654983a5626fae9a24f6ed1b0c27dd660831a803'
3
+ metadata.gz: caa795717544b44795de0d34e773af0f5023b4c915d77dffa17b845213102598
4
+ data.tar.gz: 9c625f238d6a4439b9eecc9001a20a9547478d1cb7019e0f4a4a73383ed914cb
5
5
  SHA512:
6
- metadata.gz: 3f145c713a3e429bb2cf921f46d87298832eaa6a20addd125bb6d4806887acfb8e0289c6cf9c49d35effa3ce8e07fc69876a09e7207abc954ed946dc8f202a44
7
- data.tar.gz: 4aa36436bf013c21f8d06deb5f3107b947f654b0bca46f875fdede78fe4c6756f3ee91e34edbe17e2601391be690984d5862e15e02f1afb0a923119cabad4b5b
6
+ metadata.gz: 4ec4437e5e2e606379d78a2ff204df9496afaf57defad36ccd041ce3c09416509185c7798bf3cf295322fa81e0415cc834f22282a436ae1581709f44e0f19cdc
7
+ data.tar.gz: b05e4b0f64a9be090e4850f99925782ee96746286ff3c16036b88eb4c104700b5291b9e25b87597ee7904a8adf62f4055d917e7eceafb229c3338384669bb7f0
@@ -1,6 +1,13 @@
1
1
  module PrettyLogger
2
2
  module_function
3
3
 
4
+ COLORS = {
5
+ debug: "\e[90m",
6
+ info: "\e[96m",
7
+ warn: "\e[93m",
8
+ error: "\e[31m",
9
+ }
10
+
4
11
  def instance
5
12
  @instance ||= ::ActiveSupport::Logger.new("log/custom.log")
6
13
  end
@@ -16,23 +23,31 @@ module PrettyLogger
16
23
  /\e\[36m:(\w+)\e\[0m=>/i, ("\e[36m" + '\1: ' + "\e[0m") # hashrocket(sym) to colon(sym)
17
24
  ).gsub(
18
25
  /\e\[0m=>/, "\e[0m: " # all hashrockets to colons
26
+ ).gsub(
27
+ # grey out nils
28
+ "\e[1;36mnil\e[0m", "\e[1;90mnil\e[0m"
19
29
  )
20
30
  end
21
31
 
32
+ def pretty_log(level, *messages)
33
+ message = messages.compact.map { |m| pretty_message(m) }.join("\n")
34
+ instance.send(level, "\e[90m#{timestamp}#{COLORS[level]}[#{level.to_s[0].upcase}]\e[0m #{message}")
35
+ end
36
+
22
37
  def debug(*messages)
23
- instance.debug("\e[90m#{timestamp}\e[90m[DEBUG]\e[0m " + messages.map { |m| pretty_message(m) }.join("\n"))
38
+ pretty_log(:debug, *messages)
24
39
  end
25
40
 
26
41
  def info(*messages)
27
- instance.info("\e[90m#{timestamp}\e[36m[INFO]\e[0m " + messages.map { |m| pretty_message(m) }.join("\n"))
42
+ pretty_log(:info, *messages)
28
43
  end
29
44
 
30
45
  def warn(*messages)
31
- instance.warn("\e[90m#{timestamp}\e[38;5;208m[WARN]\e[0m " + messages.map { |m| pretty_message(m) }.join("\n"))
46
+ pretty_log(:warn, *messages)
32
47
  end
33
48
 
34
49
  def error(*messages)
35
- instance.error("\e[90m#{timestamp}\e[31m[ERROR]\e[0m " + messages.map { |m| pretty_message(m) }.join("\n"))
50
+ pretty_log(:error, *messages)
36
51
  end
37
52
 
38
53
  def cl
@@ -3,6 +3,8 @@ module PrettyLogger
3
3
  initializer "pretty_logger.configure_rails_initialization" do
4
4
  ActiveSupport.on_load(:action_controller) do
5
5
  include PrettyLogger::ControllerMethods
6
+
7
+ before_action :pretty_logit
6
8
  rescue_from ::StandardError, with: :prettylog_and_reraise!
7
9
  end
8
10
  end
@@ -1,3 +1,3 @@
1
1
  module PrettyLogger
2
- VERSION = "1.2.4"
2
+ VERSION = "1.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretty_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rocco Nicholls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-22 00:00:00.000000000 Z
11
+ date: 2024-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coderay