Import members from @edx/frontend-platform/logging
Contains a shared interface for logging information. (The default implementation is in NewRelicLoggingService.js.) When in development mode, all messages will instead be sent to the console.
The initialize
function performs much of the logging configuration for you. If, however,
you're not using the initialize
function, logging (via New Relic) can be configured via:
import { configure, NewRelicLoggingService, logInfo, logError } from '@edx/frontend-platform/logging';
import { geConfig } from '@edx/frontend-platform';
configureLogging(NewRelicLoggingService, {
config: getConfig(),
});
logInfo('Just so you know...');
logInfo(new Error('Unimportant error'), { type: 'unimportant' });
logError('Uhoh!');
logError(new Error('Uhoh error!'));
As shown in this example, logging depends on the configuration document.
- Source:
Classes
Interfaces
Methods
(inner) configure()
- Source:
(inner) getLoggingService() → {LoggingService}
- Source:
Throws:
-
Thrown if the logging service has not yet been configured via {@link configure}.
- Type
- Error
Returns:
- Type
- LoggingService
(inner) logError(errorStringOrObject, customAttributesopt)
Logs a message to the 'error' log level. Can accept custom attributes as a property of the error object, or as an optional second parameter.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
errorStringOrObject |
string | Error | |||
customAttributes |
Object |
<optional> |
{} |
- Source:
(inner) logInfo(infoStringOrErrorObject, customAttributesopt)
Logs a message to the 'info' log level. Can accept custom attributes as a property of the error object, or as an optional second parameter.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
infoStringOrErrorObject |
string | Error | |||
customAttributes |
Object |
<optional> |
{} |
- Source:
(inner) resetLoggingService()
Sets the configured logging service back to null.
- Source:
(inner) setCustomAttribute(name, value)
Sets a custom attribute that will be included with all subsequent log messages.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
value |
string | number | null |
- Source: