Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
github.com/xuexihuang/new_log15
一个go日志库,支持文件和控制台输出,支持打印日志的文件行和文件名称,支持多颜色显示,支持多级日志分级,支持按时间 分割日志,支持按大小分割日志
For more information, you can access the Source Link
import log "github.com/xuexihuang/new_log15"
func main() {
h,_ := log.FileHandler("./app.log", log.LogfmtFormat())
log.Root().SetHandler(h)
Path := "http://mytest.com"
for i:=1; i < 1000000 ; i++ {
log.Info("page accessed", "path", Path, "user_id", i)
time.Sleep(50 * time.Millisecond)
}
}
Will result in output that looks like this:
t=2017-09-26T01:40:37-0400 lvl=info msg="page accessed" path=http://mytest.com user_id=21
t=2017-09-26T01:40:37-0400 lvl=info msg="page accessed" path=http://mytest.com user_id=22
func main() {
// set level to Warn
log.SetOutLevel(log.LvlWarn)
h,_ := log.FileHandler("./app.log", log.LogfmtFormat())
log.Root().SetHandler(h)
Path := "http://mytest.com"
for i:=1; i < 1000000 ; i++ {
// Info is large than Warn, output none
log.Info("page accessed", "path", Path, "user_id", i)
time.Sleep(50 * time.Millisecond)
}
}
Will output nothing.
func main() {
// set rotate parameters:
// size:1m, keep 10days, backup 5 files, uncompress when rotate
log.SetRotatePara(1,10,5,false)
h,_ := log.FileHandler("./app.log", log.LogfmtFormat())
log.Root().SetHandler(h)
Path := "http://mytest.com"
for i:=1; i < 1000000 ; i++ {
log.Info("page accessed", "path", Path, "user_id", i)
}
Will result in output that looks like this:
log15]$ ls -l
total 8664
-rw-r--r--. 1 work work 1048524 Sep 26 02:43 app-2017-09-26T02-43-12.826.log
-rw-r--r--. 1 work work 1048524 Sep 26 02:43 app-2017-09-26T02-43-12.890.log
-rw-r--r--. 1 work work 1048524 Sep 26 02:43 app-2017-09-26T02-43-12.941.log
-rw-r--r--. 1 work work 1048524 Sep 26 02:43 app-2017-09-26T02-43-13.006.log
-rw-r--r--. 1 work work 1048524 Sep 26 02:43 app-2017-09-26T02-43-13.068.log
-rw-r--r--. 1 work work 667368 Sep 26 02:43 app.log
func "SetRotatePara()" define:
SetRotatePara(maxsize, maxage, maxbackup int, compress bool)
The default rotate parameters:
func main() {
h,_ := log.FileHandler("./app.log", log.LogfmtFormat())
log.Root().SetHandler(h)
go func(){
for {
time.Sleep( 1 * time.Second)
log.LogRotate()
}
}()
Path := "http://mytest.com"
for i:=1; i < 1000000 ; i++ {
log.Info("page accessed", "path", Path, "user_id", i)
time.Sleep(50 * time.Millisecond)
}
}
Will result in output that looks like this:
log15]$ ls -l
total 2924
-rw-r--r--. 1 work work 201 Sep 26 03:08 app-2017-09-26T03-08-59.134.log.gz
-rw-r--r--. 1 work work 171 Sep 26 03:09 app-2017-09-26T03-09-00.135.log.gz
-rw-r--r--. 1 work work 174 Sep 26 03:09 app-2017-09-26T03-09-01.136.log.gz
-rw-r--r--. 1 work work 171 Sep 26 03:09 app-2017-09-26T03-09-02.138.log.gz
-rw-r--r--. 1 work work 616 Sep 26 03:09 app.log
every second rotate once.
Apache
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.