Serverless-offline: How to show console.log statements locally?

Created on 12 Jul 2017  路  7Comments  路  Source: dherault/serverless-offline

Hi!

Thanks for the great package. I'm trying to figure out how I can use console.log locally. I am using serverless-webpack so the code that is being executed is gibberish, so breakpoints don't help me that much. I just need to log out somewhere so I can see the shape of the payload, or understand how to use this package's debugging features in conjunction with the webpack plugin.

When I deploy to AWS logs are automatically shown on CloudWatch. Is there a local equivalent in serverless-offline where logs are shown?

Most helpful comment

Is there a way to show the logging statements but to not show the giant response body dumps?

I'm trying to debug, but I either don't get to see any logging, or I have giant dumps of my entire schema every second while it polls. Is there a halfway option here?

All 7 comments

I'm using serverless-offline-scheduler to invoke my function every minute.

const hello = (event) => {
  console.log('hello?');
  return {
    input: event,
    message: 'hello',
  };
};

Notice the console statement I have in there. However my console only shows:

Serverless: scheduler: running scheduled job: hello
Serverless: scheduler: running scheduled job: hello
Serverless: scheduler: running scheduled job: hello

Hi, I can't repoduce. My console.log are shown in my handlers and anywhere really. Are you sure your code doesn't override console.log somewhere ? Does your log shows up if you invoke the function with offline, ie without offline-scheduler ? Thanks

I also can't reproduce this anymore. I got it working somewhere along the line. Sorry bout that!

Any ideas how to show console.debug messages ? console.info works, but not console.debug !

Use CLI option --printOutput to print logs on terminal.
serverless offline start --printOutput

Is there a way to show the logging statements but to not show the giant response body dumps?

I'm trying to debug, but I either don't get to see any logging, or I have giant dumps of my entire schema every second while it polls. Is there a halfway option here?

seconding what @texonidas asked.

Was this page helpful?
0 / 5 - 0 ratings