adobe/aio-lib-core-logging

logging should pretty print objects

purplecabbage opened this issue · 8 comments

console.log(obj1 [, obj2, ..., objN])

console.log outputs a hson representation of each object passed to it.

console.log('resolver got request: ', request)
aioLogger.debug('resolver got request: ', request)
// console.log output:
2020-03-10T23:00:56.312Z       stdout: resolver got request:  { org: 'asdsomeorg@AdobeOrg',
  path: '/',
  clientId: 'aio-app-myapple',
  tenant: '3124',
  imsProfile: ...
  ...
}
// aioLogger.debug output:
2020-03-10T23:00:56.313Z       stdout: 2020-03-10T23:00:56.312Z @adobe/aio-app-myapps/resolver:debug resolver got request:

Should we remove debug as a logging provider and only use winston

  • winston provides JSON formatted out of the box

+1

The expected behaviour for this would be to be able to pass multiple messages to the logger

aioLogger.info('hello ', myname, ' hope you have a great day!') will only output hello

The docs imply multiple messages, can be provided but don't specify how.

It would also be useful to have a console.table() equivalent in the logger. Let me know if I should raise that as a separate issue, or add to an existing issue regarding replacing the logger.

thanks Jason! please file console.table as a separate enhancement.

Inspecting the code, it accepts variadic arguments for all loggers: https://github.com/adobe/aio-lib-core-logging/tree/master/src so perhaps there is something wrong in a lower level library

I've changed the label to bug - winston (the default logger) does not accept variadic arguments, but the debug formatter does. It has a complicated formatter system - the easy fix is to combine all variadic arguments into a string that is passed into winston

Thanks @shazron, that is what I'm currently doing.

PR #36