different timestamp format for logs
This commit is contained in:
parent
5566a83291
commit
663e89e735
|
@ -4,6 +4,8 @@ import (
|
|||
"fmt"
|
||||
"github.com/fatih/color"
|
||||
"sync"
|
||||
"time"
|
||||
"log"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -22,6 +24,7 @@ var RedS = color.New(color.FgRed).SprintFunc()
|
|||
var BlueS = color.New(color.FgBlue).SprintFunc()
|
||||
var Blue = color.New(color.FgBlue, color.Bold).SprintFunc()
|
||||
var Yellow = color.New(color.FgYellow, color.Bold).SprintFunc()
|
||||
var YellowS = color.New(color.FgYellow).SprintFunc()
|
||||
var MagentaS = color.New(color.FgMagenta).SprintFunc()
|
||||
var Magenta = color.New(color.FgMagenta, color.Bold).SprintFunc()
|
||||
|
||||
|
@ -29,11 +32,18 @@ var watcherIgnores = []string{"vendor", "bin"}
|
|||
var watcherExts = []string{".go"}
|
||||
var watcherPaths = []string{"/"}
|
||||
|
||||
type logWriter struct {}
|
||||
|
||||
// App struct contains the informations about realize
|
||||
type App struct {
|
||||
Name, Version, Description, Author, Email string
|
||||
}
|
||||
|
||||
func init(){
|
||||
log.SetFlags(0)
|
||||
log.SetOutput(new(logWriter))
|
||||
}
|
||||
|
||||
// Init is an instance of app with default values
|
||||
func Init() *App {
|
||||
return &App{
|
||||
|
@ -50,3 +60,7 @@ func (app *App) Information() {
|
|||
fmt.Println(Blue(app.Name) + " - " + Blue(app.Version))
|
||||
fmt.Println(BlueS(app.Description) + "\n")
|
||||
}
|
||||
|
||||
func (writer logWriter) Write(bytes []byte) (int, error) {
|
||||
return fmt.Print(YellowS("[")+time.Now().UTC().Format("15:04:05") +YellowS("]")+string(bytes))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue