Giter VIP home page Giter VIP logo

Comments (9)

slackpad avatar slackpad commented on August 19, 2024

Hi @gl-works it should be possible to support multiple levels, but there's a lot at the DEBUG level that we could probably make better use of a TRACE level for (things that are proportional to the traffic being handled).

from memberlist.

mofirouz avatar mofirouz commented on August 19, 2024

Hi @slackpad - I'd like to bump this up as well.

We use https://github.com/uber-go/zap to take care of the application level logging and there is sadly no-way to interface with this given the current implementation.

Could you give quick yes/no on your thoughts on this, as I'm thinking of nominating myself for a PR?

from memberlist.

slackpad avatar slackpad commented on August 19, 2024

We are still working on standardizing the logger across our different tools so we should hold off until we figure out the direction for that. I'll update this once I have more info.

from memberlist.

htdvisser avatar htdvisser commented on August 19, 2024

With a couple of changes it's already fine for me. The changes are compatible with the current logging, so existing code that uses memberlist does not have to be modified. I can submit a pull request if that would be appreciated.

Edit: I did remove the memberlist: prefix from log messages. If I'd put that back, it would be exactly the same as it is now.

from memberlist.

slackpad avatar slackpad commented on August 19, 2024

Hi @htdvisser we've now got https://github.com/hashicorp/go-hclog so we plan to port to that interface.

from memberlist.

htdvisser avatar htdvisser commented on August 19, 2024

Ok, thanks, I'll keep an eye on that

from memberlist.

egourlao avatar egourlao commented on August 19, 2024

Hi, any news about the port to https://github.com/hashicorp/go-hclog? Would be happy to work on it if it's not a priority!

from memberlist.

etiennedi avatar etiennedi commented on August 19, 2024

Here's a very dirty workaround I'm using until we get a pluggable interface logger. It's meant to work with logrus.FieldLogger, but could also be adjusted to any other logger. Maybe it'll help someone else:

type logParser struct {
	logrus logrus.FieldLogger
	regexp *regexp.Regexp
}

func newLogParser(logrus logrus.FieldLogger) *logParser {
	return &logParser{
		logrus: logrus,
		regexp: regexp.MustCompile(`(.*)\[(DEBUG|ERR|ERROR|INFO|WARNING|WARN)](.*)`),
	}
}

func (l *logParser) Write(in []byte) (int, error) {
	res := l.regexp.FindSubmatch(in)
	if len(res) != 4 {
		l.logrus.Warnf("unable to parse memberlist log message: %s", in)
	}

	switch string(res[2]) {
	case "ERR", "ERROR":
		l.logrus.Error(string(res[3]))
	case "WARN", "WARNING":
		l.logrus.Warn(string(res[3]))
	case "DEBUG":
		l.logrus.Debug(string(res[3]))
	case "INFO":
		l.logrus.Info(string(res[3]))
	default:
		l.logrus.Warnf("unable to parse memberlist log level from message: %s", in)
	}

	return len(in), nil
}

you can insert in the config using

cfg.LogOutput = newLogParser(logrus)

from memberlist.

kcmvp avatar kcmvp commented on August 19, 2024

any update?

from memberlist.

Related Issues (20)

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.