bump(github.com/ccding/go-logging): 4f3650d51969cc425c1940efa31fcb7c0bba86b3
This commit is contained in:
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// author: Cong Ding <dinggnu@gmail.com>
|
||||
//
|
||||
|
||||
package logging
|
||||
|
||||
// Logln receives log request from the client. The request includes a set of
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// author: Cong Ding <dinggnu@gmail.com>
|
||||
//
|
||||
|
||||
package logging
|
||||
|
||||
import (
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// author: Cong Ding <dinggnu@gmail.com>
|
||||
//
|
||||
|
||||
package logging
|
||||
|
||||
import (
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// author: Cong Ding <dinggnu@gmail.com>
|
||||
//
|
||||
|
||||
package logging
|
||||
|
||||
import (
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// author: Cong Ding <dinggnu@gmail.com>
|
||||
//
|
||||
|
||||
// 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
|
||||
// runtime.c file of golang source code.
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// author: Cong Ding <dinggnu@gmail.com>
|
||||
//
|
||||
|
||||
package logging
|
||||
|
||||
// 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) {
|
||||
out, err := os.Create(file)
|
||||
if err != nil {
|
||||
return new(Logger), err
|
||||
return nil, err
|
||||
}
|
||||
logger, err := createLogger(name, level, format, timeFormat, out, sync)
|
||||
if err == nil {
|
||||
logger.fd = out
|
||||
return logger, nil
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
return logger, err
|
||||
}
|
||||
|
||||
// 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
|
||||
func ConfigLogger(filename string) (*Logger, error) {
|
||||
conf, err := config.Read(filename)
|
||||
conf := config.NewConfig(filename)
|
||||
err := conf.Read()
|
||||
if err != nil {
|
||||
return new(Logger), err
|
||||
return nil, err
|
||||
}
|
||||
ok := true
|
||||
name, ok := conf["name"]
|
||||
if !ok {
|
||||
name = ""
|
||||
}
|
||||
slevel, ok := conf["level"]
|
||||
if !ok {
|
||||
name := conf.Get("", "name")
|
||||
slevel := conf.Get("", "level")
|
||||
if slevel == "" {
|
||||
slevel = "0"
|
||||
}
|
||||
l, err := strconv.Atoi(slevel)
|
||||
if err != nil {
|
||||
return new(Logger), err
|
||||
return nil, err
|
||||
}
|
||||
level := Level(l)
|
||||
format, ok := conf["format"]
|
||||
if !ok {
|
||||
format := conf.Get("", "format")
|
||||
if format == "" {
|
||||
format = BasicFormat
|
||||
}
|
||||
timeFormat, ok := conf["timeFormat"]
|
||||
if !ok {
|
||||
timeFormat := conf.Get("", "timeFormat")
|
||||
if timeFormat == "" {
|
||||
timeFormat = DefaultTimeFormat
|
||||
}
|
||||
ssync, ok := conf["sync"]
|
||||
if !ok {
|
||||
ssync := conf.Get("", "sync")
|
||||
if ssync == "" {
|
||||
ssync = "0"
|
||||
}
|
||||
file, ok := conf["file"]
|
||||
if !ok {
|
||||
file := conf.Get("", "file")
|
||||
if file == "" {
|
||||
file = DefaultFileName
|
||||
}
|
||||
sync := true
|
||||
@ -155,7 +154,7 @@ func ConfigLogger(filename string) (*Logger, error) {
|
||||
} else if ssync == "1" {
|
||||
sync = true
|
||||
} else {
|
||||
return new(Logger), err
|
||||
return nil, err
|
||||
}
|
||||
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)
|
||||
if err != nil {
|
||||
return logger, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// asign values to logger
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// author: Cong Ding <dinggnu@gmail.com>
|
||||
//
|
||||
|
||||
package logging
|
||||
|
||||
import (
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// author: Cong Ding <dinggnu@gmail.com>
|
||||
//
|
||||
|
||||
package logging
|
||||
|
||||
// request struct stores the logger request
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// author: Cong Ding <dinggnu@gmail.com>
|
||||
//
|
||||
|
||||
package logging
|
||||
|
||||
import (
|
||||
|
Reference in New Issue
Block a user