Skip to content

Commit e242c86

Browse files
set the console.quiet in the __init__
1 parent 67a9e79 commit e242c86

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

codeflash/lsp/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Silence the console module to prevent stdout pollution
2+
from codeflash.cli_cmds.console import console
3+
4+
console.quiet = True

codeflash/lsp/server.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pathlib import Path
44
from typing import TYPE_CHECKING, Any
55

6-
from lsprotocol.types import INITIALIZE, MessageType, LogMessageParams
6+
from lsprotocol.types import INITIALIZE, LogMessageParams, MessageType
77
from pygls import uris
88
from pygls.protocol import LanguageServerProtocol, lsp_method
99
from pygls.server import LanguageServer
@@ -58,21 +58,22 @@ def initialize_optimizer(self, config_file: Path) -> None:
5858

5959
def show_message_log(self, message: str, message_type: str) -> None:
6060
"""Send a log message to the client's output channel.
61-
61+
6262
Args:
6363
message: The message to log
6464
message_type: String type - "Info", "Warning", "Error", or "Log"
65+
6566
"""
6667
# Convert string message type to LSP MessageType enum
6768
type_mapping = {
6869
"Info": MessageType.Info,
69-
"Warning": MessageType.Warning,
70+
"Warning": MessageType.Warning,
7071
"Error": MessageType.Error,
71-
"Log": MessageType.Log
72+
"Log": MessageType.Log,
7273
}
73-
74+
7475
lsp_message_type = type_mapping.get(message_type, MessageType.Info)
75-
76+
7677
# Send log message to client (appears in output channel)
7778
log_params = LogMessageParams(type=lsp_message_type, message=message)
7879
self.lsp.notify("window/logMessage", log_params)

codeflash/lsp/server_entry.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
"""This script is the dedicated entry point for the Codeflash Language Server.
2-
It initializes the server and redirects its logs to stderr so that the
3-
VS Code client can display them in the output channel.
1+
# This script is the dedicated entry point for the Codeflash Language Server.
2+
# It initializes the server and redirects its logs to stderr so that the
3+
# VS Code client can display them in the output channel.
44

5-
This script is run by the VS Code extension and is not intended to be
6-
executed directly by users.
7-
"""
5+
# This script is run by the VS Code extension and is not intended to be
6+
# executed directly by users.
87

98
import logging
109
import sys
@@ -13,7 +12,7 @@
1312

1413

1514
# Configure logging to stderr for VS Code output channel
16-
def setup_logging():
15+
def setup_logging() -> logging.Logger:
1716
# Clear any existing handlers to prevent conflicts
1817
root_logger = logging.getLogger()
1918
root_logger.handlers.clear()
@@ -38,11 +37,5 @@ def setup_logging():
3837
log = setup_logging()
3938
log.info("Starting Codeflash Language Server...")
4039

41-
# Silence the console module to prevent stdout pollution
42-
from codeflash.cli_cmds.console import console
43-
44-
console.quiet = True
45-
# console.enable()
46-
4740
# Start the language server
4841
server.start_io()

0 commit comments

Comments
 (0)