Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging callback #10

Open
belak opened this issue Feb 3, 2017 · 6 comments
Open

Add logging callback #10

belak opened this issue Feb 3, 2017 · 6 comments

Comments

@belak
Copy link
Collaborator

belak commented Feb 3, 2017

It would be awesome if there was a way to log when users connect (along with what requests they run) and disconnect.

@progrium
Copy link
Contributor

progrium commented Feb 3, 2017

Great idea. The details of this are tricky. Have a proposal?

@belak
Copy link
Collaborator Author

belak commented Feb 3, 2017

We cheated and just passed a *logrus.Entry to the ssh server... however this isn't optimal because it locks you into a specific logging library. Maybe a callback like this: type LogCallback func(ctx *context.Context, logLevel, message string) LogLevel could optionally be defined as a const... and if you wanted to this could be called for errors as well (combined with #9)

EDIT: The other option would be to define some sort of logging interface, but I'd rather stay away from that if possible because it limits what you can do... for instance, it makes it harder to grab fields out of the context and pass them as params to the logging library.

@progrium
Copy link
Contributor

progrium commented Feb 3, 2017

Btw, join our Slack and maybe #golang if you want to coordinate/discuss more about these improvements. http://slack.gliderlabs.com/

@hloeffler
Copy link
Contributor

do you know any good example of logging callbacks in a go library?

@progrium
Copy link
Contributor

progrium commented Nov 1, 2017

@hloeffler not great examples. annoying examples are often callbacks with string message argument. annoying because it's really not so much a log and more an event in some cases. it might be processes by the app, or it might be logged using structured logging.

@bokunodev
Copy link

can we just define signature for the callback and let the user to format or log it however they want?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants