2bcab5d098
- moved all server related things into the folder `server`, so this configuration is parallel to the client. - All main "services" are now folders in the root directory - Added Dockerfiles to each service (currently server and client) - Added a docker compose configuration to start everything together. Currently there are heavy dependencies into https://github.com/OpenSlides/openslides-docker-compose - Resturctured the .gitignore. If someone needs something excluded, please add it to the right section. - Added initial build setup with Docker and docker-compose. - removed setup.py. We won't deliver OpenSlides via pip anymore.
30 lines
887 B
Python
30 lines
887 B
Python
import logging as python_logging
|
|
from typing import Any, MutableMapping, Tuple
|
|
|
|
from .utils import get_worker_id
|
|
|
|
|
|
class LoggerAdapter(python_logging.LoggerAdapter):
|
|
"""
|
|
Custom adapter for adding a prefix given in the constructor to every log
|
|
statement.
|
|
"""
|
|
|
|
def __init__(self, prefix: str, logger: python_logging.Logger) -> None:
|
|
super().__init__(logger, {})
|
|
self.prefix = prefix
|
|
|
|
def process(
|
|
self, msg: str, kwargs: MutableMapping[str, Any]
|
|
) -> Tuple[str, MutableMapping[str, Any]]:
|
|
return f"[{self.prefix}] {msg}", kwargs
|
|
|
|
|
|
def getLogger(name: str) -> LoggerAdapter:
|
|
"""
|
|
This method is for a drop-in replacement for the loggging module:
|
|
Use `from openslides.utils import logging` instead of `import logging`
|
|
"""
|
|
logger = python_logging.getLogger(name)
|
|
return LoggerAdapter(get_worker_id(), logger)
|