Skip to content

Commit 0b5b20b

Browse files
committed
Setup dep && add colors :)
1 parent 8ef82b1 commit 0b5b20b

File tree

4 files changed

+105
-5
lines changed

4 files changed

+105
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ bin/
1717
src/
1818
pkg/
1919
build/
20+
vendor/
21+
22+
tailmq

Gopkg.lock

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Gopkg.toml example
2+
#
3+
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4+
# for detailed Gopkg.toml documentation.
5+
#
6+
# required = ["github.com/user/thing/cmd/thing"]
7+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8+
#
9+
# [[constraint]]
10+
# name = "github.com/user/project"
11+
# version = "1.0.0"
12+
#
13+
# [[constraint]]
14+
# name = "github.com/user/project2"
15+
# branch = "dev"
16+
# source = "github.com/myfork/project2"
17+
#
18+
# [[override]]
19+
# name = "github.com/x/y"
20+
# version = "2.4.0"
21+
#
22+
# [prune]
23+
# non-go = false
24+
# go-tests = true
25+
# unused-packages = true
26+
27+
28+
[[constraint]]
29+
branch = "master"
30+
name = "github.com/logrusorgru/aurora"
31+
32+
[[constraint]]
33+
name = "github.com/satori/go.uuid"
34+
version = "1.2.0"
35+
36+
[[constraint]]
37+
branch = "master"
38+
name = "github.com/streadway/amqp"
39+
40+
[[constraint]]
41+
name = "gopkg.in/yaml.v2"
42+
version = "2.2.2"
43+
44+
[prune]
45+
go-tests = true
46+
unused-packages = true

tailmq.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/olaurendeau/tailmq/consumer"
1414
"github.com/streadway/amqp"
15+
"github.com/logrusorgru/aurora"
1516
)
1617

1718
const Help = `DESCRIPTION
@@ -38,6 +39,7 @@ type Config struct {
3839
exchangeName string
3940
routingKey string
4041
globalConfigFilePath *string
42+
noColors *bool
4143
global GlobalConfig
4244
}
4345

@@ -54,6 +56,7 @@ func main() {
5456
config.verbose = flag.Bool("verbose", false, "Do you want more informations ?")
5557
config.help = flag.Bool("help", false, "How does it work ?")
5658
config.globalConfigFilePath = flag.String("config", "", "Path of the global config file to use")
59+
config.noColors = flag.Bool("no-colors", false, "If you don't want a colorful life :'(")
5760
flag.Parse()
5861

5962
config.global, err = NewGlobalConfig(*config.globalConfigFilePath)
@@ -89,17 +92,19 @@ func main() {
8992
}
9093

9194
func printDelivery(d amqp.Delivery, config *Config) {
95+
96+
au := aurora.NewAurora(!*config.noColors)
97+
9298
if *config.prefix {
93-
fmt.Printf("[%s]", time.Now().Format("2006-01-02 15:04:05"))
99+
fmt.Printf("%s", au.Green(fmt.Sprintf("[%s]", time.Now().Format("2006-01-02 15:04:05"))))
94100
if d.RoutingKey != "" {
95-
fmt.Printf(" %s ", d.RoutingKey)
101+
fmt.Printf(" %s ", au.Green(d.RoutingKey))
96102
}
97-
fmt.Printf(" ")
103+
fmt.Printf("\n")
98104
}
99105
if *config.header {
100-
fmt.Printf("\n")
101106
for k,v := range(d.Headers) {
102-
fmt.Printf("Header : %s=%s\n", k, v)
107+
fmt.Printf("%s", au.Cyan(fmt.Sprintf("Header : %s=%s\n", k, v)))
103108
}
104109
}
105110
fmt.Printf("%s\n", d.Body)

0 commit comments

Comments
 (0)