-
Notifications
You must be signed in to change notification settings - Fork 26
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
Is it possible to "decorate" jsonPayload? #24
Comments
If this feature is supported by the GCP Logging API then we should be able to implement this here. Otherwise, no, since this is just a wrapper for their APIs. Or I might be misinterpreting your question. |
It's not really a gcp feature, I used the request id as an example, but it could really be anything like memory usage, or some detail about the user. In short I'm looking to add extra data to the context of all log messages. |
I think this is outside the scope of this package. We simply listen for calls to the Laravel log method: $this->app['log']->listen(function () {
$args = Arr::first(func_get_args());
$this->app['Stackdriver\Logger']->log(
$args->level,
$args->message,
$args->context
);
}); So I guess it is best to find a Laravel compatible solution. So you will have to find a way to add a default context. Have you checked this? |
If I'm following, I'm trying to do something very similar... I have a bunch of different queues (one per concurrently-running job) and I'm looking to isolate which job created which task. I came here to see if there was a similar question already, and well here we all are! GCP does support structured logs, and the I've just not yet traced things back up the stack to see that |
It's looking like the easiest way to pull this off is to tweak the config during runtime, since the static method Here's a gist for the middleware that I wrote to accomplish this. Then, standard Laravel (Laravel7 for me) stuff to get it to be called...
I ought to be in-testing this method tomorrow... and this is my first Laravel project (hell, my first MVC project) so the usual "zero-warranties" disclaimers apply. |
Hey all. I've abandoned this original idea. Last night I finally got back to the original idea, and have tried placing the "labels" associative array in a few different places , yet none worked. So I RTFM'd a bit more, and found (go easy, I'm new to Laravel) that the second parameter to all of the What happens is that when it's consumed in Stackdriver, each of the keys end up being properties inside of the So, here's what one log entry in my system looks like (where I added the "Process-Job" property):
HTH |
I'd like to add some data to all log messages, like a request id for tracing purposed for example. Any idea how I might accomplish that? I tried adding a processor to all log handlers but it seems like that data doesn't get passed to the
app['log']->listen
. Thanks!The text was updated successfully, but these errors were encountered: