feat(logging): make toLogEntry function public#3856
feat(logging): make toLogEntry function public#3856loburm wants to merge 2 commits intogoogleapis:masterfrom
Conversation
This will allows clients of the library to easily migrate from using Logger abstraction to calling WriteLogEntries directly.
freelerobot
left a comment
There was a problem hiding this comment.
From a UX perspective, these changes are helpful.
The only slightly weird behavior that's introduced now is that the e.HTTPRequest conversion will only write errors to the logger's error channel, when users might expect the function to directly return the error. Not the end of world.
| } | ||
|
|
||
| func (l *Logger) toLogEntry(e Entry) (*logpb.LogEntry, error) { | ||
| // ToLogEntry takes an Entry structure and converts it to the LogEntry proto. |
There was a problem hiding this comment.
(1) Expand the fn comment to the effect of "ToLogEntry is implied when users invoke Logger.Log or Logger.LogSync, but its exported as a pub function here to give users additional flexibility when using the library". This is so majority users don't feel like they have to do the conversion themselves.
There was a problem hiding this comment.
(2) Add an example in examples_test.go. Name it: ExampleLogger_ToLogEntry
Note: doc and example additions will be autogenerated here.
|
Is there an issue for this for discussion? Here are couple of my thoughts:
|
I'll let @loburm elaborate here. My understanding is that their implementation of GKE logging agent uses this lib. And certain abstractions we make around logger/logname/batching, are too heavyhanded for their use case. They need a middle ground btw raw API and current library exports, namely the tologentry private function. Will defer to @codyoss on best practices here. I like the idea of letting users have access to different levels of abstraction, but will definitely acknowledge our internal best practices. |
|
@nicoleczhu actually I think it makes more sense to refactor logic to remove dependency on client completely. Also after going through it once again it's better not to depend on Logger at all. I'll try to resolve these issues. @codyoss thanks for taking a look, let me try to explain why our team is unhappy with how Logger works:
|
SGTM, I think that was my initial suggestion in our chat as well. Whichever path works best for your needs. Closing this one for now |
|
@loburm Thanks, I think that is some great feedback for the client. I agree, it sounds like your use case would be better solved by working with the lower level client directly. |
This will allows clients of the library to easily migrate from using
Logger abstraction to calling WriteLogEntries directly.