Skip to content

Commit 90ede69

Browse files
committed
testing logs
1 parent 73ec1ac commit 90ede69

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

api/src/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#
1616
# This files allows to add extra application decorators aside from the generated code.
1717
# The app created here is intended to replace the generated feeds_gen.main:app variable.
18+
import logging
1819
import os
1920

2021
import uvicorn
@@ -58,7 +59,9 @@
5859

5960
@app.on_event("startup")
6061
async def startup_event():
62+
print("print: TEST_LOG_FROM_MAIN_PY_INIT_QA_PROD")
6163
global_logging_setup()
64+
logging.critical("TEST_LOG_FROM_MAIN_PY_INIT_QA_PROD")
6265

6366

6467
if __name__ == "__main__":

api/src/middleware/request_context_middleware.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class RequestContextMiddleware:
1212

1313
def __init__(self, app: ASGIApp) -> None:
1414
self.logger = get_logger(API_ACCESS_LOG)
15+
self.logger.critical("MIDDLEWARE_INIT_TEST_QA_PROD")
1516
self.app = app
1617

1718
@staticmethod
@@ -60,6 +61,10 @@ def log_api_access(
6061
"""
6162
Log the API access logs.
6263
"""
64+
self.logger.critical(
65+
f"MIDDLEWARE_USER_ID_CHECK_QA_PROD_CRITICAL: "
66+
f"{request_context.user_id if request_context.user_id else 'USER_ID_IS_EMPTY_OR_NONE'}"
67+
)
6368
latency = time.time() - start_time
6469
request = self.create_http_request(scope, request_context, status_code, content_length, latency)
6570
headers = {k.decode().lower(): v.decode() for k, v in scope.get("headers", [])}

api/src/utils/logger.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,20 @@ def is_local_env():
116116

117117

118118
def global_logging_setup():
119+
logging.critical("Starting cloud up logging")
119120
if is_local_env():
121+
logging.critical("Setting local up logging")
120122
logging.basicConfig(level=get_env_logging_level())
121123
return
122-
124+
logging.critical("Setting cloud up logging")
123125
# Send warnings through logging
124126
logging.captureWarnings(True)
125127
# Replace sys.stderr
126128
sys.stderr = StderrToLog(logging.getLogger("stderr"))
127129
try:
128130
client = google.cloud.logging.Client()
129131
handler = CloudLoggingHandler(client, structured=True)
130-
handler.setLevel(get_env_logging_level())
132+
handler.setLevel(logging.DEBUG)
131133
handler.addFilter(GoogleCloudLogFilter(project=client.project))
132134
except Exception as e:
133135
logging.error("Error initializing cloud logging: %s", e)
@@ -136,7 +138,7 @@ def global_logging_setup():
136138

137139
# Configure root logger
138140
root_logger = logging.getLogger()
139-
root_logger.setLevel(get_env_logging_level())
141+
root_logger.setLevel(logging.DEBUG)
140142
root_logger.handlers.clear()
141143
root_logger.addHandler(handler)
142144

0 commit comments

Comments
 (0)