Skip to content

Commit 972eaca

Browse files
committed
v1.1.0 - crayon dependency removed
1 parent 2d1e13b commit 972eaca

File tree

4 files changed

+28
-45
lines changed

4 files changed

+28
-45
lines changed

shard.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
name: epilog
2-
version: 1.0.0
2+
version: 1.1.0
33

44
authors:
55
- Mark Molnar <[email protected]>
66

77
dependencies:
8-
crayon:
9-
github: crystalrealm/crayon
108
stringpad:
119
github: crystalrealm/stringpad
1210

src/epilog.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require "./epilog/*"
22

33
module Epilog
4-
VERSION = "1.0.0"
4+
VERSION = "1.1.0"
55
end

src/epilog/log_types.cr

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,53 @@ module Epilog::LogTypes
22
@options = {
33
"success" => {
44
"emoji" => "",
5-
"foreground" => "light_green",
6-
"background" => "black",
5+
"foreground" => :light_green,
6+
"background" => :black,
77
},
88
"error" => {
99
"emoji" => "",
10-
"foreground" => "red",
11-
"background" => "black",
10+
"foreground" => :red,
11+
"background" => :black,
1212
},
1313
"fatal" => {
1414
"emoji" => "",
15-
"foreground" => "red",
16-
"background" => "black",
15+
"foreground" => :red,
16+
"background" => :black,
1717
},
1818
"warn" => {
1919
"emoji" => "",
20-
"foreground" => "yellow",
21-
"background" => "black",
20+
"foreground" => :yellow,
21+
"background" => :black,
2222
},
2323
"log" => {
2424
"emoji" => "",
25-
"foreground" => "white",
26-
"background" => "black",
25+
"foreground" => :white,
26+
"background" => :black,
2727
},
2828
"info" => {
2929
"emoji" => "",
30-
"foreground" => "blue",
31-
"background" => "black",
30+
"foreground" => :blue,
31+
"background" => :black,
3232
},
3333
"start" => {
3434
"emoji" => "",
35-
"foreground" => "blue",
36-
"background" => "black",
35+
"foreground" => :blue,
36+
"background" => :black,
3737
},
3838
"ready" => {
3939
"emoji" => "",
40-
"foreground" => "green",
41-
"background" => "black",
40+
"foreground" => :green,
41+
"background" => :black,
4242
},
4343
"debug" => {
4444
"emoji" => "",
45-
"foreground" => "dark_gray",
46-
"background" => "black",
45+
"foreground" => :dark_gray,
46+
"background" => :black,
4747
},
4848
"trace" => {
4949
"emoji" => "",
50-
"foreground" => "dark_gray",
51-
"background" => "black",
50+
"foreground" => :dark_gray,
51+
"background" => :black,
5252
},
5353
}
5454
end

src/epilog/reporters/fancy.cr

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,17 @@
1-
require "crayon"
21
require "stringpad"
2+
require "colorize"
33
require "../log_types"
44

55
module Epilog
6-
WHITE = Crayon::Crayon.new("white", "black")
7-
86
class FancyReporter
97
include Epilog::LogTypes
108

11-
@crayon_instances = {} of String => Crayon::Crayon
12-
13-
def initialize
14-
@options.each_key do |key|
15-
emoji = @options[key]["emoji"].as(String)
16-
foreground = @options[key]["foreground"].as(String)
17-
background = @options[key]["background"].as(String)
18-
@crayon_instances[key] = Crayon::Crayon.new(foreground, background, {
19-
"bold" => true,
20-
})
21-
end
22-
end
23-
249
def format(log_type, message)
25-
colors = @crayon_instances.fetch(log_type)
26-
emoji = @options[log_type]["emoji"].as(String)
27-
colored_emoji = colors.apply(emoji)
28-
colored_log_type = colors.apply(log_type)
29-
colored_message = WHITE.apply(message)
10+
foreground = @options[log_type]["foreground"].as(Symbol)
11+
background = @options[log_type]["background"].as(Symbol)
12+
colored_emoji = @options[log_type]["emoji"].colorize.fore(foreground).back(background).mode(:bold)
13+
colored_log_type = log_type.colorize.fore(foreground).back(background).mode(:bold)
14+
colored_message = message.colorize(:white)
3015
"#{colored_emoji} #{Stringpad.rpad(colored_log_type, " ", 8 - log_type.size)} #{colored_message}"
3116
end
3217
end

0 commit comments

Comments
 (0)