Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const fast = function (stream) {
// Use fast variant if write method has _not_ been modified
return stream.hasOwnProperty('write') ? stream : Pino.destination(stream.fd);
};
function createPinoLogger (opts, stream) {
stream = stream || opts.stream
delete opts.stream
if (stream && opts.file) {
throw new FST_ERR_LOG_INVALID_DESTINATION()
} else if (opts.file) {
// we do not have stream
stream = pino.destination(opts.file)
delete opts.file
}
var prevLogger = opts.logger
var prevGenReqId = opts.genReqId
var logger = null
if (prevLogger) {
opts.logger = undefined
opts.genReqId = undefined
// we need to tap into pino internals because in v5 it supports
// adding serializers in child loggers
if (prevLogger[serializersSym]) {
opts.serializers = Object.assign({}, opts.serializers, prevLogger[serializersSym])
}
logger = prevLogger.child(opts)
createLogger(options = {}, destination) {
return pino(
Object.assign(this.pinoOptions, options),
destination || pino.destination(path.join(logPath, 'app.log'))
);
}
export const CommandError = errors => {
const log = pino(
{prettyPrint: {levelFirst: true}},
pino.destination('./tomo-errors.txt')
);
useEffect(() => {
log.error(errors);
}, []);
return
↳{space}Details written to ./tomo-errors.txt
;
};
export const Debug = ({data, title}) => {
createRequestsLogger(options, destination) {
return koaPinoLogger(
Object.assign(
{
logger: this.createLogger(
options,
destination || pino.destination(path.join(logPath, 'requests.log'))
),
serializers: {
req: pino.stdSerializers.req,
res: pino.stdSerializers.res,
},
},
options
)
);
}