Skip to content

Commit

Permalink
Merge pull request #478 from stacklok/quiten-logs
Browse files Browse the repository at this point in the history
Logs are to verbose and make it a challenge to follow
  • Loading branch information
yrobla authored Jan 2, 2025
2 parents f6e2937 + d78c8a9 commit 997c8ae
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/codegate/codegate_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def setup_logging(
# Set explicitly the log level for other modules
logging.getLogger("sqlalchemy").disabled = True
logging.getLogger("uvicorn.error").disabled = True
logging.getLogger("aiosqlite").disabled = True

# Create a logger for our package
logger = structlog.get_logger("codegate")
Expand Down
7 changes: 4 additions & 3 deletions src/codegate/db/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ async def record_outputs(self, outputs: List[Output]) -> Optional[Output]:
"""
)
recorded_output = await self._insert_pydantic_model(output_db, sql)
logger.debug(f"Recorded output: {recorded_output}")
# Uncomment to debug
# logger.debug(f"Recorded output: {recorded_output}")
return recorded_output

async def record_alerts(self, alerts: List[Alert]) -> List[Alert]:
Expand Down Expand Up @@ -177,8 +178,8 @@ async def record_alerts(self, alerts: List[Alert]) -> List[Alert]:
recorded_alerts.append(alert_result)
if alert_result and alert_result.trigger_category == "critical":
await alert_queue.put(f"New alert detected: {alert.timestamp}")

logger.debug(f"Recorded alerts: {recorded_alerts}")
# Uncomment to debug the recorded alerts
# logger.debug(f"Recorded alerts: {recorded_alerts}")
return recorded_alerts

def _should_record_context(self, context: Optional[PipelineContext]) -> bool:
Expand Down
6 changes: 4 additions & 2 deletions src/codegate/pipeline/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def add_alert(
timestamp=datetime.datetime.now(datetime.timezone.utc),
)
)
logger.debug(f"Added alert to context: {self.alerts_raised[-1]}")
# Uncomment the below to debug
# logger.debug(f"Added alert to context: {self.alerts_raised[-1]}")

def add_input_request(
self, normalized_request: ChatCompletionRequest, is_fim_request: bool, provider: str
Expand Down Expand Up @@ -159,7 +160,8 @@ def add_output(self, model_response: ModelResponse) -> None:
output=output_str,
)
)
logger.debug(f"Added output to context: {self.output_responses[-1]}")
# Uncomment the below to debug the responses
# logger.debug(f"Added output to context: {self.output_responses[-1]}")
except Exception as e:
logger.error(f"Failed to serialize output: {model_response}", error=str(e))
return
Expand Down
17 changes: 9 additions & 8 deletions src/codegate/storage/storage_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,15 @@ async def search(

# Log the raw SQL results
rows = cursor.fetchall()
logger.debug(
"Raw SQL results",
row_count=len(rows),
rows=[
{"name": row[0], "type": row[1], "status": row[2], "description": row[3]}
for row in rows
],
)
# Uncomment the following lines to log
# logger.debug(
# "Raw SQL results",
# row_count=len(rows),
# rows=[
# {"name": row[0], "type": row[1], "status": row[2], "description": row[3]}
# for row in rows
# ],
# )

results = []
query_words = None
Expand Down

0 comments on commit 997c8ae

Please sign in to comment.