-
Notifications
You must be signed in to change notification settings - Fork 0
/
logs.go
40 lines (34 loc) · 1.11 KB
/
logs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Logres - Distributed logs system PostgresSQL to MongoDB
// https://github.com/luk4z7/logres for the canonical source repository
//
// Copyright 2017 The Lucas Alves Author. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package logs return instance of gocolorize
package logs
import (
"github.com/agtorre/gocolorize"
"log"
"os"
)
var (
// INFO const return Green log
INFO *log.Logger
// WARNING const return yellow log
WARNING *log.Logger
// CRITICAL const return red log
CRITICAL *log.Logger
)
// Start initiate the instances of gocolorize
func Start() {
info := gocolorize.NewColor("green")
warning := gocolorize.NewColor("yellow")
critical := gocolorize.NewColor("back+u:red")
//helper functions to shorten code
i := info.Paint
w := warning.Paint
c := critical.Paint
INFO = log.New(os.Stdout, i("INFO "), log.Ldate|log.Lmicroseconds|log.Lshortfile)
WARNING = log.New(os.Stdout, w("WARNING "), log.Ldate|log.Lmicroseconds|log.Lshortfile)
CRITICAL = log.New(os.Stdout, c("CRITICAL "), log.Ldate|log.Lmicroseconds|log.Lshortfile)
}