fluidattacks-core 5.0.1__py3-none-any.whl → 5.1.0__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.
- fluidattacks_core/logging/filters.py +11 -1
- fluidattacks_core/logging/handlers.py +17 -2
- {fluidattacks_core-5.0.1.dist-info → fluidattacks_core-5.1.0.dist-info}/METADATA +1 -1
- {fluidattacks_core-5.0.1.dist-info → fluidattacks_core-5.1.0.dist-info}/RECORD +6 -6
- {fluidattacks_core-5.0.1.dist-info → fluidattacks_core-5.1.0.dist-info}/WHEEL +0 -0
- {fluidattacks_core-5.0.1.dist-info → fluidattacks_core-5.1.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
-
from fluidattacks_core.logging.sources.utils import get_environment
|
|
3
|
+
from fluidattacks_core.logging.sources.utils import get_env_var, get_environment
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class NoProductionFilter(logging.Filter):
|
|
@@ -11,3 +11,13 @@ class NoProductionFilter(logging.Filter):
|
|
|
11
11
|
class ProductionOnlyFilter(logging.Filter):
|
|
12
12
|
def filter(self, _record: logging.LogRecord) -> bool:
|
|
13
13
|
return get_environment() == "production"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ErrorOnlyFilter(logging.Filter):
|
|
17
|
+
def filter(self, _record: logging.LogRecord) -> bool:
|
|
18
|
+
return _record.levelno >= logging.ERROR
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class EnabledTelemetryFilter(logging.Filter):
|
|
22
|
+
def filter(self, _record: logging.LogRecord) -> bool:
|
|
23
|
+
return str(get_env_var("TELEMETRY_OPT_OUT")).lower() != "true"
|
|
@@ -7,7 +7,12 @@ from typing import TextIO
|
|
|
7
7
|
|
|
8
8
|
import simplejson as json
|
|
9
9
|
|
|
10
|
-
from fluidattacks_core.logging.filters import
|
|
10
|
+
from fluidattacks_core.logging.filters import (
|
|
11
|
+
EnabledTelemetryFilter,
|
|
12
|
+
ErrorOnlyFilter,
|
|
13
|
+
NoProductionFilter,
|
|
14
|
+
ProductionOnlyFilter,
|
|
15
|
+
)
|
|
11
16
|
from fluidattacks_core.logging.formatters import ColorfulFormatter, CustomJsonFormatter
|
|
12
17
|
|
|
13
18
|
|
|
@@ -114,7 +119,14 @@ class DatadogLogsHandler(HTTPHandler):
|
|
|
114
119
|
|
|
115
120
|
|
|
116
121
|
class TelemetryAsyncHandler(CustomQueueHandler):
|
|
117
|
-
"""Logging handler for sending logs to telemetry services asynchronously.
|
|
122
|
+
"""Logging handler for sending logs to telemetry services asynchronously.
|
|
123
|
+
|
|
124
|
+
To enable telemetry, set the `TELEMETRY_OPT_OUT` environment variable different from `true`.
|
|
125
|
+
|
|
126
|
+
Includes:
|
|
127
|
+
- Filters: `ErrorOnlyFilter`, `EnabledTelemetryFilter`
|
|
128
|
+
- Formatter: `CustomJsonFormatter`
|
|
129
|
+
"""
|
|
118
130
|
|
|
119
131
|
def __init__(self, service: str, source: str, dd_client_token: str) -> None:
|
|
120
132
|
"""Initialize the TelemetryAsyncHandler.
|
|
@@ -125,6 +137,9 @@ class TelemetryAsyncHandler(CustomQueueHandler):
|
|
|
125
137
|
dd_client_token: The Datadog Client Token.
|
|
126
138
|
|
|
127
139
|
"""
|
|
140
|
+
self.addFilter(ErrorOnlyFilter())
|
|
141
|
+
self.addFilter(EnabledTelemetryFilter())
|
|
142
|
+
|
|
128
143
|
handler = DatadogLogsHandler(service, source, dd_client_token)
|
|
129
144
|
handler.setFormatter(CustomJsonFormatter())
|
|
130
145
|
|
|
@@ -30,9 +30,9 @@ fluidattacks_core/http/__init__.py,sha256=3Zz90L6e3_z-M-8Bvk_53rv-CFhPThkRGXnxCi
|
|
|
30
30
|
fluidattacks_core/http/client.py,sha256=jIhtGU2cKi5GZbxHq8WJOPgnk0beScRtxlz9tBSaKuw,2454
|
|
31
31
|
fluidattacks_core/http/validations.py,sha256=h10Hr906KJqda1rJJb8eOqk1Xyyz81lAJ1glXeae4kM,3766
|
|
32
32
|
fluidattacks_core/logging/__init__.py,sha256=y6D12LrvrsMwaveQn5C4Em3RyeS6mP6E9fRpq7gqS4o,1546
|
|
33
|
-
fluidattacks_core/logging/filters.py,sha256=
|
|
33
|
+
fluidattacks_core/logging/filters.py,sha256=jEJkrvFeoQxCJ9vI8rd4N1FWXTbPdiTlv-7kriB8dQ0,725
|
|
34
34
|
fluidattacks_core/logging/formatters.py,sha256=SCA4k9XvHJknmkTv63uiCBU31VrWOsgA7llEXYYj1uQ,6063
|
|
35
|
-
fluidattacks_core/logging/handlers.py,sha256=
|
|
35
|
+
fluidattacks_core/logging/handlers.py,sha256=X-brVAc-QOqSFiEKqbBmxirkLLAaZDi5ID6cYzKdoHg,5028
|
|
36
36
|
fluidattacks_core/logging/presets.py,sha256=KU6d6PI61kklJ_o7NgAzU1DahEPM0KwwjTYHo2naHv8,939
|
|
37
37
|
fluidattacks_core/logging/utils.py,sha256=jbAcwr0L6iPsId3dYEp-vAbtFex2UUU2l2iIk1F60BE,1115
|
|
38
38
|
fluidattacks_core/logging/sources/__init__.py,sha256=bUOsNhmBq9WHLvPxCW3G0Az4D8Wunp0mCCqEYlCsjsI,5937
|
|
@@ -44,7 +44,7 @@ fluidattacks_core/semver/match_versions.py,sha256=10Vc3aS5Q2WVeM6UYUNiAo8C4E7zFT
|
|
|
44
44
|
fluidattacks_core/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
45
|
fluidattacks_core/serializers/snippet.py,sha256=e520pZHC-fsNuYVNY30A7TcSugvUlFL6xdr74j5aCDM,12780
|
|
46
46
|
fluidattacks_core/serializers/syntax.py,sha256=eSpoAmWLaVbd8tQ8ghHIvjJlCtieEf_IimonqLpIe3Y,16020
|
|
47
|
-
fluidattacks_core-5.0.
|
|
48
|
-
fluidattacks_core-5.0.
|
|
49
|
-
fluidattacks_core-5.0.
|
|
50
|
-
fluidattacks_core-5.0.
|
|
47
|
+
fluidattacks_core-5.1.0.dist-info/METADATA,sha256=atsMg03afFaIl0BmNom7s3Oecao6wEV7x00__o91GKc,3453
|
|
48
|
+
fluidattacks_core-5.1.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
49
|
+
fluidattacks_core-5.1.0.dist-info/top_level.txt,sha256=m49ZyZ2zPQmDBxkSpjb20wr-ZbGVXdOMFBZrDiP5Lb8,18
|
|
50
|
+
fluidattacks_core-5.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|