Hi, is it possible to add extra fields to the logs...
# spicedb
e
Hi, is it possible to add extra fields to the logs that are created in spicedb?
v
hi, I think the answer is not out of the box. I've done this myself by adding a middleware layer (middleware is part of SpiceDB exported Go API) and injecting your values into the context, like this:
Copy code
ctx := log.Ctx(ctx).With().Str("my-key", "my-value").Logger().WithContext(ctx)
@jzelinskie maybe you know an alternative way?
e
How do you access the middleware? I'm new to Go, so I can't really wrap my head around it 😄
v
it looks like this when you are programatically creating a new server:
Copy code
configOpts := []server.ConfigOption{
        server.WithMiddlewareModification(server.MiddlewareModification{
            DependencyMiddlewareName: server.DefaultInternalMiddlewareServerVersion,
            Operation:                server.OperationAppend,
            Middlewares: []server.ReferenceableMiddleware{
                {
                    Name:                "yourmiddleware",
                    UnaryMiddleware:     yourunarymiddleware
                    StreamingMiddleware: yourstreamingmiddleware,
                },
            },
        }),
    }

    return server.NewConfigWithOptions(configOpts...).Complete(ctx)
4 Views