CatchTheTornado / CatchTheTornado/text-extract-api

[feat] Implement a universal logger

Open
#72 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
3.2k
Forks
279
PR merge metrics
No merged PRs in 30d

Description

We need a logger that works well both locally (for devs) and in production (like containerized setups). It should be configurable, support multiple outputs (file/stdout/stderr), and handle different formats (plain text, JSON). Also, it should be easy to configure via env vars.

## Requirements

- [ ] **Environment-based configuration**
- All settings (log level, format, output, etc.) should be configurable via env vars.

- [ ] **Default output**
- Logs should go to a file (`pdf-extract-api.log`) by default.
- Allow overriding the file path with an env var, e.g., `LOG_FILE`.

- [ ] **Support multiple formats**
- Add **plain text** format: `[YYYY-MM-DD HH:MM:SS] LEVEL - Message`.
- Add **JSON** format for structured logging.
- Configurable via an env var, e.g., `LOG_FORMAT` (`plain/json`).
- Default: `plain`.

- [ ] **Support multiple outputs**
- Add support for `stdout` (for containers) and `stderr` (for errors).
- Control output via an env var, e.g., `LOG_OUTPUT` (`file/stdout`).
- Default: `file`.

- [ ] **Configurable log levels**
- Support levels: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`.
- Make log level configurable via `LOG_LEVEL`. Default: `INFO`.

## Optional

- [ ] **File rotation** (OPTIONAL)
- If files, implement log rotation when logging to files (e.g., {LOG_MAX_ONE_FILE_SIZE} MB max, keep {LOG_BACKUP_KEEP_COUNT} backups).
- I'm not sure if we should do it - it's usualy devops job, but it might be handy for us so why not let other people use it ;-)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.