Typescript & Serverless Logging System
A guide for our Typescript & Serverless logs system which is available through our Open Source project on Github.
The following guide describes the principles that use in our Typescript Serverless projects which we have made available through our Open Source starter project whose repository is available in the link below.
Log processes and objects through 4 types of commands
The functionality behind our logging system can be found in under utils/logs in our Typescript Serverless Open Source starter project and are broken down into four variations: In Progress, Failed, Complete & Success.
Each of these variations is exported as a function that takes in a process and an optional object; with the idea that you always the state that your process is in, and in some cases, the objects that are related to steps within the process.
For example, consider a function that stores customer data in your database that has a process identifier of "Store Customer Data". As part of your function, you would use:
- The In Progress log functionality with the process identifier to log the process has begun.
- The Failed Log functionality with the process identifier and customer object to log if the process failed.
- The Success Log functionality with the process identifier and object to log if the data was stored successfully.
- The Complete Log functionality with the process identifier before ending the API call to log that the function was completed successfully.
⚈ ⚈ ⚈ In Progress ⚈ ⚈ ⚈
The In Progress log makes use of the ⚈ ⚈ ⚈ emoji and is recommended to be used with clear identifiers when:
- Functions start to indicate that the function is in progress.
- Modules, such as storing data or gathering data from the backend, start to indicate that subtasks have begun and are in progress.
❌ Failed
The Failed log makes use of the ❌ emoji and is recommended to be used with clear identifiers when:
- Functions return an error in the response to indicate that the function has failed.
- Modules, such as storing data or gathering data from the backend, fail to indicate that subtasks have failed to be executed as expected.
✅ Success
The Success log makes use of the ✅ emoji and is recommended to be used with clear identifiers when:
- Modules, such as storing data or gathering data from the backend, succeed to indicate that subtasks have been executed as expected.
✅ Complete
The Complete log makes use of the ✅ emoji and is recommended to be used with clear identifiers when:
- Functions return an successful response to indicate that the function has successfully completed all the expected tasks and has reached the end of the service.
Any Questions?
We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.