c2cwsgiutils 6.2.0.dev374__py3-none-any.whl → 6.2.0.dev376__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- c2cwsgiutils/sqlalchemylogger/README.md +30 -0
- c2cwsgiutils/sqlalchemylogger/handlers.py +24 -0
- {c2cwsgiutils-6.2.0.dev374.dist-info → c2cwsgiutils-6.2.0.dev376.dist-info}/METADATA +1 -1
- {c2cwsgiutils-6.2.0.dev374.dist-info → c2cwsgiutils-6.2.0.dev376.dist-info}/RECORD +7 -7
- {c2cwsgiutils-6.2.0.dev374.dist-info → c2cwsgiutils-6.2.0.dev376.dist-info}/WHEEL +0 -0
- {c2cwsgiutils-6.2.0.dev374.dist-info → c2cwsgiutils-6.2.0.dev376.dist-info}/entry_points.txt +0 -0
- {c2cwsgiutils-6.2.0.dev374.dist-info → c2cwsgiutils-6.2.0.dev376.dist-info}/licenses/LICENSE +0 -0
|
@@ -63,3 +63,33 @@ if __name__ == '__main__':
|
|
|
63
63
|
# logs after a timeout
|
|
64
64
|
time.sleep(2)
|
|
65
65
|
```
|
|
66
|
+
|
|
67
|
+
## Use with forking server (ex: `gunicorn`)
|
|
68
|
+
|
|
69
|
+
Snippet for configuration with `gunicorn` and `paste`:
|
|
70
|
+
|
|
71
|
+
`production.ini`:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
[handler_sqlalchemylogger]
|
|
75
|
+
class = c2cwsgiutils.sqlalchemylogger.handlers.SQLAlchemyHandler
|
|
76
|
+
args = ({'url':'postgresql://','tablename':'logs','tableargs': {'schema':'logs'}, 'delay_startup': True},'healthcheck')
|
|
77
|
+
level = NOTSET
|
|
78
|
+
formatter = generic
|
|
79
|
+
propagate = 0
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`gunicorn.conf.py`:
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
def post_fork(server, worker):
|
|
86
|
+
import logging
|
|
87
|
+
logger = logging.getHandlerByName('sqlalchemylogger')
|
|
88
|
+
logger.start()
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The gunicorn must be started with this config file:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
gunicorn -c gunicorn.conf.py [...]
|
|
95
|
+
```
|
|
@@ -36,6 +36,29 @@ class SQLAlchemyHandler(logging.Handler):
|
|
|
36
36
|
) -> None:
|
|
37
37
|
"""Initialize the SQLAlchemyHandler."""
|
|
38
38
|
super().__init__()
|
|
39
|
+
|
|
40
|
+
self.started = False
|
|
41
|
+
if sqlalchemy_url.get("delay_startup", False):
|
|
42
|
+
self.sqlalchemy_url = sqlalchemy_url
|
|
43
|
+
self.does_not_contain_expression = does_not_contain_expression
|
|
44
|
+
self.contains_expression = contains_expression
|
|
45
|
+
else:
|
|
46
|
+
self._start(sqlalchemy_url, does_not_contain_expression, contains_expression)
|
|
47
|
+
|
|
48
|
+
def start(self) -> None:
|
|
49
|
+
"""Force startup of logger in case of delayed startup."""
|
|
50
|
+
self._start(self.sqlalchemy_url, self.does_not_contain_expression, self.contains_expression)
|
|
51
|
+
|
|
52
|
+
def _start(
|
|
53
|
+
self,
|
|
54
|
+
sqlalchemy_url: dict[str, str],
|
|
55
|
+
does_not_contain_expression: str,
|
|
56
|
+
contains_expression: str,
|
|
57
|
+
) -> None:
|
|
58
|
+
if self.started:
|
|
59
|
+
# only start once
|
|
60
|
+
return
|
|
61
|
+
|
|
39
62
|
# Initialize DB session
|
|
40
63
|
self.engine = create_engine(sqlalchemy_url["url"])
|
|
41
64
|
self.Log = create_log_class( # pylint: disable=invalid-name
|
|
@@ -55,6 +78,7 @@ class SQLAlchemyHandler(logging.Handler):
|
|
|
55
78
|
self.addFilter(DoesNotContainExpression(does_not_contain_expression))
|
|
56
79
|
if contains_expression:
|
|
57
80
|
self.addFilter(ContainsExpression(contains_expression))
|
|
81
|
+
self.started = True
|
|
58
82
|
|
|
59
83
|
def _processor(self) -> None:
|
|
60
84
|
_LOG.debug("%s: starting processor thread", __name__)
|
|
@@ -47,13 +47,13 @@ c2cwsgiutils/services.py,sha256=ZgJcFpZHog7Cg998c8xYxDrYKNZJxSvOT8K3bhCKwbc,1606
|
|
|
47
47
|
c2cwsgiutils/setup_process.py,sha256=BDHCPegT2pIYVfmXeqP0jByNl3R_bs3htLwLMhlqHMU,3624
|
|
48
48
|
c2cwsgiutils/sql_profiler/__init__.py,sha256=NeKXxNxSpLaIp-1FaddBejzMEubdQ9dnqtfddq027Ls,958
|
|
49
49
|
c2cwsgiutils/sql_profiler/_impl.py,sha256=8-YtSQjPKL6RVTiHtcNtT9kESwoQj5Pw5bw-YnSPLc0,3801
|
|
50
|
-
c2cwsgiutils/sqlalchemylogger/README.md,sha256=
|
|
50
|
+
c2cwsgiutils/sqlalchemylogger/README.md,sha256=4nfSo_aLOHtt8UgPZrbRy65_-reG3-SugvwdGvcQPM0,2672
|
|
51
51
|
c2cwsgiutils/sqlalchemylogger/__init__.py,sha256=pkqbKuATfEJFGtJhN7Al_pCqPeSKFJh55pqW94LU6X0,36
|
|
52
52
|
c2cwsgiutils/sqlalchemylogger/_filters.py,sha256=cxAXd9Wa8Wa_aKrubEWRoeDrfC_jNaH0-Dt1DSWL18c,789
|
|
53
53
|
c2cwsgiutils/sqlalchemylogger/_models.py,sha256=m3qjET5iovifeUkgTuBzEWyDGCg__Os0UcpJ5J26F5E,1512
|
|
54
54
|
c2cwsgiutils/sqlalchemylogger/examples/__init__.py,sha256=pkqbKuATfEJFGtJhN7Al_pCqPeSKFJh55pqW94LU6X0,36
|
|
55
55
|
c2cwsgiutils/sqlalchemylogger/examples/example.py,sha256=2gQcVrXKqONyNdx9xkzxjpY_uhriRUl1MlN78ZQ1Ws8,497
|
|
56
|
-
c2cwsgiutils/sqlalchemylogger/handlers.py,sha256=
|
|
56
|
+
c2cwsgiutils/sqlalchemylogger/handlers.py,sha256=1OgZScCB5yjZpUPW5qxDST94345yAWM0Hd4FQuSLJkU,5793
|
|
57
57
|
c2cwsgiutils/static/favicon-16x16.png,sha256=LKk6RFvb3NlPIZdDfAodE8H9IN8KM6CMGnMx4vOHlUQ,887
|
|
58
58
|
c2cwsgiutils/static/favicon-32x32.png,sha256=i4ucx08zAZARd8e7JTMGK-gb5WcOmyuDN6IN4brsEOo,1216
|
|
59
59
|
c2cwsgiutils/stats_pyramid/__init__.py,sha256=1_r66Kk955nGJ6DpchAAI0j2ZZIpZoa-_I_URnBKS60,838
|
|
@@ -61,8 +61,8 @@ c2cwsgiutils/stats_pyramid/_db_spy.py,sha256=HV9tEFCkOhcBS-U1_DicLe3y3TGAVc_sxEt
|
|
|
61
61
|
c2cwsgiutils/stats_pyramid/_pyramid_spy.py,sha256=GeV7a_AKDjcToIVpju4T3KBI64yCG6IWw_6nw_IAlFM,3535
|
|
62
62
|
c2cwsgiutils/templates/index.html.mako,sha256=e54pfSL0nGRsnJkahFRLevNyUhvlCNb_2uVaO8rDhbg,1416
|
|
63
63
|
c2cwsgiutils/version.py,sha256=3youfhXNIwZXuOqjDMUua2njF0cQS75FCuW1AMCldgs,3193
|
|
64
|
-
c2cwsgiutils-6.2.0.
|
|
65
|
-
c2cwsgiutils-6.2.0.
|
|
66
|
-
c2cwsgiutils-6.2.0.
|
|
67
|
-
c2cwsgiutils-6.2.0.
|
|
68
|
-
c2cwsgiutils-6.2.0.
|
|
64
|
+
c2cwsgiutils-6.2.0.dev376.dist-info/METADATA,sha256=EirgNAbFoLnXAFpw7rrjLP3bxwsyY8e5xtdt9-kdQmQ,37533
|
|
65
|
+
c2cwsgiutils-6.2.0.dev376.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
|
|
66
|
+
c2cwsgiutils-6.2.0.dev376.dist-info/entry_points.txt,sha256=ujgqMTL1awN9qDg8WXmrF7m0fgR-hslUM6zKH86pvy0,703
|
|
67
|
+
c2cwsgiutils-6.2.0.dev376.dist-info/licenses/LICENSE,sha256=hCNci_ppSy6SKe_nTdgzjCsTIaNQgAKqDSghWn_G-1I,1304
|
|
68
|
+
c2cwsgiutils-6.2.0.dev376.dist-info/RECORD,,
|
|
File without changes
|
{c2cwsgiutils-6.2.0.dev374.dist-info → c2cwsgiutils-6.2.0.dev376.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{c2cwsgiutils-6.2.0.dev374.dist-info → c2cwsgiutils-6.2.0.dev376.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|