https://github.com/flike/golog
simple log library for Golang
https://github.com/flike/golog
Last synced: 10 months ago
JSON representation
simple log library for Golang
- Host: GitHub
- URL: https://github.com/flike/golog
- Owner: flike
- License: mit
- Created: 2015-06-25T09:05:25.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-25T09:31:58.000Z (almost 11 years ago)
- Last Synced: 2024-06-19T13:45:51.083Z (almost 2 years ago)
- Language: Go
- Size: 129 KB
- Stars: 14
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
#golog
simple log library for Golang
##case
```
package main
import (
"fmt"
. "github.com/flike/golog"
"os"
)
func main() {
path := "/tmp/test_log"
os.RemoveAll(path)
os.Mkdir(path, 0777)
fileName := path + "/test.log"
h, err := NewRotatingFileHandler(fileName, 1024*1024, 2)
if err != nil {
fmt.Println(err.Error())
}
//GlobalLogger is a global variable
GlobalLogger = New(h, Lfile|Ltime|Llevel)
GlobalLogger.SetLevel(LevelTrace)
args1 := "go"
args2 := "log"
args3 := "golog"
//the log will record into the file(/tmp/test_log/test.log)
Debug("Mode", "main", "OK", 0, "args1", args1, "args2", args2, "args3", args3)
GlobalLogger.Close()
}
```