mirror of https://github.com/go-gitea/gitea.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.0 KiB
Markdown
52 lines
1.0 KiB
Markdown
6 years ago
|
## log
|
||
|
|
||
4 years ago
|
[](https://goreportcard.com/report/gitea.com/lunny/log)
|
||
|
[](https://godoc.org/gitea.com/lunny/log)
|
||
|
|
||
|
[简体中文](https://gitea.com/lunny/log/blob/master/README_CN.md)
|
||
6 years ago
|
|
||
|
# Installation
|
||
|
|
||
|
```
|
||
4 years ago
|
go get gitea.com/lunny/log
|
||
6 years ago
|
```
|
||
|
|
||
|
# Features
|
||
|
|
||
|
* Add color support for unix console
|
||
|
* Implemented dbwriter to save log to database
|
||
|
* Implemented FileWriter to save log to file by date or time.
|
||
|
* Location configuration
|
||
|
|
||
|
# Example
|
||
|
|
||
|
For Single File:
|
||
|
```Go
|
||
|
f, _ := os.Create("my.log")
|
||
|
log.Std.SetOutput(f)
|
||
|
```
|
||
|
|
||
|
For Multiple Writer:
|
||
|
```Go
|
||
|
f, _ := os.Create("my.log")
|
||
|
log.Std.SetOutput(io.MultiWriter(f, os.Stdout))
|
||
|
```
|
||
|
|
||
|
For log files by date or time:
|
||
|
```Go
|
||
|
w := log.NewFileWriter(log.FileOptions{
|
||
|
ByType:log.ByDay,
|
||
|
Dir:"./logs",
|
||
|
})
|
||
|
log.Std.SetOutput(w)
|
||
|
```
|
||
|
|
||
|
# About
|
||
|
|
||
|
This repo is an extension of Golang log.
|
||
|
|
||
|
# LICENSE
|
||
|
|
||
|
BSD License
|
||
|
[http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/)
|