Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logs missing timestamp #5560

Closed
srowe0091 opened this issue May 4, 2019 · 5 comments · Fixed by #5571
Closed

Logs missing timestamp #5560

srowe0091 opened this issue May 4, 2019 · 5 comments · Fixed by #5571

Comments

@srowe0091
Copy link

Issue Description

Logs for info and error do not have a timestamp, which causes an issue with Parse-Dashboard to not be able to view any logs, because it will break the UI. Since Winston Logger was upgraded to 3.x, timestamp format has been changed.

Steps to reproduce

In a Parse Cloud function, running
request.log.info("foo")
or
request.log.error("bar")

Expected Results

in parse-server/logs
in parse-server.info.DATE-OF-LOG
expect to see
{ "level": "info", "message": "foo", timestamp: "TIME-OF-LOG" }

also in
parse-server.error.DATE-OF-LOG
expect to see
{ "level": "error", "message": "bar", timestamp: "TIME-OF-LOG" }

Actual Outcome

in parse-server/logs
in parse-server.info.DATE-OF-LOG
expect to see
{ "level": "info", "message": "foo" }

also in
parse-server.error.DATE-OF-LOG
expect to see
{ "level": "error", "message": "bar" }

Environment Setup

  • Server
    • parse-server version (Be specific! Don't say 'latest'.) : [3.3.0]
    • Operating System: [Windows & Linux]
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): [Local & Digital Ocean]

I have created a fix, but I am not sure how to submit the Pull Request to push my changes, which are VERY minor :)

@dplewis
Copy link
Member

dplewis commented May 4, 2019

There is an issue in the PHP SDK as well.

A PR would be great. You can start with the guide for contributing https://github.com/parse-community/parse-server/blob/master/CONTRIBUTING.md

@beiguancyc
Copy link

+1

@yingmu52
Copy link

yingmu52 commented May 8, 2019

another issue I notice is with the latest version, the logs are all stringified, makes difficult to read, any suggestion on that?

@dplewis
Copy link
Member

dplewis commented May 8, 2019

@yingmu52 I noticed that too. @stage88 any thoughts?

@stage88
Copy link
Contributor

stage88 commented May 9, 2019

Looks like @acinader has got it covered... 😃

There are a few examples of how to combine formats to get a similar output 2.*, take a look at this file: https://github.com/winstonjs/winston/blob/master/examples/quick-start.js

Maybe this type of formater is ok?

format.combine(
  format.timestamp(),
  format.errors({ stack: true }),
  format.splat(),
  format.json()
)

Personally I have been using a custom adapter for a while now, see below:

const winston = require('winston');
const env = require('./env');

const { format } = winston;
const {
  combine, timestamp, printf,
} = format;

const print = printf(info => `${info.timestamp} - ${info.level}: ${info.message}`);

const transports = [
  new winston.transports.Console({
    level: env.environment === 'localhost' ? 'info' : 'warn',
  }),
  new winston.transports.File({
    filename: `${env.logFilePath}/parse-server.log`,
    level: 'warn',
  }),
];

const logger = winston.createLogger({
  format: combine(
    timestamp(),
    print,
  ),
  transports,
});

module.exports = logger;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants