Skip to content

Commit

Permalink
Make log format configurable
Browse files Browse the repository at this point in the history
This patch makes the logging format configurable using the environment
variable `LOGGING_FORMAT`:

    LOGGING_FORMAT="%(asctime)s: %(message)s"
  • Loading branch information
lkiesow committed Feb 12, 2025
1 parent 7700565 commit f8180f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ MONGODB_URI=mongodb://mongodb:27017/
# Configure log level
LOGGING_LEVEL=info

# Configure log format
LOGGING_FORMAT="%(asctime)s - %(levelname)s - %(message)s"

# Specify Mongo Database - Optional. Defaults to "LibreChat"
MONGODB_DATABASE=librechat
```
Expand Down
4 changes: 3 additions & 1 deletion metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

# Set up logging
loglevel = os.getenv("LOGGING_LEVEL", "info").upper()
logging.basicConfig(level=loglevel)
logformat = os.getenv("LOGGING_FORMAT", "%(asctime)s - %(levelname)s - %(message)s")
logging.basicConfig(format=logformat, level=loglevel)
logger = logging.getLogger(__name__)
logger.debug("Set log level to %s", logging.getLevelName(logger.getEffectiveLevel()))


class LibreChatMetricsCollector(Collector):
Expand Down

0 comments on commit f8180f7

Please sign in to comment.