From ccc0bd26959c50bb606a5542764dc0e74b6b3792 Mon Sep 17 00:00:00 2001 From: fangdingjun Date: Tue, 30 Oct 2018 10:00:40 +0800 Subject: [PATCH] remove submodule --- README.md | 42 +++++++++---------- ...ile_writer.go => always_new_file_writer.go | 2 +- ...ily_file_writer.go => daily_file_writer.go | 2 +- doc.go | 8 ++-- examples/main.go | 5 +-- ...ile_writer.go => fixed_size_file_writer.go | 2 +- .../json_formatter.go => json_formatter.go | 6 +-- log_interface.go | 8 ++-- .../text_formatter.go => text_formatter.go | 8 ++-- .../util_fileline.go => util_fileline.go | 2 +- .../util_terminal.go => util_terminal.go | 2 +- 11 files changed, 40 insertions(+), 47 deletions(-) rename writers/always_new_file_writer.go => always_new_file_writer.go (98%) rename writers/daily_file_writer.go => daily_file_writer.go (99%) rename writers/fixed_size_file_writer.go => fixed_size_file_writer.go (99%) rename formatters/json_formatter.go => json_formatter.go (89%) rename formatters/text_formatter.go => text_formatter.go (90%) rename formatters/util_fileline.go => util_fileline.go (96%) rename formatters/util_terminal.go => util_terminal.go (93%) diff --git a/README.md b/README.md index 9b334e2..ef64c84 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ go-log ================ - -[![GoDoc](https://godoc.org/github.com/subchen/go-log?status.svg)](https://godoc.org/github.com/subchen/go-log) -[![Build Status](https://travis-ci.org/subchen/go-log.svg?branch=master)](https://travis-ci.org/subchen/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) -[![Go Report Card](https://goreportcard.com/badge/github.com/subchen/go-log)](https://goreportcard.com/report/github.com/subchen/go-log) + Logging package similar to log4j for the Golang. @@ -13,7 +14,7 @@ Logging package similar to log4j for the Golang. - Support customized formatter - TextFormatter - JSONFormatter -- Support multiple rolling file writers +- Support multiple rolling file log - FixedSizeFileWriter - DailyFileWriter - AlwaysNewFileWriter @@ -22,7 +23,7 @@ Installation --------------- ```bash -$ go get github.com/subchen/go-log +$ go get github.com/fangdingjun/go-log ``` Usage @@ -34,7 +35,7 @@ package main import ( "os" "errors" - "github.com/subchen/go-log" + "github.com/fangdingjun/go-log" ) func main() { @@ -55,23 +56,23 @@ Default log to console, you can set `Logger.Out` to set a file writer into log. ```go import ( - "github.com/subchen/go-log" - "github.com/subchen/go-log/writers" + "github.com/fangdingjun/go-log" + "github.com/fangdingjun/go-log/log" ) -log.Default.Out = &writers.FixedSizeFileWriter{ +log.Default.Out = &log.FixedSizeFileWriter{ Name: "/tmp/test.log", MaxSize: 10 * 1024 * 1024, // 10m MaxCount: 10, }) ``` -Three builtin writers for use +Three builtin log for use ```go // Create log file if file size large than fixed size (10m) // files: /tmp/test.log.0 .. test.log.10 -&writers.FixedSizeFileWriter{ +&log.FixedSizeFileWriter{ Name: "/tmp/test.log", MaxSize: 10 * 1024 * 1024, // 10m MaxCount: 10, @@ -79,14 +80,14 @@ Three builtin writers for use // Create log file every day. // files: /tmp/test.log.20160102 -&writers.DailyFileWriter{ +&log.DailyFileWriter{ Name: "/tmp/test.log", MaxCount: 10, } // Create log file every process. // files: /tmp/test.log.20160102_150405 -&writers.AlwaysNewFileWriter{ +&log.AlwaysNewFileWriter{ Name: "/tmp/test.log", MaxCount: 10, } @@ -94,7 +95,7 @@ Three builtin writers for use // Output to multiple writes io.MultiWriter( os.Stdout, - &writers.DailyFileWriter{ + &log.DailyFileWriter{ Name: "/tmp/test.log", MaxCount: 10, } @@ -106,11 +107,10 @@ io.MultiWriter( ```go import ( - "github.com/subchen/go-log" - "github.com/subchen/go-log/formatters" + "github.com/fangdingjun/go-log" ) -log.Default.Formatter = new(formatters.TextFormatter) +log.Default.Formatter = new(log.TextFormatter) ``` @@ -118,13 +118,13 @@ log.Default.Formatter = new(formatters.TextFormatter) ```go import ( - "github.com/subchen/go-log" + "github.com/fangdingjun/go-log" ) func main() { logger := &log.Logger{ Level: log.INFO, - Formatter: new(formatters.JSONFormatter), + Formatter: new(log.JSONFormatter), Out: os.Stdout, } diff --git a/writers/always_new_file_writer.go b/always_new_file_writer.go similarity index 98% rename from writers/always_new_file_writer.go rename to always_new_file_writer.go index 64900f6..7b243ae 100644 --- a/writers/always_new_file_writer.go +++ b/always_new_file_writer.go @@ -1,4 +1,4 @@ -package writers +package log import ( "fmt" diff --git a/writers/daily_file_writer.go b/daily_file_writer.go similarity index 99% rename from writers/daily_file_writer.go rename to daily_file_writer.go index 5dd52d0..d71fbdc 100644 --- a/writers/daily_file_writer.go +++ b/daily_file_writer.go @@ -1,4 +1,4 @@ -package writers +package log import ( "fmt" diff --git a/doc.go b/doc.go index adb2435..98bba6b 100644 --- a/doc.go +++ b/doc.go @@ -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. @@ -32,15 +32,13 @@ You also can config `log.Default` or new `log.Logger` to customize formatter and import ( "os" "github.com/fangdingjun/go-log" - "github.com/fangdingjun/go-log/formatters" - "github.com/fangdingjun/go-log/writers" ) func main() { logger := &log.Logger{ Level: log.INFO, - Formatter: new(formatters.TextFormatter), - Out: &writers.FixedSizeFileWriter{ + Formatter: new(log.TextFormatter), + Out: &log.FixedSizeFileWriter{ Name: "/tmp/test.log", MaxSize: 10 * 1024 * 1024, // 10m MaxCount: 10, diff --git a/examples/main.go b/examples/main.go index 250a8e0..e8e98c3 100644 --- a/examples/main.go +++ b/examples/main.go @@ -4,20 +4,19 @@ import ( "os" "github.com/fangdingjun/go-log" - "github.com/fangdingjun/go-log/formatters" ) func main() { log.Info("hello", 123) log.Warn("hello", 123) - log.Default.Formatter = new(formatters.TextFormatter) + log.Default.Formatter = new(log.TextFormatter) log.Infoln("hello", "world") log.Warnln("hello", "world") newLog := &log.Logger{ Level: log.INFO, - Formatter: new(formatters.JSONFormatter), + Formatter: new(log.JSONFormatter), Out: os.Stdout, } newLog.Infof("hello %v", 123) diff --git a/writers/fixed_size_file_writer.go b/fixed_size_file_writer.go similarity index 99% rename from writers/fixed_size_file_writer.go rename to fixed_size_file_writer.go index d96a7a2..07441e0 100644 --- a/writers/fixed_size_file_writer.go +++ b/fixed_size_file_writer.go @@ -1,4 +1,4 @@ -package writers +package log import ( "fmt" diff --git a/formatters/json_formatter.go b/json_formatter.go similarity index 89% rename from formatters/json_formatter.go rename to json_formatter.go index f669b33..baa50c8 100644 --- a/formatters/json_formatter.go +++ b/json_formatter.go @@ -1,4 +1,4 @@ -package formatters +package log import ( "bytes" @@ -8,8 +8,6 @@ import ( "path/filepath" "sync" "time" - - "github.com/fangdingjun/go-log" ) // JSONFormatter is a json formatter @@ -23,7 +21,7 @@ type JSONFormatter struct { } // 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 f.init.Do(func() { diff --git a/log_interface.go b/log_interface.go index ded583f..cc91694 100644 --- a/log_interface.go +++ b/log_interface.go @@ -2,8 +2,8 @@ package log // Won't compile if LogInterface can't be realized by a log.Logger var ( - _ StdLog = Default - _ LogInterface = Default + _ StdLog = Default + _ Interface = Default ) // StdLog is interface for builtin log @@ -21,8 +21,8 @@ type StdLog interface { Panicln(...interface{}) } -// LogInterface is interface for this logger -type LogInterface interface { +// Interface is interface for this logger +type Interface interface { Debug(...interface{}) Info(...interface{}) Print(...interface{}) diff --git a/formatters/text_formatter.go b/text_formatter.go similarity index 90% rename from formatters/text_formatter.go rename to text_formatter.go index 63d0391..480809a 100644 --- a/formatters/text_formatter.go +++ b/text_formatter.go @@ -1,4 +1,4 @@ -package formatters +package log import ( "bytes" @@ -7,8 +7,6 @@ import ( "strconv" "sync" "time" - - "github.com/fangdingjun/go-log" ) /* @@ -33,8 +31,8 @@ type TextFormatter struct { isterm bool } -// Format implements log.Formatter -func (f *TextFormatter) Format(level log.Level, msg string, logger *log.Logger) []byte { +// Format implements Formatter +func (f *TextFormatter) Format(level Level, msg string, logger *Logger) []byte { // 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 ... diff --git a/formatters/util_fileline.go b/util_fileline.go similarity index 96% rename from formatters/util_fileline.go rename to util_fileline.go index ec3f864..b13ec16 100644 --- a/formatters/util_fileline.go +++ b/util_fileline.go @@ -1,4 +1,4 @@ -package formatters +package log import ( "path" diff --git a/formatters/util_terminal.go b/util_terminal.go similarity index 93% rename from formatters/util_terminal.go rename to util_terminal.go index ab402b8..018cabc 100644 --- a/formatters/util_terminal.go +++ b/util_terminal.go @@ -1,4 +1,4 @@ -package formatters +package log import ( "io"