Mobicoop V3 logging service
Go to file
Gsk54 25041325a2 add auth and configuration logs 2023-01-26 10:36:47 +01:00
src add auth and configuration logs 2023-01-26 10:36:47 +01:00
.editorconfig initial commit 2022-12-23 16:36:23 +01:00
.env.dist simplify compose 2023-01-06 14:44:54 +01:00
.eslintrc.js initial commit 2022-12-23 16:36:23 +01:00
.gitignore initial commit 2022-12-23 16:36:23 +01:00
.gitlab-ci.yml add auth and configuration logs 2023-01-26 10:36:47 +01:00
.prettierrc initial commit 2022-12-23 16:36:23 +01:00
Dockerfile update dockerfile 2023-01-04 13:59:47 +01:00
README.md update readme 2023-01-04 13:51:53 +01:00
docker-compose.yml simplify compose 2023-01-06 14:44:54 +01:00
jest-e2e.json initial commit 2022-12-23 16:36:23 +01:00
nest-cli.json initial commit 2022-12-23 16:36:23 +01:00
package-lock.json dynamic dir and names, log rotation 2022-12-26 15:08:51 +01:00
package.json add auth and configuration logs 2023-01-26 10:36:47 +01:00
tsconfig.build.json initial commit 2022-12-23 16:36:23 +01:00
tsconfig.json initial commit 2022-12-23 16:36:23 +01:00

README.md

Mobicoop V3 - Logger Service

Logging system for all services.

Requirements

You need Docker and its compose plugin.

A RabbitMQ instance is also required to receive messages from other services.

Installation

Copy .env.dist to .env :

cp .env.dist .env

and modify it to suit your needs.

Then execute :

docker compose up -d

The app runs automatically on the port defined in SERVICE_PORT of .env file (default : 5099).

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
  • action : the action that was at the origin of the message (one or more words separated by a dot)
  • level : the severity (log level) of the message, as described in RFC5424 syslog :
    • 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 :

  • user.create.info
  • user.create.crit
  • user.update.warning
  • auth.username.add.info

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).

Test

# unit tests
docker exec v3-user sh -c "npm run test"

# test coverage
docker exec v3-user sh -c "npm run test:cov"

Note : you can run all npm commands directly outside the container (see scripts section of package.json for available commands), but you need NodeJS installed locally. We strongly advise to install Node Version Manager and use the latest LTS version of Node.

License

Mobicoop V3 - Logger Service is AGPL licensed.