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

Enable application side logging of hashicat runtime #68

Closed
eikenb opened this issue Oct 12, 2021 · 1 comment · Fixed by #77
Closed

Enable application side logging of hashicat runtime #68

eikenb opened this issue Oct 12, 2021 · 1 comment · Fixed by #77
Labels
enhancement New feature or request
Milestone

Comments

@eikenb
Copy link
Contributor

eikenb commented Oct 12, 2021

Add support for injecting a logger into the Watcher to support logging it's events.

Should allow for injecting our logger, go-hclog, but should attempt to be as generic as possible.

@eikenb eikenb added the enhancement New feature or request label Oct 12, 2021
@eikenb eikenb changed the title Logger injectsion Logger injection Oct 12, 2021
@eikenb eikenb closed this as completed in #77 Nov 3, 2021
@eikenb eikenb changed the title Logger injection event handler hook (was: Logger injection) Nov 4, 2021
@eikenb
Copy link
Contributor Author

eikenb commented Nov 4, 2021

For some context on why this was implemented the way it is, here is a snipped from a document I wrote up based on a bit of research I did on the current thoughts about enabling logging in libraries.

--

Discussions about a more featureful standard logging library.

https://github.com/golang/go/issues/13182
https://github.com/golang/go/issues/28412

The conclusion is to keep it simple but make it an interface. They discarded
the idea of adopting additional features, like log levels, as logging is to
varied to have one standard, complex interface.

Instead the decided convention that best enabled logging to plug into a library
is a callback. Callbacks allow you to handle logging, metrics or whatever you
need in relation to the events triggering them. This position is spelled out in
a golang-dev thread on standardizing logging.

https://groups.google.com/g/golang-dev/c/F3l9Iz1JX4g

Notably this paragraph.. ("our proposal" being a new log package proposal)

Note that we do not plan to submit our proposal to the Go project because we
now believe that a standard logging interface is the wrong approach for the
wider Go community. Instead we believe that widely shared libraries should
expose event data via a more richly typed callback API. This approach allows
applications to optionally handle the events as they need. Perhaps they log
(with their preferred logging implementation), or perhaps they do something
else. See, for example, how the golang.org/pkg/net/http/httptrace package
enables many more use cases than just logging. I briefly touched on this topic
starting at slide 47 of my presentation.

The httptrace package, used above as an example of what this might look like,
uses a large structure of callback functions. Things like "GotConn", called
when a successful connection is made, and DNSDone, called when DNS lookups
finish. It has 16 different callbacks for different cases.

This works but is clumsey and only extensible by adding more functions, but has
the upside of allowing the different callbacks to have different signatures.
I'd like to keep the benefits of a callback system, along with the ability to
have data releavent to the event (enabled by varied signatures), while having a
cleaner, more easily extensible API.

@eikenb eikenb changed the title event handler hook (was: Logger injection) Enable application side logging of hashicat runtime Nov 4, 2021
@eikenb eikenb added this to the v0.1.0 milestone Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant