Git Product home page Git Product logo

clog's People

Contributors

jsfaint avatar rasa avatar unknwon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clog's Issues

Add file adapter

  • Basic function
  • Rotation
    • By size
    • By lines
    • By day
  • Rotation cleanup by max days

[BUG] First log not written

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")
}

image

Panic triggered when running multiple replica containers

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

Unexpected output

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.

The outdated log file is not deleted when the rorate is on

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

Support writing to named loggers

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.