Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
122 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { pino } from '../../pino' | ||
|
||
// Single | ||
const transport = pino.transport({ | ||
target: '#pino/pretty', | ||
options: { some: 'options for', the: 'transport' } | ||
}) | ||
pino(transport) | ||
|
||
// Multiple | ||
const transports = pino.transport({targets: [ | ||
{ | ||
level: 'info', | ||
target: '#pino/pretty', | ||
options: { some: 'options for', the: 'transport' } | ||
}, | ||
{ | ||
level: 'trace', | ||
target: '#pino/file', | ||
options: { destination: './test.log' } | ||
} | ||
]}) | ||
pino(transports) | ||
|
||
type TransportConfig = { | ||
id: string | ||
} | ||
|
||
// Custom transport params | ||
const customTransport = pino.transport<TransportConfig>({ | ||
target: 'custom', | ||
options: { id: 'abc' } | ||
}) | ||
pino(customTransport) | ||
|
||
// Worker | ||
pino.transport({ | ||
target: 'custom', | ||
worker: { | ||
argv: ['a', 'b'], | ||
stdin: false, | ||
stderr: true, | ||
stdout: false, | ||
autoEnd: true, | ||
}, | ||
options: { id: 'abc' } | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { pino } from '../../pino' | ||
import { join } from 'path' | ||
import { tmpdir } from'os' | ||
|
||
const destination = join( | ||
tmpdir(), | ||
'_' + Math.random().toString(36).substr(2, 9) | ||
) | ||
|
||
// Single | ||
const transport = pino.transport({ | ||
target: '#pino/pretty', | ||
options: { some: 'options for', the: 'transport' } | ||
}) | ||
const logger = pino(transport) | ||
logger.info('test2') | ||
|
||
const transport2 = pino.transport({ | ||
target: '#pino/pretty', | ||
}) | ||
const logger2 = pino(transport2) | ||
logger2.info('test2') | ||
|
||
|
||
// Multiple | ||
|
||
const transports = pino.transport({targets: [ | ||
{ | ||
level: 'info', | ||
target: '#pino/pretty', | ||
options: { some: 'options for', the: 'transport' } | ||
}, | ||
{ | ||
level: 'trace', | ||
target: '#pino/file', | ||
options: { destination } | ||
} | ||
]}) | ||
const loggerMulti = pino(transports) | ||
loggerMulti.info('test2') |