Skip to content

Commit b920b92

Browse files
committed
wrap in main block
1 parent 96a89f3 commit b920b92

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

codeflash/lsp/server_entry.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,48 @@
1-
"""
2-
This script is the dedicated entry point for the Codeflash Language Server.
1+
"""This script is the dedicated entry point for the Codeflash Language Server.
32
It initializes the server and redirects its logs to stderr so that the
43
VS Code client can display them in the output channel.
54
65
This script is run by the VS Code extension and is not intended to be
76
executed directly by users.
87
"""
8+
99
import logging
1010
import sys
11-
import os
11+
1212
from codeflash.lsp.beta import server
1313

14+
1415
# Configure logging to stderr for VS Code output channel
1516
def setup_logging():
1617
# Clear any existing handlers to prevent conflicts
1718
root_logger = logging.getLogger()
1819
root_logger.handlers.clear()
19-
20+
2021
# Set up stderr handler for VS Code output channel with [LSP-Server] prefix
2122
handler = logging.StreamHandler(sys.stderr)
2223
handler.setFormatter(logging.Formatter("[LSP-Server] %(asctime)s [%(levelname)s]: %(message)s"))
23-
24+
2425
# Configure root logger
2526
root_logger.addHandler(handler)
2627
root_logger.setLevel(logging.INFO)
27-
28+
2829
# Also configure the pygls logger specifically
29-
pygls_logger = logging.getLogger('pygls')
30+
pygls_logger = logging.getLogger("pygls")
3031
pygls_logger.setLevel(logging.INFO)
31-
32+
3233
return root_logger
3334

34-
# Set up logging
35-
log = setup_logging()
3635

37-
# Silence the console module to prevent stdout pollution
38-
from codeflash.cli_cmds.console import console
39-
console.quiet = True
36+
if __name__ == "__main__":
37+
# Set up logging
38+
log = setup_logging()
39+
log.info("Starting Codeflash Language Server...")
40+
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()
4046

41-
log.info("Starting Codeflash Language Server...")
42-
server.start_io()
47+
# Start the language server
48+
server.start_io()

0 commit comments

Comments
 (0)