1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-06-18 05:00:03 +02:00

Move source files to "src" folder.

This commit is contained in:
Henrik Hautakoski 2020-03-06 11:35:36 +01:00
parent 8e8393d560
commit 4ef714a750
6 changed files with 1 additions and 1 deletions

49
src/log/log.go Normal file
View file

@ -0,0 +1,49 @@
package log
import "fmt"
// Colors
// ---------------------------------------------------------
const (
InfoColor = "\033[1;34m%s\033[0m"
NoticeColor = "\033[1;36m%s\033[0m"
WarningColor = "\033[1;33m%s\033[0m"
ErrorColor = "\033[1;31m%s\033[0m"
)
// Define LogFunc prototype
// Function that takes a format string and variadic number
// of arguments (like printf)
// ---------------------------------------------------------
type LogFunc func(format string, args ...interface{})
// Create a log function.
// This is the base logging function. by providing a prefix
// a new log function of LogFunc type will be created
// appending "[ <prefix> ]" before the message.
// ---------------------------------------------------------
func logfn(prefix string) LogFunc {
return func(format string, args ...interface{}) {
format = "[" + prefix + "] " + format + "\n"
fmt.Printf(format, args...)
}
}
// Declare our different log functions.
// ---------------------------------------------------------
var Info LogFunc
var Notice LogFunc
var Warning LogFunc
var Error LogFunc
// Initilize log module
// ---------------------------------------------------------
func init() {
// Initilize functions.
Info = logfn(fmt.Sprintf(InfoColor, "INFO"))
Notice = logfn(fmt.Sprintf(NoticeColor, "NOTICE"))
Warning = logfn(fmt.Sprintf(WarningColor, "WARN"))
Error = logfn(fmt.Sprintf(ErrorColor, "ERROR"))
}