The PR implements a createLogger instance for each package to be used by the logs generated in the PWA Kit packages.
The logger uses the console object adding a consistent format to the message we want to print.
Proposes a consistent namespace for all default logs generated by PWA Kit to facilitate filtering and analyzing logs.
1.1. The namespace consists of 'packageName.component.action' where the log message is printed.
1.2. The optional additionalProperties defines any other additional properties to include in the log message.
Incoming request logs use the log level equivalent to the response status code. i.e. console.info for statusCode<400 console.error for statusCode >= 400
~~3. The environment variable PWAKIT_LOG_LEVEL defines the log level to filter the logs generated by PWA Kit server-side.
The environment variable PWAKIT_LOG_FORMAT defines the format in which to print log messages server-side. It can be 'JSON' or 'TEXT'.
The createLogger clientConfig object optional parameter allows users to define the format and logLevel for the client-side logs. E.g. createLogger('package-name', clientConfig(format, logLevel)~~
Description
The PR implements a createLogger instance for each package to be used by the logs generated in the PWA Kit packages. The logger uses the
console
object adding a consistent format to the message we want to print.Proposes a consistent namespace for all default logs generated by PWA Kit to facilitate filtering and analyzing logs. 1.1. The
namespace
consists of 'packageName.component.action' where the log message is printed. 1.2. The optionaladditionalProperties
defines any other additional properties to include in the log message.Incoming request logs use the log level equivalent to the response status code. i.e. console.info for statusCode<400 console.error for statusCode >= 400
~~3. The environment variable
PWAKIT_LOG_LEVEL
defines the log level to filter the logs generated by PWA Kit server-side.PWAKIT_LOG_FORMAT
defines the format in which to print log messages server-side. It can be 'JSON' or 'TEXT'.clientConfig
object optional parameter allows users to define theformat
andlogLevel
for the client-side logs. E.g.createLogger('package-name', clientConfig(format, logLevel)
~~Example using the logger utility: https://github.com/SalesforceCommerceCloud/pwa-kit/blob/05d7c8b0e0f00f48f2af989513b869bd50794290/packages/template-retail-react-app/app/components/_app/index.jsx#L157-L168
Related PR https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1828: Replace all the
console
statements in PWA Kit with the equivalentlogger
Types of Changes
Changes
How to Test-Drive This PR
npm start
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization