Skip to content

Commit 7901e2d

Browse files
committed
feat: add centralized logging to all modules; fix import formatting; correct datefmt typo
1 parent c07a6e9 commit 7901e2d

6 files changed

Lines changed: 60 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
A production-ready Python library for data cleaning, anomaly detection, report generation, and SQL query analysis. Built on **pandas** and **numpy**, it provides typed, well-documented APIs suitable for pipelines, notebooks, and automated reporting workflows.
66

7+
> ⚠️ **Limitation:** `QueryOptimizer` performs static heuristic analysis using regex patterns. It does not parse SQL with a full AST engine. Complex queries (nested CTEs, window functions, or dialect-specific syntax) may produce incomplete results. For production-grade SQL parsing, consider [sqlglot](https://github.com/tobymao/sqlglot).
8+
79
## Features
810

911
| Module | Class | Purpose |

‎src/_logging.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Centralized logging configuration for the toolkit."""
2+
3+
import logging as lg
4+
5+
6+
def configure_logging(level: int = lg.INFO) -> None:
7+
"""Configure basic logging with a specified level.
8+
9+
Parameters:
10+
-----------
11+
Level : int
12+
Logging level (default: INFO).
13+
"""
14+
lg.basicConfig(
15+
level=level,
16+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
17+
datefmt="%Y-%m-%d %H:%M:%S",
18+
)

‎src/anomaly_detector.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
from __future__ import annotations
44

5+
import logging as lg
6+
7+
from src._logging import configure_logging
8+
9+
configure_logging()
10+
_logger = lg.getLogger(__name__)
11+
12+
513
from typing import Literal
614

715
import numpy as np

‎src/data_cleaner.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
from __future__ import annotations
44

5+
import logging as lg
6+
7+
from src._logging import configure_logging
8+
9+
configure_logging()
10+
_logger = lg.getLogger(__name__)
11+
512
from typing import Any, Literal
613

714
import numpy as np
@@ -34,6 +41,11 @@ class DataCleaner:
3441
"""
3542

3643
def __init__(self, df: pd.DataFrame) -> None:
44+
_logger.debug(
45+
"Initializing DataCleaner with %d rows, %d columns",
46+
len(df),
47+
len(df.columns),
48+
)
3749
if not isinstance(df, pd.DataFrame):
3850
raise DataCleanerError(
3951
f"Expected pandas DataFrame, got {type(df).__name__}."
@@ -119,6 +131,12 @@ def handle_missing_values(
119131
else:
120132
self._df[col] = self._df[col].fillna(mode_vals.iloc[0])
121133

134+
_logger.info(
135+
"handle_missing_values: strategy=%s, columns=%s, rows=%d",
136+
strategy,
137+
columns,
138+
len(self._df),
139+
)
122140
return self.data
123141

124142
def remove_duplicates(

‎src/query_optimizer.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
"""SQL query analysis and optimization utilities."""
2-
32
from __future__ import annotations
43

4+
import logging as lg
5+
6+
from src._logging import configure_logging
7+
8+
configure_logging()
9+
_logger = lg.getLogger(__name__)
10+
511
import re
612
from dataclasses import dataclass, field
713

‎src/report_generator.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
from __future__ import annotations
44

5+
import logging as lg
6+
7+
from src._logging import configure_logging
8+
9+
configure_logging()
10+
_logger = lg.getLogger(__name__)
11+
512
from datetime import datetime, timezone
613
from pathlib import Path
714
from typing import Any, Literal

0 commit comments

Comments
 (0)