2022-12-23 15:36:23 +00:00
# Mobicoop V3 - Logger Service
2022-12-23 15:20:08 +00:00
2022-12-23 15:36:23 +00:00
Logging system for all services.
2022-12-23 15:20:08 +00:00
2022-12-23 15:36:23 +00:00
## Requirements
2022-12-23 15:20:08 +00:00
2023-01-04 12:51:53 +00:00
You need [Docker ](https://docs.docker.com/engine/ ) and its [compose ](https://docs.docker.com/compose/ ) plugin.
2022-12-23 15:20:08 +00:00
2022-12-23 15:36:23 +00:00
A RabbitMQ instance is also required to receive messages from other services.
2022-12-23 15:20:08 +00:00
2022-12-23 15:36:23 +00:00
## Installation
2022-12-23 15:20:08 +00:00
2022-12-23 15:36:23 +00:00
Copy `.env.dist` to `.env` :
2022-12-23 15:20:08 +00:00
2022-12-23 15:36:23 +00:00
```bash
cp .env.dist .env
2022-12-23 15:20:08 +00:00
```
2022-12-23 15:36:23 +00:00
and modify it to suit your needs.
2022-12-23 15:20:08 +00:00
2022-12-23 15:36:23 +00:00
Then execute :
2022-12-23 15:20:08 +00:00
2022-12-23 15:36:23 +00:00
```bash
2023-01-04 12:51:53 +00:00
docker compose up -d
2022-12-23 15:36:23 +00:00
```
2022-12-23 15:20:08 +00:00
2022-12-23 15:36:23 +00:00
The app runs automatically on the port defined in `SERVICE_PORT` of `.env` file (default : _5099_ ).
2022-12-23 15:20:08 +00:00
2022-12-26 14:08:51 +00:00
## Usage
The app subscribes to RabbitMQ queues in order to log messages. We use the routing key with the given format : < **service**>.< **action**>.< **level**>, with :
- **service** : the name of the service that has emitted the message
2023-06-29 10:24:56 +00:00
- **action** : the action that triggered the message (one or more words separated by a dot, last word should be a past action)
2022-12-26 14:08:51 +00:00
- **level** : the severity (_log level_) of the message, as described in [RFC5424 syslog ](https://www.rfc-editor.org/rfc/rfc5424 ) :
- **emer** : Emergency: system is unusable
- **alert** : Alert: action must be taken immediately
- **crit** : Critical: critical conditions
- **error** : Error: error conditions
- **warning** : Warning: warning conditions
- **notice** : Notice: normal but significant condition
- **info** : Informational: informational messages
- **debug** : Debug: debug-level messages
Examples of valid routing keys :
2023-06-29 09:49:07 +00:00
- user.created.info
- user.created.crit
- user.updated.warning
- auth.username.added.info
2022-12-26 14:08:51 +00:00
It is the responsibility of each service to set the routing key to the appropriate value.
To handle logs for a given service, a controller corresponding to the service must be set. In this controller, you must define a handler for each action and level. You must also define a unique RabbitMQ queue for this handler (this permits to use durable queues, allowing to keep logs in RabbitMQ even if the logger service is down).
2022-12-23 15:20:08 +00:00
## License
2022-12-23 15:36:23 +00:00
Mobicoop V3 - Logger Service is [AGPL licensed ](LICENSE ).