Overview
To support developers in analyzing lambdas
as they work, we support logging functions. This feature gives you the ability to add logs to your lambdas
, in order to monitor the execution & behaviour of your function.
These logs will be stored after every lambda
invocation (except manual invocations) for 30 days. You are able to view these logs at Investigate Function Logs. How to log is described in the next chapter below.
Logging Function behavior
The different log-levels are: debug
, info
, warn
and error
. All functions take a string as a log message and multiple instances of the extra
parameter. These extra
parameters are JavaScript objects, providing further insights about the runtime execution. An example for a function which is logged can be found in the LivePerson Functions Templates (at "Logging Template").
The template for the logging functions is as follows:
console.<info/debug/warn/error>(<message> [, extra])
Component | Type | Notes |
---|---|---|
log-level | Method | Method names correspond to the different log-levels and influence in which way the logs are displayed within LivePerson Functions. Current levels are: console.debug(), console.info(), console.warn() and console.error() |
message | String | Message defines the message to be displayed in the logs. |
extras | Any | An object which will then be wrapped in an Array and displayed in the log for additional information. |
Example code for logging a function:
function lambda(input, callback) {
console.debug('This is a simple debug message', {
'bugs': 'none!'
});
console.info('Informing you about important news', new Date(), Number.MAX_SAFE_INTEGER);
try {
console.warn('Starting a non-existent function');
nonExistentFunction();
} catch (e) {
console.error('You cannot call what you did not create');
}
callback(null, 'Function has finished...');
}
After deployment, you should be able to manually invoke your lambda
and see the logs written in the Logs
section.
Be aware that logs written during manual test invocations will not be written into the storage. Logs with a Debug level will only be shown on manual test invocations and not written into the storage.
- This feature allows you to log sensitive information, since there's no sanitation or limitations on the logged parameters! Please be considerate with your logged values and don't pass any sensitive information to this function, e.g a token or password.
- Logs written during invocation are limited to 10 entries, with an overall maximum of 5000 characters per lambda invocation. If this limit is exceeded, only 1 error log will be stored.
Accessing Logs Storage
LivePerson Functions allows developers to investigate lambda
logs.
Logs of a certain function can be accessed during development & deployment via the button on the right side. Moreover, our left-hand sidebar allows to also directly navigate to the Investigate Function Logs
screen.
When navigating to the Investigate Function Logs
screen from a selected function, the search parameters should be pre-defined. In case the left-hand sidebar is used, the relevant lambda
needs to be selected from the dropdown.
To fine-tune the selected lambda
logs, the following search parameters can be adjusted:
-
Function: The
lambda
the logs should be displayed for - Log Levels: The log levels you want to see (selecting no log level will cause all levels to be displayed)
- Start Date: The timestamp from which the logs will be shown (only the last 30 days can be selected)
- End Date: The timestamp to which the logs will be shown (must be after Start Date)
After selecting the parameters, a click on the SEARCH button will show you the logs for the parameters set.