Steps to reproduce
I believe this is related to #653 that was closed by #697. I'm seeing similar results on v3.3.5.
In logger.js:
const { createLogger, format, transports } = require('winston');
const { combine, timestamp, label } = format;
const env = process.env.NODE_ENV || 'development';
const options = {
host: 'localhost',
port: env === 'development' ? 3061 : 3031,
path: 'logs',
auth: 'None',
ssl: false
};
// Configure the Winston logger. For the complete documentation see https://github.com/winstonjs/winston
const logger = createLogger({
// To see more detailed errors, change this to 'debug'
level: env === 'development' ? 'debug' : 'info',
format: combine(
label({ label: 'connector'}),
timestamp(),
format.splat(),
format.simple()
),
transports: [
new transports.Console(),
new transports.Http(options),
],
});
module.exports = logger;
In app.js:
const logger = require('./logger');
.
.
.
app.use(express.errorHandler({ logger }));
Expected behavior
When I manually use the logger, this is the JSON received by the HTTP server:
{ level: 'info',
message: 'TEST Feathers application started on http://localhost:3060',
label: 'connector',
timestamp: '2019-01-06T22:24:08.403Z' },
{ query: {}, route: {}, provider: 'rest' }
Notice the level, label, and timestamp that were added by winston.
Actual behavior
When running the predefined Feathers unit tests for 404, an internal FeathersError is thrown. This is what is received by the HTTP server:
{ name: 'NotFound',
message: 'Page not found',
code: 404,
className: 'not-found',
data: { url: '/path/to/nowhere' },
errors: {} },
{ query: {}, route: {}, provider: 'rest' }
The level, label, and timestamp have been stripped off. Debugging the http transport in Winston, at this line req.end(Buffer.from(JSON.stringify(options), 'utf8'));, options is the full FeathersError object and has the level, label, and timestamp properties. But I believe the FeathersError.prototype.toJson() function is not adding the dynamic properties, as mentioned in #653, and thus they get stripped off as they are logged. Is this what #697 was supposed to resolve?
System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that's not working): feathers-errors@3.3.5, winston@3.1.0
NodeJS version: 8.9.4
Operating System: Mac
Steps to reproduce
I believe this is related to #653 that was closed by #697. I'm seeing similar results on v3.3.5.
In logger.js:
In app.js:
Expected behavior
When I manually use the logger, this is the JSON received by the HTTP server:
Notice the level, label, and timestamp that were added by winston.
Actual behavior
When running the predefined Feathers unit tests for 404, an internal FeathersError is thrown. This is what is received by the HTTP server:
The level, label, and timestamp have been stripped off. Debugging the http transport in Winston, at this line
req.end(Buffer.from(JSON.stringify(options), 'utf8'));,optionsis the full FeathersError object and has the level, label, and timestamp properties. But I believe the FeathersError.prototype.toJson() function is not adding the dynamic properties, as mentioned in #653, and thus they get stripped off as they are logged. Is this what #697 was supposed to resolve?System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that's not working): feathers-errors@3.3.5, winston@3.1.0
NodeJS version: 8.9.4
Operating System: Mac