Npm log levels used for the SAP Cloud SDK logger.
Default logger for the SAP Cloud SDK for unhandled exceptions.
Format for logging in Kibana.
Format for local logging.
Calls rambda's assoc function if the provided value is neither null nor undefined. Note that this is different to JS idiomatic checks for truthy/falsy values, i.e. an empty string will result in assoc being called.
The key to associate with the given value.
The value to associate with the given key.
A copy of the input object with the new key-value pair if the value is neither null nor undefined.
Works similar to Ramdas pipe function, but works on promises, which allows using async functions.
The functions to be chained.
Create a logger for the given message context, if available.
Usage:
To create a logger in your module, it is recommended to pass a module identifier that will be logged as messageContext
for all messages from this logger:
const logger = createLogger('my-module');
. Not setting any module identifier will retrieve the default logger.
Use this logger throughout your module. If the module is spread over multiple files, you can retrieve the logger instance by calling the createLogger
function with the respective module identifier.
There will always be only one instance of a logger per module identifier.
You can pass any custom data that you want to be logged in addition by passing an object instead. You can change the default logging level (INFO
) using the level
key in the object.
In those cases, provide the messageContext
as a key in the object:
const logger = createLogger({
messageContext: 'my-module',
myCustomKey: 'my-custom-data',
level: 'debug'
});
You will find these information under the custom_fields key in your Cloud Foundry logs.
To retrieve a logger after its creation use getLogger. If you want to change the log level of a logger use setLogLevel.
Either a key for the message context of all messages produced by the logger or an object with additional keys to set in the message.
A newly created or an already existing logger for the given context.
Disable logging of exceptions. Enabled by default.
Enable logging of exceptions. Enabled by default.
Creates a new error using the provided message and appends the causes stacktrace to the new error's stacktrace.
The message of the new error.
The original error.
A new error instance.
Flatten a multidimensional array
Multidimensional array to be flattened
Flattened array
Get logger for a given message context, if avilable.
A key for the message context of all messages produced by the logger
The logger for the given messageContext if it was created before
Calls rambda's merge function if second object is neither null nor undefined.
The object to merge into.
The object which to merge into a.
A copy of the merge(a, b) or a if b is undefined or null.
Checks if a chain of properties exists on the given object.
The object to be checked.
Chained properties.
True if the property chain leads to a truthy value, false otherwise.
Takes an object and returns a new object whose keys are renamed according to the provided key mapping. Any keys in the input object not present in the key mapping will be present in the output object as-is. If a key in the key mapping is not present in the input object, the output object will contain the key with value "undefined".
An object mapping keys of the input object to keys of the output object.
The input object.
An object with renamed keys.
Change the log level of a logger based on its message context.
E. g., to set the log level for the destination accessor module of the SDK to debug, simply call setLogLevel('debug', 'destination-acessor')
.
level to set the logger to
Message context of the logger to change the log level for or the logger itself
Remove all duplicates from array
Array of strings that might contain duplicates
Array of unique strings
cloud-sdk-utils
Package that contains general utility functions that we reuse multiple times in the SDK. While primarily designed for internal usage, they might also be benefical for consumers of the SDK.
Helpful Links