remove submodule

remotes/origin/HEAD
fangdingjun 6 years ago
parent 16bae880ea
commit ccc0bd2695

@ -1,11 +1,12 @@
go-log go-log
================ ================
<!--
[![GoDoc](https://godoc.org/github.com/subchen/go-log?status.svg)](https://godoc.org/github.com/subchen/go-log) [![GoDoc](https://godoc.org/github.com/fangdingjun/go-log?status.svg)](https://godoc.org/github.com/fangdingjun/go-log)
[![Build Status](https://travis-ci.org/subchen/go-log.svg?branch=master)](https://travis-ci.org/subchen/go-log) [![Build Status](https://travis-ci.org/fangdingjun/go-log.svg?branch=master)](https://travis-ci.org/fangdingjun/go-log)
[![Coverage Status](https://coveralls.io/repos/github/subchen/go-log/badge.svg?branch=master)](https://coveralls.io/github/subchen/go-log?branch=master) [![Coverage Status](https://coveralls.io/repos/github/fangdingjun/go-log/badge.svg?branch=master)](https://coveralls.io/github/fangdingjun/go-log?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/subchen/go-log)](https://goreportcard.com/report/github.com/subchen/go-log) [![Go Report Card](https://goreportcard.com/badge/github.com/fangdingjun/go-log)](https://goreportcard.com/report/github.com/fangdingjun/go-log)
[![License](http://img.shields.io/badge/License-Apache_2-red.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![License](http://img.shields.io/badge/License-Apache_2-red.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
-->
Logging package similar to log4j for the Golang. Logging package similar to log4j for the Golang.
@ -13,7 +14,7 @@ Logging package similar to log4j for the Golang.
- Support customized formatter - Support customized formatter
- TextFormatter - TextFormatter
- JSONFormatter - JSONFormatter
- Support multiple rolling file writers - Support multiple rolling file log
- FixedSizeFileWriter - FixedSizeFileWriter
- DailyFileWriter - DailyFileWriter
- AlwaysNewFileWriter - AlwaysNewFileWriter
@ -22,7 +23,7 @@ Installation
--------------- ---------------
```bash ```bash
$ go get github.com/subchen/go-log $ go get github.com/fangdingjun/go-log
``` ```
Usage Usage
@ -34,7 +35,7 @@ package main
import ( import (
"os" "os"
"errors" "errors"
"github.com/subchen/go-log" "github.com/fangdingjun/go-log"
) )
func main() { func main() {
@ -55,23 +56,23 @@ Default log to console, you can set `Logger.Out` to set a file writer into log.
```go ```go
import ( import (
"github.com/subchen/go-log" "github.com/fangdingjun/go-log"
"github.com/subchen/go-log/writers" "github.com/fangdingjun/go-log/log"
) )
log.Default.Out = &writers.FixedSizeFileWriter{ log.Default.Out = &log.FixedSizeFileWriter{
Name: "/tmp/test.log", Name: "/tmp/test.log",
MaxSize: 10 * 1024 * 1024, // 10m MaxSize: 10 * 1024 * 1024, // 10m
MaxCount: 10, MaxCount: 10,
}) })
``` ```
Three builtin writers for use Three builtin log for use
```go ```go
// Create log file if file size large than fixed size (10m) // Create log file if file size large than fixed size (10m)
// files: /tmp/test.log.0 .. test.log.10 // files: /tmp/test.log.0 .. test.log.10
&writers.FixedSizeFileWriter{ &log.FixedSizeFileWriter{
Name: "/tmp/test.log", Name: "/tmp/test.log",
MaxSize: 10 * 1024 * 1024, // 10m MaxSize: 10 * 1024 * 1024, // 10m
MaxCount: 10, MaxCount: 10,
@ -79,14 +80,14 @@ Three builtin writers for use
// Create log file every day. // Create log file every day.
// files: /tmp/test.log.20160102 // files: /tmp/test.log.20160102
&writers.DailyFileWriter{ &log.DailyFileWriter{
Name: "/tmp/test.log", Name: "/tmp/test.log",
MaxCount: 10, MaxCount: 10,
} }
// Create log file every process. // Create log file every process.
// files: /tmp/test.log.20160102_150405 // files: /tmp/test.log.20160102_150405
&writers.AlwaysNewFileWriter{ &log.AlwaysNewFileWriter{
Name: "/tmp/test.log", Name: "/tmp/test.log",
MaxCount: 10, MaxCount: 10,
} }
@ -94,7 +95,7 @@ Three builtin writers for use
// Output to multiple writes // Output to multiple writes
io.MultiWriter( io.MultiWriter(
os.Stdout, os.Stdout,
&writers.DailyFileWriter{ &log.DailyFileWriter{
Name: "/tmp/test.log", Name: "/tmp/test.log",
MaxCount: 10, MaxCount: 10,
} }
@ -106,11 +107,10 @@ io.MultiWriter(
```go ```go
import ( import (
"github.com/subchen/go-log" "github.com/fangdingjun/go-log"
"github.com/subchen/go-log/formatters"
) )
log.Default.Formatter = new(formatters.TextFormatter) log.Default.Formatter = new(log.TextFormatter)
``` ```
@ -118,13 +118,13 @@ log.Default.Formatter = new(formatters.TextFormatter)
```go ```go
import ( import (
"github.com/subchen/go-log" "github.com/fangdingjun/go-log"
) )
func main() { func main() {
logger := &log.Logger{ logger := &log.Logger{
Level: log.INFO, Level: log.INFO,
Formatter: new(formatters.JSONFormatter), Formatter: new(log.JSONFormatter),
Out: os.Stdout, Out: os.Stdout,
} }

@ -1,4 +1,4 @@
package writers package log
import ( import (
"fmt" "fmt"

@ -1,4 +1,4 @@
package writers package log
import ( import (
"fmt" "fmt"

@ -1,5 +1,5 @@
/* /*
Package log is a simple and configurable Logging in Go, with level, formatters and writers. Package log is a simple and configurable Logging in Go, with level, log and log.
It is completely API compatible with the standard library logger. It is completely API compatible with the standard library logger.
@ -32,15 +32,13 @@ You also can config `log.Default` or new `log.Logger` to customize formatter and
import ( import (
"os" "os"
"github.com/fangdingjun/go-log" "github.com/fangdingjun/go-log"
"github.com/fangdingjun/go-log/formatters"
"github.com/fangdingjun/go-log/writers"
) )
func main() { func main() {
logger := &log.Logger{ logger := &log.Logger{
Level: log.INFO, Level: log.INFO,
Formatter: new(formatters.TextFormatter), Formatter: new(log.TextFormatter),
Out: &writers.FixedSizeFileWriter{ Out: &log.FixedSizeFileWriter{
Name: "/tmp/test.log", Name: "/tmp/test.log",
MaxSize: 10 * 1024 * 1024, // 10m MaxSize: 10 * 1024 * 1024, // 10m
MaxCount: 10, MaxCount: 10,

@ -4,20 +4,19 @@ import (
"os" "os"
"github.com/fangdingjun/go-log" "github.com/fangdingjun/go-log"
"github.com/fangdingjun/go-log/formatters"
) )
func main() { func main() {
log.Info("hello", 123) log.Info("hello", 123)
log.Warn("hello", 123) log.Warn("hello", 123)
log.Default.Formatter = new(formatters.TextFormatter) log.Default.Formatter = new(log.TextFormatter)
log.Infoln("hello", "world") log.Infoln("hello", "world")
log.Warnln("hello", "world") log.Warnln("hello", "world")
newLog := &log.Logger{ newLog := &log.Logger{
Level: log.INFO, Level: log.INFO,
Formatter: new(formatters.JSONFormatter), Formatter: new(log.JSONFormatter),
Out: os.Stdout, Out: os.Stdout,
} }
newLog.Infof("hello %v", 123) newLog.Infof("hello %v", 123)

@ -1,4 +1,4 @@
package writers package log
import ( import (
"fmt" "fmt"

@ -1,4 +1,4 @@
package formatters package log
import ( import (
"bytes" "bytes"
@ -8,8 +8,6 @@ import (
"path/filepath" "path/filepath"
"sync" "sync"
"time" "time"
"github.com/fangdingjun/go-log"
) )
// JSONFormatter is a json formatter // JSONFormatter is a json formatter
@ -23,7 +21,7 @@ type JSONFormatter struct {
} }
// Format implements log.Formatter // Format implements log.Formatter
func (f *JSONFormatter) Format(level log.Level, msg string, logger *log.Logger) []byte { func (f *JSONFormatter) Format(level Level, msg string, logger *Logger) []byte {
// output fields: time level host app pid file line msg // output fields: time level host app pid file line msg
f.init.Do(func() { f.init.Do(func() {

@ -3,7 +3,7 @@ package log
// Won't compile if LogInterface can't be realized by a log.Logger // Won't compile if LogInterface can't be realized by a log.Logger
var ( var (
_ StdLog = Default _ StdLog = Default
_ LogInterface = Default _ Interface = Default
) )
// StdLog is interface for builtin log // StdLog is interface for builtin log
@ -21,8 +21,8 @@ type StdLog interface {
Panicln(...interface{}) Panicln(...interface{})
} }
// LogInterface is interface for this logger // Interface is interface for this logger
type LogInterface interface { type Interface interface {
Debug(...interface{}) Debug(...interface{})
Info(...interface{}) Info(...interface{})
Print(...interface{}) Print(...interface{})

@ -1,4 +1,4 @@
package formatters package log
import ( import (
"bytes" "bytes"
@ -7,8 +7,6 @@ import (
"strconv" "strconv"
"sync" "sync"
"time" "time"
"github.com/fangdingjun/go-log"
) )
/* /*
@ -33,8 +31,8 @@ type TextFormatter struct {
isterm bool isterm bool
} }
// Format implements log.Formatter // Format implements Formatter
func (f *TextFormatter) Format(level log.Level, msg string, logger *log.Logger) []byte { func (f *TextFormatter) Format(level Level, msg string, logger *Logger) []byte {
// output format: DATE LEVEL HOST APP PID file:line message // output format: DATE LEVEL HOST APP PID file:line message
// 2001-10-10T12:00:00,000+0800 INFO web-1 app 1234 main/main.go:1234 message ... // 2001-10-10T12:00:00,000+0800 INFO web-1 app 1234 main/main.go:1234 message ...

@ -1,4 +1,4 @@
package formatters package log
import ( import (
"path" "path"

@ -1,4 +1,4 @@
package formatters package log
import ( import (
"io" "io"
Loading…
Cancel
Save