User-facing Logging
Once a lambda-based connector finished execution, it should return a stats object along with the rest of the data. The stats object will be used to create log entries and show them to a user on the Apination UI.
Stats Format
{
// ...
stats: {
// A single object name (e.g. contact, transaction, update),
// will be used to format a user-facing log messages
objectName: 'object',
// A plural object name (e.g. contacts, transactions, updates),
// will be used to format a user-facing log message
objectNamePlural: 'objects',
// Each of the below entries can be either a small array of user-facing ref numbers,
// or a numeric value representing amount of retrieved/created/updated/deleted objects.
// "retrieved" is only used for triggers
// "created", "updated" and "deleted" are used for actions
retrieved: ['reference number 1', 'reference number 2']
created: 0,
updated: 0,
deleted: 0
}
}
Based on the returned stats data, one of the following messages will be logged:
- Trigger (main/top-level log entry)
- {Object} retrieved ({Reference Number})
- {Num} {objects} retrieved ({Reference Number 1}, {Reference Number 2}, …)
- {Num} {objects} retrieved
- {Error Message}
- Action (child log entries)
- {Object} created ({Reference Number})
- {Num} {objects} created ({Reference Number 1}, {Reference Number 2}, …)
- {Num} {objects} created
- {Object} updated ({Reference Number})
- {Num} {objects} updated ({Reference Number 1}, {Reference Number 2}, …)
- {Num} {objects} updated
- {Object} deleted ({Reference Number})
- {Num} {objects} deleted ({Reference Number 1}, {Reference Number 2}, …)
- {Num} {objects} deleted
- {Error Message}
Tricky Hacks
If you need to show logs for large amounts of data retrieved from a couple of different systems, you can make it similar to cn-mls connector:
{
stats: {
objectName: "MLS listing batch",
objectNamePlural: "MLS listing batches",
retrieved: [
"KAAR - 50 listings",
"MLS - 20 listings"
]
}
}
which produces the following message:
2 MLS listing batches retrieved (KAAR - 50 listings, MLS - 20 listings)
Technical Logging
All connector functions must log enough information to trace the problem if that will be needed, but is not allowed to log any sensitive user information.
AWS Lambda functions log standard output to AWS CloudWatch, which is available on the AWS Console. You can find more details in the Logging sections of the AWS documentation (NodeJS, Python).