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:
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:
Thanks for submitting this. We never implemented that, because we never had the need. But I like the idea, and will accept any merge request with tests :)
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 }