go-clog / clog Goto Github PK
View Code? Open in Web Editor NEWPackage clog is a channel-based logging package for Go
License: MIT License
Package clog is a channel-based logging package for Go
License: MIT License
If I want to use logging for different modules, I would have destinations (like file) depending on the module.
Has it been planned or envisaged to write to a specific logger and not to all managed loggers ?
For example, I would create a console and a file logged for the main part of an application, but also would have a specific logger for a module (let's call it "module"). That would be convenient to have InfoTo(), WarnTo(), etc... for this:
log.NewFileWithName("module", 100, log.FileConfig{
Level: log.LevelInfo,
Filename: "module.log"
})
log.InfoTo("module", "log this")
log.WarnTo("module", "warn this")
A complete management of different logger sources with associated destinations would be better, but I think it's a good compromise to add such a functionnality without breaking compatibility.
Panic triggered when multiple pods with log directory mounted as NFS
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x7b19ec]
goroutine 15 [running]:
unknwon.dev/clog/v2.(*fileLogger).deleteOutdatedFiles.func1({0xc0010ef7a0, 0x21}, {0x0, 0x0}, {0xc0006a0e08?, 0xffffffffffffff9c?})
unknwon.dev/clog/[email protected]/file.go:104 +0x2c
path/filepath.walk({0xc0005fd848, 0xd}, {0x274cf28, 0xc002222d00}, 0xc0006a0e08)
path/filepath/path.go:497 +0x1d4
path/filepath.Walk({0xc0005fd848, 0xd}, 0xc0006a0e08)
path/filepath/path.go:572 +0x66
unknwon.dev/clog/v2.(*fileLogger).deleteOutdatedFiles(0xc00040e540)
unknwon.dev/clog/[email protected]/file.go:103 +0x4b
unknwon.dev/clog/v2.(*fileLogger).write(0xc00040e540, {0x27437c0, 0xc00165c078})
unknwon.dev/clog/[email protected]/file.go:203 +0x465
unknwon.dev/clog/v2.(*fileLogger).Write(0xc0006a0fb0?, {0x27437c0?, 0xc00165c078?})
unknwon.dev/clog/[email protected]/file.go:212 +0x1d
unknwon.dev/clog/v2.New.func1()
unknwon.dev/clog/[email protected]/logger.go:204 +0x54
created by unknwon.dev/clog/v2.New in goroutine 1
unknwon.dev/clog/[email protected]/logger.go:199 +0x5a9
Using this file:
package main
import aa "gopkg.in/clog.v1"
func main() {
aa.New(aa.CONSOLE, aa.ConsoleConfig{})
aa.Info("bbbbb")
aa.Info("ccccc")
}
I get this result:
2019/06/14 20:38:47 [ INFO] bbbbb
Notice only one message is printed.
使用了 阿里云的 proxy
和 goproxy.cn
Configuration should support fields content,
username` and Embed Object described in Execute Webhook.
I use clog as logging library in my project.
I meet an weird issue that the outdated log file is not deleted when rotate is on.
My go version is
$ go version
go version go1.13.5 linux/amd64
clog was initialled with the code below:
func New(c Config) (err error) {
name := filepath.Join(c.Path, c.LogName)
if c.IsConsole {
_ = clog.NewConsole()
}
return clog.NewFile(clog.FileConfig{
Level: c.logLevel(),
Filename: name,
FileRotationConfig: clog.FileRotationConfig{
Rotate: true,
Daily: true,
MaxSize: c.MaxSize,
MaxDays: c.MaxDays,
},
})
}
The daemon is running since last Thursday.
The MaxDays
is set to 1
, but the old log is still there.
$ ls -1
daemon.log
daemon.log.2019-12-12
daemon.log.2019-12-12.001
daemon.log.2019-12-12.002
daemon.log.2019-12-13
daemon.log.2019-12-13.001
daemon.log.2019-12-13.002
daemon.log.2019-12-14
daemon.log.2019-12-14.001
daemon.log.2019-12-15
daemon.log.2019-12-15.001
Did I make anything wrong or miss anything ?
Thanks
E.g. log.Infos
, log.Errors
The first log is not written everytime
package main
import log "unknwon.dev/clog/v2"
func init() {
if err := log.NewConsole(); err != nil {
panic("unable to create new logger: " + err.Error())
}
}
func main() { log.Trace("This will not print") } // will not print anything
But everything get written correctly once you trigger a new one
func main() {
log.Trace("This will print")
log.Trace("This will print too")
}
EDIT : after some more testing I found the behavior to be inconsistant,
I ran the same program around 5 times and had different results
func main() {
log.Trace("something")
log.Trace("something")
}
E.g. log.Infos
, log.Errors
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.