Message HandlingLearn how messages are parsed when creating a log.
LambdaLog does its best to parse any type of message you can provide it. You may pass in any JSON-stringify-able primitive value as a log such as
Boolean, along with any instance of an
undefined cannot be stringified into JSON and will throw an error.
You may pass in an object as a log message, but there are some limitations. It's best to use plain objects when possible.
- If the object is a class and has anything on the
prototype, these values will not be included in the message.
- Objects containing circular references will be truncated.
In many cases, you may log an
Error that occurred within your application. Errors may be passed in as the log message for any log level. LambdaLog determines if the provided value is an error by checking:
- The value is an object AND it's an instance of
- The value is an object AND it has a
If LambdaLog determines the value is an error, there is a few things that will happen:
- The log message is set to the value of the
stackproperty is added to the metadata for the log with the value of the error's
nameproperty is added to the metadata for the log with the value of the error's
- Any additional properties on the error object that is not on the
prototypewill be added to the log's metadata.