Skip to content

Commit 734a87d

Browse files
committed
feat(pino): update logger structure to use 'rpc' instead of 'orpc'
1 parent 8606faa commit 734a87d

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

packages/pino/src/handler-plugin.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ describe('loggingHandlerPlugin', () => {
233233
expect(result.matched).toBe(true)
234234
// The path should be set before the handler returns
235235
// because clientInterceptor wraps the procedure call
236-
expect(capturedBeforeReturn.orpc.path).toEqual(['ping'])
236+
expect(capturedBeforeReturn.rpc.method).toEqual('ping')
237237
})
238238

239239
it('logs stream errors as error and abort stream errors as info', async () => {
@@ -321,11 +321,9 @@ describe('loggingHandlerPlugin', () => {
321321

322322
// Check that child logger was created
323323
expect(globalSpies.child).toHaveBeenCalled()
324-
expect(globalSpies.child).toHaveBeenCalledWith(
325-
expect.objectContaining({
326-
orpc: expect.objectContaining({ id: 'test-id' }),
327-
}),
328-
)
324+
expect(globalSpies.child).toHaveBeenCalledWith({
325+
rpc: { id: 'test-id', system: 'orpc' },
326+
})
329327

330328
// Verify id and req were set
331329
expect(globalSpies.setBindings).toHaveBeenCalledWith(

packages/pino/src/handler-plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { StandardHandlerInterceptorOptions, StandardHandlerOptions, Standar
33
import type { Logger } from 'pino'
44
import type { LoggerContext } from './context'
55
import { mapEventIterator } from '@orpc/client'
6-
import { isAsyncIteratorObject, overlayProxy } from '@orpc/shared'
6+
import { isAsyncIteratorObject, ORPC_NAME, overlayProxy } from '@orpc/shared'
77
import pino from 'pino'
88
import { CONTEXT_LOGGER_SYMBOL, getLogger } from './context'
99

@@ -71,7 +71,7 @@ export class LoggingHandlerPlugin<T extends Context> implements StandardHandlerP
7171
const logger = (
7272
(interceptorOptions.context as LoggerContext)[CONTEXT_LOGGER_SYMBOL] ?? this.logger
7373
).child({
74-
orpc: { id: this.generateId(interceptorOptions) },
74+
rpc: { id: this.generateId(interceptorOptions), system: ORPC_NAME },
7575
})
7676

7777
/**
@@ -165,7 +165,7 @@ export class LoggingHandlerPlugin<T extends Context> implements StandardHandlerP
165165

166166
options.clientInterceptors.unshift(async ({ next, path, context, signal }) => {
167167
const logger = getLogger(context)
168-
logger?.setBindings({ orpc: { ...logger.bindings().orpc, path } })
168+
logger?.setBindings({ rpc: { ...logger.bindings().rpc, method: path.join('.') } })
169169

170170
const output = await next()
171171

0 commit comments

Comments
 (0)