bump(github.com/ccding/go-logging): 4f3650d51969cc425c1940efa31fcb7c0bba86b3
This commit is contained in:
@ -5,14 +5,6 @@ go-logging is a high-performance logging library for golang.
|
|||||||
low delay of about 800 nano-seconds.
|
low delay of about 800 nano-seconds.
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
The stable version is under the `stable` branch, which does never revert and
|
|
||||||
is fully tested. The tags in `stable` branch indicate the version numbers.
|
|
||||||
|
|
||||||
However, `master` branch is unstable version, and `dev` branch is development
|
|
||||||
branch. `master` branch merges `dev` branch periodically.
|
|
||||||
|
|
||||||
Btw, all the pull request should be sent to the `dev` branch.
|
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
The step below will download the library source code to
|
The step below will download the library source code to
|
||||||
`${GOPATH}/src/github.com/ccding/go-logging`.
|
`${GOPATH}/src/github.com/ccding/go-logging`.
|
||||||
@ -46,7 +38,6 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
logger, _ := logging.SimpleLogger("main")
|
logger, _ := logging.SimpleLogger("main")
|
||||||
logger.SetLevel(logging.DEBUG)
|
|
||||||
logger.Error("this is a test from error")
|
logger.Error("this is a test from error")
|
||||||
logger.Destroy()
|
logger.Destroy()
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
// author: Cong Ding <dinggnu@gmail.com>
|
// author: Cong Ding <dinggnu@gmail.com>
|
||||||
//
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
// author: Cong Ding <dinggnu@gmail.com>
|
// author: Cong Ding <dinggnu@gmail.com>
|
||||||
//
|
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
// Logln receives log request from the client. The request includes a set of
|
// Logln receives log request from the client. The request includes a set of
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
// author: Cong Ding <dinggnu@gmail.com>
|
// author: Cong Ding <dinggnu@gmail.com>
|
||||||
//
|
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
// author: Cong Ding <dinggnu@gmail.com>
|
// author: Cong Ding <dinggnu@gmail.com>
|
||||||
//
|
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
// author: Cong Ding <dinggnu@gmail.com>
|
// author: Cong Ding <dinggnu@gmail.com>
|
||||||
//
|
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
// author: Cong Ding <dinggnu@gmail.com>
|
// author: Cong Ding <dinggnu@gmail.com>
|
||||||
//
|
|
||||||
// This file defines GetGoId function, which is used to get the id of the
|
// This file defines GetGoId function, which is used to get the id of the
|
||||||
// current goroutine. More details about this function are availeble in the
|
// current goroutine. More details about this function are availeble in the
|
||||||
// runtime.c file of golang source code.
|
// runtime.c file of golang source code.
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
// author: Cong Ding <dinggnu@gmail.com>
|
// author: Cong Ding <dinggnu@gmail.com>
|
||||||
//
|
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
// Level is the type of level.
|
// Level is the type of level.
|
||||||
|
@ -99,13 +99,15 @@ func RichLogger(name string) (*Logger, error) {
|
|||||||
func FileLogger(name string, level Level, format string, timeFormat string, file string, sync bool) (*Logger, error) {
|
func FileLogger(name string, level Level, format string, timeFormat string, file string, sync bool) (*Logger, error) {
|
||||||
out, err := os.Create(file)
|
out, err := os.Create(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return new(Logger), err
|
return nil, err
|
||||||
}
|
}
|
||||||
logger, err := createLogger(name, level, format, timeFormat, out, sync)
|
logger, err := createLogger(name, level, format, timeFormat, out, sync)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
logger.fd = out
|
logger.fd = out
|
||||||
|
return logger, nil
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
return logger, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriterLogger creates a new logger with a writer
|
// WriterLogger creates a new logger with a writer
|
||||||
@ -115,38 +117,35 @@ func WriterLogger(name string, level Level, format string, timeFormat string, ou
|
|||||||
|
|
||||||
// WriterLogger creates a new logger from a configuration file
|
// WriterLogger creates a new logger from a configuration file
|
||||||
func ConfigLogger(filename string) (*Logger, error) {
|
func ConfigLogger(filename string) (*Logger, error) {
|
||||||
conf, err := config.Read(filename)
|
conf := config.NewConfig(filename)
|
||||||
|
err := conf.Read()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return new(Logger), err
|
return nil, err
|
||||||
}
|
}
|
||||||
ok := true
|
name := conf.Get("", "name")
|
||||||
name, ok := conf["name"]
|
slevel := conf.Get("", "level")
|
||||||
if !ok {
|
if slevel == "" {
|
||||||
name = ""
|
|
||||||
}
|
|
||||||
slevel, ok := conf["level"]
|
|
||||||
if !ok {
|
|
||||||
slevel = "0"
|
slevel = "0"
|
||||||
}
|
}
|
||||||
l, err := strconv.Atoi(slevel)
|
l, err := strconv.Atoi(slevel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return new(Logger), err
|
return nil, err
|
||||||
}
|
}
|
||||||
level := Level(l)
|
level := Level(l)
|
||||||
format, ok := conf["format"]
|
format := conf.Get("", "format")
|
||||||
if !ok {
|
if format == "" {
|
||||||
format = BasicFormat
|
format = BasicFormat
|
||||||
}
|
}
|
||||||
timeFormat, ok := conf["timeFormat"]
|
timeFormat := conf.Get("", "timeFormat")
|
||||||
if !ok {
|
if timeFormat == "" {
|
||||||
timeFormat = DefaultTimeFormat
|
timeFormat = DefaultTimeFormat
|
||||||
}
|
}
|
||||||
ssync, ok := conf["sync"]
|
ssync := conf.Get("", "sync")
|
||||||
if !ok {
|
if ssync == "" {
|
||||||
ssync = "0"
|
ssync = "0"
|
||||||
}
|
}
|
||||||
file, ok := conf["file"]
|
file := conf.Get("", "file")
|
||||||
if !ok {
|
if file == "" {
|
||||||
file = DefaultFileName
|
file = DefaultFileName
|
||||||
}
|
}
|
||||||
sync := true
|
sync := true
|
||||||
@ -155,7 +154,7 @@ func ConfigLogger(filename string) (*Logger, error) {
|
|||||||
} else if ssync == "1" {
|
} else if ssync == "1" {
|
||||||
sync = true
|
sync = true
|
||||||
} else {
|
} else {
|
||||||
return new(Logger), err
|
return nil, err
|
||||||
}
|
}
|
||||||
return FileLogger(name, level, format, timeFormat, file, sync)
|
return FileLogger(name, level, format, timeFormat, file, sync)
|
||||||
}
|
}
|
||||||
@ -166,7 +165,7 @@ func createLogger(name string, level Level, format string, timeFormat string, ou
|
|||||||
|
|
||||||
err := logger.parseFormat(format)
|
err := logger.parseFormat(format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return logger, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// asign values to logger
|
// asign values to logger
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
// author: Cong Ding <dinggnu@gmail.com>
|
// author: Cong Ding <dinggnu@gmail.com>
|
||||||
//
|
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
// author: Cong Ding <dinggnu@gmail.com>
|
// author: Cong Ding <dinggnu@gmail.com>
|
||||||
//
|
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
// request struct stores the logger request
|
// request struct stores the logger request
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
// author: Cong Ding <dinggnu@gmail.com>
|
// author: Cong Ding <dinggnu@gmail.com>
|
||||||
//
|
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
Reference in New Issue
Block a user