Giter VIP home page Giter VIP logo

logrus-postgresql-hook's People

Contributors

gravis avatar soyangel avatar ykhrustalev avatar

Stargazers

 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

logrus-postgresql-hook's Issues

Is sync.RWMutex needed?

Hi,

While reading the code I noticed that the sync.RWMutex is only used with RLock, I could not find a corresponding Lock call.

RWMutex is doing states:
A RWMutex is a reader/writer mutual exclusion lock. The lock can be held by an arbitrary number of readers or a single writer.

The newEntry method is also not having a critical section, correct?

Am I missing something?

`Caller` field is lost when method name is logged

When method name is being logged, i.e. log.SetReportCaller(true) , the Caller field is lost in hook. This is because this field (Caller) is not copied when new entry is created.

newEntry := &logrus.Entry{

The newEntry should be:

newEntry := &logrus.Entry{
		Logger:  entry.Logger,
		Data:    data,
		Time:    entry.Time,
		Level:   entry.Level,
		Message: entry.Message,
                Caller: entry.Caller,
	}

Feature Request: Assign Levels for firing.

Currently the database will log for every event level except for panic, as seen here:
func (hook *Hook) Levels() []logrus.Level { return []logrus.Level{ logrus.FatalLevel, logrus.ErrorLevel, logrus.WarnLevel, logrus.InfoLevel, logrus.DebugLevel, } }

It would be ideal if this method can be provided externally with something like the following:

func (h *Hook) init() { h.Levels = func (hook *Hook) Levels() []logrus.Level { return []logrus.Level{ logrus.FatalLevel, logrus.ErrorLevel, logrus.WarnLevel, logrus.InfoLevel, logrus.DebugLevel, } } }

Then in my caller I can update Levels with something like:
hook := pglogrus.NewAsyncHook(db.DB, map[string]interface{}{}) hook.Levels = func() []logrus.Level { topLevel := int(settings.Log.DbLogLevel) + 1 return logrus.AllLevels[0:topLevel] } l.AddHook(hook)

Alternatively it would be good if we can assign levels at declaration to a slice, and that could be used during execution. Something like the following:

type Hook struct { ... LogLevels []Level }

New Trace log level in logrus

Hello, I'm just opening this issue to let you know, the next release of logrus (v1.2.0) will add a new trace level named Trace below Debug.
Here is the PR for reference sirupsen/logrus#844
You may want to take into account this new level.

Question regarding Ticker + Data Race issue

Hello,

I have 2 questions/concerns, which seem to be related:

  1. I would like to ask about the rationale behind setting the *time.Ticker to 1 second when the new async hook is created
    Ticker: time.NewTicker(time.Second),

and then overwriting this time ticker with a 'quicker' one in the Flush() method

hook.Ticker = time.NewTicker(100 * time.Millisecond)

  1. When running the test with race condition on i.e. with -race flag, there is data racing problem. While one goroutine tries to write to hook.Ticker in Flush() method, another one want to read in fire() method, line 202.

Here is the output that I get when running test with race condition:
screenshot from 2019-03-05 15-55-02

Thank you!

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.