We are creating a logging module that will be added to several console apps and web apps. Throughout the code in the apps, we want to use the logging module to create log messages that end up on a Slack channel. However, we don’t want the logging module to introduce any issues or pauses while posting to the Slack API and we don’t want a scenario where we lose messages. We also don’t want to add complexity. The apps typically generate very few messages, but there have been situations where a thousand or more were generated on a single day.
Plan A
- All of the apps use the same local database and maintain a connection, so we can easily log messages to a database table.
- Have an external helper app monitor the table and post messages to Slack API
As a fail-safe:
1, If we cant write to the database, then post a Slack message directly from the app within the logging module.
2. If we can’t post a Slack message, then write to the system log.
Plan B
Have the logging module post log messages directly to the Slack API. Forget about the complexity of a separate helper app. Write to the system log if there is an error posting to the Slack API.
Which is the best option?