-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun_report_service.py
executable file
·52 lines (41 loc) · 1.31 KB
/
run_report_service.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from pathlib import Path
from typing import Any
import logging
import sys
from autobot.config import Settings
from moderation.activity import ReportService
import structlog
def configure_structlog() -> None:
procs: list[Any] = [
structlog.stdlib.filter_by_level,
structlog.stdlib.add_logger_name,
structlog.stdlib.add_log_level,
structlog.stdlib.PositionalArgumentsFormatter(),
structlog.processors.TimeStamper(fmt="iso"),
structlog.processors.StackInfoRenderer(),
structlog.processors.UnicodeDecoder()
]
if sys.stderr.isatty():
procs.append(structlog.dev.ConsoleRenderer())
else:
procs.append(structlog.processors.JSONRenderer())
structlog.configure(
processors=procs,
wrapper_class=structlog.stdlib.BoundLogger,
logger_factory=structlog.stdlib.LoggerFactory(),
cache_logger_on_first_use=True,
)
if __name__ == '__main__':
configure_structlog()
logging.basicConfig(
format="%(message)s",
stream=sys.stdout,
level=logging.INFO
)
log = structlog.get_logger()
cfg = Settings()
log.info("Report service starting")
cd = Path(__file__).resolve().parent
td = cd / "moderation" / "templates"
svc = ReportService(cfg, td, log)
svc.run(interval=600)