LoGo is a Golang logging library.
LoGo is licensed under the Simplified BSD License.
Make Sure You Have golang installed!
$ go get github.com/Nurza/LoGo
Make Sure You Have golang installed!
$ go get -u github.com/Nurza/LoGo
See the "examples" directory.
- Simple console logging
type SimpleStructure struct {
A string
B bool
C int
D float64
F byte
}
func main() {
logo.Log(true) // bool
logo.Log(42) // int
logo.Log(42.42) // float64
logo.Log('A') // byte
logo.Log(SimpleStructure{"Hello World", true, 42, 42.42, 'A'}) // Structure
logo.Log("Hello", true, 42, "World") // Mixed
logo.Log("Hello", "World", "!") // Is the same as :
logo.Log("Hello World !")
}
- Console logging
func main() {
var l logo.Logger // Create a simple Logger
l.AddTransport(logo.Console) // Add a transport: Console
l.EnableAllLevels() // Enable all logging levels
l.Log(logo.Info, "Hello World !") // This is the same as:
l.Info("Hello World !")
}
- File logging
func main() {
var l logo.Logger // Create a simple Logger
l.AddTransport(logo.File, "test.log") // Add a transport: Console
l.EnableAllLevels() // Enable all logging levels
l.Log(logo.Info, "Hello World !") // This is the same as:
l.Info("Hello World !")
}
- Console logging with color:
func main() {
var l logo.Logger // Create a simple Logger
t := l.AddTransport(logo.Console) // Add a transport: Console
t.AddColor(logo.ConsoleColor) // Add a color: Console color
l.EnableAllLevels() // Enable all logging levels
l.Silly("Silly")
l.Debug("Debug")
l.Verbose("Verbose")
l.Info("Info")
l.Warn("Warn")
l.Error("Error")
l.Critical("Critical")
}
- Logging with timer:
func main() {
var l logo.Logger // Create a simple Logger
t := l.AddTransport(logo.Console) // Add a transport: Console
t.AddColor(logo.ConsoleColor) // Add a color: Console color
l.AddTime("[2006-01-02 15:04:05]") // Add time template
l.EnableAllLevels() // Enable all logging levels
l.Silly("Silly")
l.Debug("Debug")
l.Verbose("Verbose")
l.Info("Info")
l.Warn("Warn")
l.Error("Error")
l.Critical("Critical")
}