Skip to content

Commit cc9807a

Browse files
committed
adjust logs info
1 parent 655084a commit cc9807a

8 files changed

Lines changed: 63 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ CodeWiki demonstrates significant improvements in high-level and managed languag
9797
Install CodeWiki CLI from source:
9898

9999
```bash
100-
pip install https://github.com/FSoft-AI4Code/CodeWiki.git
100+
pip install git+https://github.com/FSoft-AI4Code/CodeWiki.git
101101
```
102102

103103
Verify installation:

codewiki/cli/adapters/doc_generator.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import time
1111
import asyncio
1212
import os
13+
import logging
14+
import sys
1315

1416

1517
from codewiki.cli.utils.progress import ProgressTracker
@@ -64,6 +66,51 @@ def __init__(
6466
cluster_model=config.get('cluster_model', ''),
6567
base_url=config.get('base_url', '')
6668
)
69+
70+
# Configure backend logging
71+
self._configure_backend_logging()
72+
73+
def _configure_backend_logging(self):
74+
"""Configure backend logger for CLI use."""
75+
# Get backend logger (parent of all backend modules)
76+
backend_logger = logging.getLogger('codewiki.src.be')
77+
78+
# Remove existing handlers to avoid duplicates
79+
backend_logger.handlers.clear()
80+
81+
if self.verbose:
82+
# In verbose mode, show DEBUG and above
83+
backend_logger.setLevel(logging.DEBUG)
84+
85+
# Create console handler with formatting
86+
console_handler = logging.StreamHandler(sys.stdout)
87+
console_handler.setLevel(logging.DEBUG)
88+
89+
# Create formatter with timestamp and minimal formatting for cleaner output
90+
formatter = logging.Formatter(
91+
'[%(asctime)s] %(message)s',
92+
datefmt='%H:%M:%S'
93+
)
94+
console_handler.setFormatter(formatter)
95+
96+
# Add handler to logger
97+
backend_logger.addHandler(console_handler)
98+
else:
99+
# In non-verbose mode, suppress backend logs (use WARNING level to hide INFO/DEBUG)
100+
backend_logger.setLevel(logging.WARNING)
101+
102+
# Create console handler for warnings and errors only
103+
console_handler = logging.StreamHandler(sys.stderr)
104+
console_handler.setLevel(logging.WARNING)
105+
106+
# Simple formatter for warnings/errors
107+
formatter = logging.Formatter('%(levelname)s: %(message)s')
108+
console_handler.setFormatter(formatter)
109+
110+
backend_logger.addHandler(console_handler)
111+
112+
# Prevent propagation to root logger to avoid duplicate messages
113+
backend_logger.propagate = False
67114

68115
def generate(self) -> DocumentationJob:
69116
"""

codewiki/src/be/agent_orchestrator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import Dict, List, Any
66

77
# Configure logging and monitoring
8-
logging.basicConfig(level=logging.INFO)
8+
99
logger = logging.getLogger(__name__)
1010

1111
# try:

codewiki/src/be/agent_tools/generate_sub_module_documentations.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
from codewiki.src.be.cluster_modules import format_potential_core_components
1010
from codewiki.src.config import MAX_TOKEN_PER_LEAF_MODULE
1111

12+
import logging
13+
logger = logging.getLogger(__name__)
14+
1215

1316

1417
async def generate_sub_module_documentation(
@@ -36,6 +39,10 @@ async def generate_sub_module_documentation(
3639

3740
for sub_module_name, core_component_ids in sub_module_specs.items():
3841

42+
tabs = " " * deps.current_depth
43+
44+
logger.info(f"{tabs}Generating documentation for sub-module: {sub_module_name}")
45+
3946
num_tokens = count_tokens(format_potential_core_components(core_component_ids, ctx.deps.components)[-1])
4047

4148
if is_complex_module(ctx.deps.components, core_component_ids) and ctx.deps.current_depth < ctx.deps.max_depth and num_tokens >= MAX_TOKEN_PER_LEAF_MODULE:

codewiki/src/be/agent_tools/str_replace_editor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import logging
1717

1818
# Configure logging and monitoring
19-
logging.basicConfig(level=logging.INFO)
19+
2020
logger = logging.getLogger(__name__)
2121

2222
from pydantic_ai import RunContext, Tool

codewiki/src/be/documentation_generator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import traceback
77

88
# Configure logging and monitoring
9-
logging.basicConfig(level=logging.INFO)
109
logger = logging.getLogger(__name__)
1110

1211
# Local imports
@@ -70,7 +69,7 @@ def create_documentation_metadata(self, working_dir: str, components: Dict[str,
7069

7170
metadata_path = os.path.join(working_dir, "metadata.json")
7271
file_manager.save_json(metadata, metadata_path)
73-
logger.debug(f"Documentation metadata saved to: {metadata_path}")
72+
# logger.debug(f"Documentation metadata saved to: {metadata_path}")
7473

7574
def get_processing_order(self, module_tree: Dict[str, Any], parent_path: List[str] = []) -> List[tuple[List[str], str]]:
7675
"""Get the processing order using topological sort (leaf modules first)."""
@@ -135,7 +134,7 @@ async def generate_module_documentation(self, components: Dict[str, Any], leaf_n
135134

136135
# Get processing order (leaf modules first)
137136
processing_order = self.get_processing_order(first_module_tree)
138-
logger.debug(f"Processing {len(processing_order)} modules in dependency order:\n{processing_order}")
137+
# logger.debug(f"Processing {len(processing_order)} modules in dependency order:\n{processing_order}")
139138

140139
# Process modules in dependency order
141140
final_module_tree = module_tree

codewiki/src/be/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import asyncio
1414

1515
# Configure logging and monitoring
16-
logging.basicConfig(level=logging.INFO)
16+
1717
logger = logging.getLogger(__name__)
1818

1919
# Local imports

codewiki/src/be/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import logging
55
import tiktoken
66

7-
logging.basicConfig(level=logging.INFO)
7+
88
logger = logging.getLogger(__name__)
99

1010
# ------------------------------------------------------------
@@ -143,7 +143,7 @@ async def validate_single_diagram(diagram_content: str, diagram_num: int, line_s
143143

144144
try:
145145
from mermaid_parser.parser import parse_mermaid_py
146-
logger.debug("Using mermaid-parser-py to validate mermaid diagrams")
146+
# logger.debug("Using mermaid-parser-py to validate mermaid diagrams")
147147

148148
try:
149149
# Redirect stderr to suppress mermaid parser JavaScript errors
@@ -172,7 +172,7 @@ async def validate_single_diagram(diagram_content: str, diagram_num: int, line_s
172172
raise Exception(error_str)
173173

174174
except Exception as e:
175-
logger.debug("Using mermaid-py to validate mermaid diagrams")
175+
logger.warning("Using mermaid-py to validate mermaid diagrams")
176176
try:
177177
import mermaid as md
178178
# Create Mermaid object and check response

0 commit comments

Comments
 (0)