CBX logger
const Logger = require('@councilbox/logger');
const logger = Logger({
name: 'API',
level: 'debug',
pretty: true
});
const Logger = require('@councilbox/logger');
const logger = Logger({
name: 'API',
level: 'debug',
pretty: true,
redact: {
paths: [
'variables.pwd',
'variables.password',
'variables.vote',
'variables.dni',
'variables.tin',
'variables.base64',
'variables.certificate',
'result.nif'
],
remove: true,
}
});
const Logger = require('@councilbox/logger');
const logger = Logger({
name: 'API',
level: 'debug',
pretty: true,
graphqlConfig: {
excludedOperations: {
api: true
},
getUserId: (requestContext) => {
const user = requestContext.context.req.jwtSession;
return user.data ? user.data.id : null;
}
}
});
logger.info(`Version: ${logger.loggerVersion}`);
logger.debug('Hola');
logger.info('Hola');
logger.warn('Hola');
logger.error('Hola');
const startTime = performance.now();
const debugLog = {
userId: '<USER_ID>',
result: {
response: 'sample response'
},
startTime,
debug: true,
endTime: performance.now(),
type: 'testing_log',
};
logger.formatter(debugLog);
const infoLog = {
userId: '<USER_ID>',
result: {
response: 'sample response'
},
startTime,
endTime: performance.now(),
type: 'testing_log',
};
logger.formatter(infoLog);
const warnlog = {
userId: '<USER_ID>',
result: {
response: 'sample response'
},
warn: true,
startTime,
endTime: performance.now(),
type: 'testing_log',
};
logger.formatter(warnlog);
const errorLog = {
userId: '<USER_ID>',
result: {
error: 'Default error'
},
startTime,
endTime: performance.now(),
type: 'testing_log',
};
logger.formatter(errorLog);
const errorsLog = {
userId: '<USER_ID>',
errors: ['Default error', 'Default error 2'],
startTime,
endTime: performance.now(),
type: 'testing_log',
};
logger.formatter(errorsLog);
new ApolloServer({
...,
plugins: [logger.graphql()],
...
});