Skip to content

Logging when cloud function result contains base64 image #3918

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

Closed
mauvesteven opened this issue Jun 9, 2017 · 7 comments
Closed

Logging when cloud function result contains base64 image #3918

mauvesteven opened this issue Jun 9, 2017 · 7 comments

Comments

@mauvesteven
Copy link

Is there a way to turn off logging on a specific cloud function but not for all of them? My issue is that the result of my cloud function contains a base64 image, and Parse Server by default output the base64 string to the log, which makes my daily log files extremely large and hard to maintain.

setting logLevel = 'warn' instead of 'info' solves this problem but then I lost the I/O information of other cloud functions which I also need..

@acinader
Copy link
Contributor

acinader commented Jun 9, 2017

I wrote a test case see #3919

Just want to make sure I understand the issue.

Here's the log out put from this test:

[ { functionName: 'readImageToBase64',
    params: {},
    user: 'FKzEJUaKJ3',
    level: 'info',
add a failing test...
    message: 'Ran cloud function readImageToBase64 for user FKzEJUaKJ3 with:\n  Input: {}\n  Result: "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx4BBQUFBwYHDggIDh4UERQeHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHv/CABEIAiYCJgMBIgACEQEDEQH/xAAdAAABBQEBAQEAAAAAAAAAAAADAQIEBQYHAAgJ/9oACAEBAAAAAPm3OMKYriK4jkUj0ZHfVSCul9W+iNjHr4PKI2w0cS8vLGUWW0UfO8I5Gl3pzKijF4jXRF9IbGPE4+eqrxke9z3ecrBpJYD03ZdR65pnjjZ7mXQbHT0F7YWE0p2hicr4pRZ907XzSMcAR3j8xjCB84HFrZJXocKONofKriPir0ntGhtjSSqtLwDtm2kDsrKUc70BVfPnJ4NJXLc6SzmzHxmnM1zAkE0z2cTWbLn2BIxLIgEfMt9K7ZaBsUamJKN8rX/brV95azzIVsTHfNOBq6obyPkWNrc28xxkYNj3JJMeDygTZM2zlkiAsbq0tLS3tZZzeCN8mXM4NnNH0S5uLq2mIjIfHfmygqY5F85XkMaz0eklBOKOVynf4OIRHFJOkEGGRY3N1ZzZc2WZ3nlLzPJ3rpvUr40ie0VP818LgQfE8rfOOR5JEqw0FraMiFWOR7PU7mksvC9JM50mXY2FhYTZcgyoLA4zSkyG76tbuW2j4b5d5tCiFf5Go6QZy+kyTHuNJKAcFNYzG+rZE0ltNNHrY02VLPMlTJ0y6uJ5IHPMWObQ1ez11/ezZ/CfmargCP5vmeIQxDv8dwTz5866sxVUiQwtPPtjw7+xkXtHz315Z2dhsdxqJSt8iei884vl9lZ3mv0md+BYMNp0RgzEV0qewTXGAKbZkm6eyFHIIlIexn2Mq8vtM/LfOOTsuxfUewd5GiRyJ7y... (truncated)',
    timestamp: '2017-06-09T21:27:59.882Z' } ]

The message field of the log object is ~1000 characters which is set by this var in the LoggerController.

So, is my test accurate and the issue is that this log of ~1k char is too long -- which I buy, just making sure?

@mauvesteven
Copy link
Author

yes, this is similar to what I had..

@acinader
Copy link
Contributor

@flovilmart any thoughts? I chose 1k char limit to match parse.com. I don't really see a way to change this for the duration of a function since the logger is shared....

  1. make truncation chars configurable. wont fix it for just one function, but will at least make adjustable?
  2. add something to the response object to indicate not to log, or at least to make it really short.

@flovilmart
Copy link
Contributor

I'm ok with 1, that will help.
also, we could create a copy of the logger for each http request / response, this way we could use that logger for the cloud code life cycle no? This will let a user reconfigure the logger inside a beforeSave.

@acinader
Copy link
Contributor

I'm not going to have time to put a bow on this in the next month. could close or someone else can pick it up?

@virtualtoy
Copy link

@acinader problem is it logs 3 components that can be long: input, result and params:

logger.info(`Ran cloud function ${functionName} for user ${userString} with:\n  Input: ${cleanInput }\n  Result: ${cleanResult }`, {functionName, params, user: userString});

Input is stringified and trimmed params. Result is trimmed as well, but params is just a raw object which can be huge. Why not remove 3rd parameter completely and log it with verbose level?

@stale
Copy link

stale bot commented Sep 30, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

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

No branches or pull requests

4 participants