refactor: 🔊 replace all print with logger.debug
This commit is contained in:
parent
7894c8ed15
commit
99ece78c86
17 changed files with 123 additions and 100 deletions
|
|
@ -21,6 +21,7 @@ from ..libs.util.traceback_parsers import get_python_traceback, get_javascript_t
|
|||
from openai import error as openai_errors
|
||||
from ..libs.util.create_async_task import create_async_task
|
||||
from ..libs.util.telemetry import posthog_logger
|
||||
from ..libs.util.logging import logger
|
||||
|
||||
|
||||
def get_error_title(e: Exception) -> str:
|
||||
|
|
@ -153,7 +154,7 @@ class Autopilot(ContinueBaseModel):
|
|||
|
||||
await self.update_subscribers()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logger.debug(e)
|
||||
|
||||
def handle_manual_edits(self, edits: List[FileEditWithFullContents]):
|
||||
for edit in edits:
|
||||
|
|
@ -258,7 +259,7 @@ class Autopilot(ContinueBaseModel):
|
|||
e)
|
||||
|
||||
# Attach an InternalErrorObservation to the step and unhide it.
|
||||
print(
|
||||
logger.error(
|
||||
f"Error while running step: \n{error_string}\n{error_title}")
|
||||
posthog_logger.capture_event('step error', {
|
||||
'error_message': error_string, 'error_title': error_title, 'step_name': step.name, 'params': step.dict()})
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from pydantic import BaseModel
|
|||
|
||||
from .main import ChatMessage, ContextItem, ContextItemDescription, ContextItemId
|
||||
from ..server.meilisearch_server import check_meilisearch_running
|
||||
|
||||
from ..libs.util.logging import logger
|
||||
|
||||
SEARCH_INDEX_NAME = "continue_context_items"
|
||||
|
||||
|
|
@ -57,16 +57,22 @@ class ContextProvider(BaseModel):
|
|||
Default implementation uses the search index to get the item.
|
||||
"""
|
||||
async with Client('http://localhost:7700') as search_client:
|
||||
result = await search_client.index(
|
||||
SEARCH_INDEX_NAME).get_document(id.to_string())
|
||||
return ContextItem(
|
||||
description=ContextItemDescription(
|
||||
name=result["name"],
|
||||
description=result["description"],
|
||||
id=id
|
||||
),
|
||||
content=result["content"]
|
||||
)
|
||||
try:
|
||||
result = await search_client.index(
|
||||
SEARCH_INDEX_NAME).get_document(id.to_string())
|
||||
return ContextItem(
|
||||
description=ContextItemDescription(
|
||||
name=result["name"],
|
||||
description=result["description"],
|
||||
id=id
|
||||
),
|
||||
content=result["content"]
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"Error while retrieving document from meilisearch: {e}")
|
||||
|
||||
return None
|
||||
|
||||
async def delete_context_with_ids(self, ids: List[ContextItemId]):
|
||||
"""
|
||||
|
|
@ -100,8 +106,8 @@ class ContextProvider(BaseModel):
|
|||
if item.description.id.item_id == id.item_id:
|
||||
return
|
||||
|
||||
new_item = await self.get_item(id, query)
|
||||
self.selected_items.append(new_item)
|
||||
if new_item := await self.get_item(id, query):
|
||||
self.selected_items.append(new_item)
|
||||
|
||||
|
||||
class ContextManager:
|
||||
|
|
@ -146,7 +152,7 @@ class ContextManager:
|
|||
meilisearch_running = False
|
||||
|
||||
if not meilisearch_running:
|
||||
print(
|
||||
logger.warning(
|
||||
"MeiliSearch not running, avoiding any dependent context providers")
|
||||
context_providers = list(
|
||||
filter(lambda cp: cp.title == "code", context_providers))
|
||||
|
|
@ -170,7 +176,7 @@ class ContextManager:
|
|||
async with Client('http://localhost:7700') as search_client:
|
||||
await search_client.index(SEARCH_INDEX_NAME).add_documents(documents)
|
||||
except Exception as e:
|
||||
print("Error loading meilisearch index: ", e)
|
||||
logger.debug(f"Error loading meilisearch index: {e}")
|
||||
|
||||
# def compile_chat_messages(self, max_tokens: int) -> List[Dict]:
|
||||
# """
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ from ..plugins.steps.core.core import *
|
|||
from ..libs.llm.proxy_server import ProxyServer
|
||||
from ..libs.util.telemetry import posthog_logger
|
||||
from ..libs.util.paths import getConfigFilePath
|
||||
from ..libs.util.logging import logger
|
||||
|
||||
|
||||
class Autopilot:
|
||||
|
|
@ -161,7 +162,7 @@ class ContinueSDK(AbstractContinueSDK):
|
|||
config = sdk._load_config_dot_py()
|
||||
sdk.config = config
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logger.debug(e)
|
||||
sdk.config = ContinueConfig()
|
||||
msg_step = MessageStep(
|
||||
name="Invalid Continue Config File", message=e.__repr__())
|
||||
|
|
@ -273,7 +274,7 @@ class ContinueSDK(AbstractContinueSDK):
|
|||
|
||||
return config.config
|
||||
except Exception as e:
|
||||
print("Error loading config.py: ", e)
|
||||
logger.debug(f"Error loading config.py: {e}")
|
||||
return ContinueConfig() if self._last_valid_config is None else self._last_valid_config
|
||||
|
||||
def get_code_context(self, only_editing: bool = False) -> List[RangeInFileWithContents]:
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from llama_index import GPTVectorStoreIndex, StorageContext, load_index_from_sto
|
|||
from llama_index.langchain_helpers.text_splitter import TokenTextSplitter
|
||||
import os
|
||||
from .update import filter_ignored_files, load_gpt_index_documents
|
||||
from ..util.logging import logger
|
||||
from functools import cached_property
|
||||
|
||||
|
||||
|
|
@ -56,7 +57,8 @@ class ChromaIndexManager:
|
|||
try:
|
||||
text_chunks = text_splitter.split_text(doc.text)
|
||||
except:
|
||||
print("ERROR (probably found special token): ", doc.text)
|
||||
logger.warning(
|
||||
f"ERROR (probably found special token): {doc.text}")
|
||||
continue
|
||||
filename = doc.extra_info["filename"]
|
||||
chunks[filename] = len(text_chunks)
|
||||
|
|
@ -79,7 +81,7 @@ class ChromaIndexManager:
|
|||
|
||||
index.storage_context.persist(persist_dir=self.index_dir)
|
||||
|
||||
print("Codebase index created")
|
||||
logger.debug("Codebase index created")
|
||||
|
||||
def get_modified_deleted_files(self) -> Tuple[List[str], List[str]]:
|
||||
"""Get a list of all files that have been modified since the last commit."""
|
||||
|
|
@ -121,7 +123,7 @@ class ChromaIndexManager:
|
|||
|
||||
del metadata["chunks"][file]
|
||||
|
||||
print(f"Deleted {file}")
|
||||
logger.debug(f"Deleted {file}")
|
||||
|
||||
for file in modified_files:
|
||||
|
||||
|
|
@ -132,7 +134,7 @@ class ChromaIndexManager:
|
|||
for i in range(num_chunks):
|
||||
index.delete(f"{file}::{i}")
|
||||
|
||||
print(f"Deleted old version of {file}")
|
||||
logger.debug(f"Deleted old version of {file}")
|
||||
|
||||
with open(file, "r") as f:
|
||||
text = f.read()
|
||||
|
|
@ -145,19 +147,20 @@ class ChromaIndexManager:
|
|||
|
||||
metadata["chunks"][file] = len(text_chunks)
|
||||
|
||||
print(f"Inserted new version of {file}")
|
||||
logger.debug(f"Inserted new version of {file}")
|
||||
|
||||
metadata["commit"] = self.current_commit
|
||||
|
||||
with open(f"{self.index_dir}/metadata.json", "w") as f:
|
||||
json.dump(metadata, f, indent=4)
|
||||
|
||||
print("Codebase index updated")
|
||||
logger.debug("Codebase index updated")
|
||||
|
||||
def query_codebase_index(self, query: str) -> str:
|
||||
"""Query the codebase index."""
|
||||
if not self.check_index_exists():
|
||||
print("No index found for the codebase at ", self.index_dir)
|
||||
logger.debug(
|
||||
f"No index found for the codebase at {self.index_dir}")
|
||||
return ""
|
||||
|
||||
storage_context = StorageContext.from_defaults(
|
||||
|
|
@ -180,4 +183,4 @@ class ChromaIndexManager:
|
|||
documents = [Document(info)]
|
||||
index = GPTVectorStoreIndex(documents)
|
||||
index.save_to_disk(f'{self.index_dir}/additional_index.json')
|
||||
print("Additional index replaced")
|
||||
logger.debug("Additional index replaced")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from typing import Coroutine, Union
|
||||
import traceback
|
||||
from .telemetry import posthog_logger
|
||||
from .logging import logger
|
||||
import asyncio
|
||||
import nest_asyncio
|
||||
nest_asyncio.apply()
|
||||
|
|
@ -14,8 +15,9 @@ def create_async_task(coro: Coroutine, unique_id: Union[str, None] = None):
|
|||
try:
|
||||
future.result()
|
||||
except Exception as e:
|
||||
print("Exception caught from async task: ",
|
||||
'\n'.join(traceback.format_exception(e)))
|
||||
formatted_tb = '\n'.join(traceback.format_exception(e))
|
||||
logger.critical(
|
||||
f"Exception caught from async task: {formatted_tb}")
|
||||
posthog_logger.capture_event("async_task_error", {
|
||||
"error_title": e.__str__() or e.__repr__(), "error_message": '\n'.join(traceback.format_exception(e))
|
||||
})
|
||||
|
|
|
|||
30
continuedev/src/continuedev/libs/util/logging.py
Normal file
30
continuedev/src/continuedev/libs/util/logging.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import logging
|
||||
|
||||
from .paths import getLogFilePath
|
||||
|
||||
# Create a logger
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
# Create a file handler
|
||||
file_handler = logging.FileHandler(getLogFilePath())
|
||||
file_handler.setLevel(logging.DEBUG)
|
||||
|
||||
# Create a console handler
|
||||
console_handler = logging.StreamHandler()
|
||||
console_handler.setLevel(logging.DEBUG)
|
||||
|
||||
# Create a formatter
|
||||
formatter = logging.Formatter(
|
||||
'[%(asctime)s] [%(levelname)s] %(message)s')
|
||||
|
||||
# Add the formatter to the handlers
|
||||
file_handler.setFormatter(formatter)
|
||||
console_handler.setFormatter(formatter)
|
||||
|
||||
# Add the handlers to the logger
|
||||
logger.addHandler(file_handler)
|
||||
logger.addHandler(console_handler)
|
||||
|
||||
# Log a test message
|
||||
logger.debug('Testing logs')
|
||||
|
|
@ -14,6 +14,7 @@ from ...plugins.steps.on_traceback import DefaultOnTracebackStep
|
|||
from ...plugins.steps.clear_history import ClearHistoryStep
|
||||
from ...plugins.steps.open_config import OpenConfigStep
|
||||
from ...plugins.steps.help import HelpStep
|
||||
from ...libs.util.logging import logger
|
||||
|
||||
# This mapping is used to convert from string in ContinueConfig json to corresponding Step class.
|
||||
# Used for example in slash_commands and steps_on_startup
|
||||
|
|
@ -38,6 +39,6 @@ def get_step_from_name(step_name: str, params: Dict) -> Step:
|
|||
try:
|
||||
return step_name_to_step_class[step_name](**params)
|
||||
except:
|
||||
print(
|
||||
logger.error(
|
||||
f"Incorrect parameters for step {step_name}. Parameters provided were: {params}")
|
||||
raise
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from posthog import Posthog
|
|||
import os
|
||||
from dotenv import load_dotenv
|
||||
from .commonregex import clean_pii_from_any
|
||||
from .logging import logger
|
||||
|
||||
load_dotenv()
|
||||
in_codespaces = os.getenv("CODESPACES") == "true"
|
||||
|
|
@ -24,7 +25,8 @@ class PostHogLogger:
|
|||
self.allow_anonymous_telemetry = allow_anonymous_telemetry or True
|
||||
|
||||
def capture_event(self, event_name: str, event_properties: Any):
|
||||
print("------- Logging event -------")
|
||||
# logger.debug(
|
||||
# f"Logging to PostHog: {event_name} ({self.unique_id}, {self.allow_anonymous_telemetry}): {event_properties}")
|
||||
telemetry_path = os.path.expanduser("~/.continue/telemetry.log")
|
||||
|
||||
# Make sure the telemetry file exists
|
||||
|
|
@ -46,7 +48,5 @@ class PostHogLogger:
|
|||
self.posthog.capture(self.unique_id, event_name,
|
||||
clean_pii_from_any(event_properties))
|
||||
|
||||
print("------- Event logged -------")
|
||||
|
||||
|
||||
posthog_logger = PostHogLogger(api_key=POSTHOG_API_KEY)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ def main():
|
|||
try:
|
||||
json = schema_json_of(model, indent=2, title=title)
|
||||
except Exception as e:
|
||||
print(f"Failed to generate json schema for {title}: ", e)
|
||||
print(f"Failed to generate json schema for {title}: {e}")
|
||||
continue
|
||||
|
||||
with open(f"{SCHEMA_DIR}/{title}.json", "w") as f:
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from ...core.sdk import ContinueSDK, Models
|
|||
from ...core.observation import Observation
|
||||
from .core.core import DefaultModelEditCodeStep
|
||||
from ...libs.util.calculate_diff import calculate_diff2
|
||||
from ...libs.util.logging import logger
|
||||
|
||||
|
||||
class Policy(BaseModel):
|
||||
|
|
@ -105,7 +106,7 @@ class FasterEditHighlightedCodeStep(Step):
|
|||
# Temporarily doing this to generate description.
|
||||
self._prompt = prompt
|
||||
self._completion = completion
|
||||
print(completion)
|
||||
logger.debug(completion)
|
||||
|
||||
# ALTERNATIVE DECODING STEP HERE
|
||||
raw_file_edits = []
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from .gui_protocol import AbstractGUIProtocolServer
|
|||
from ..libs.util.queue import AsyncSubscriptionQueue
|
||||
from ..libs.util.telemetry import posthog_logger
|
||||
from ..libs.util.create_async_task import create_async_task
|
||||
from ..libs.util.logging import logger
|
||||
|
||||
router = APIRouter(prefix="/gui", tags=["gui"])
|
||||
|
||||
|
|
@ -25,7 +26,7 @@ class AppStatus:
|
|||
@staticmethod
|
||||
def handle_exit(*args, **kwargs):
|
||||
AppStatus.should_exit = True
|
||||
print("Shutting down")
|
||||
logger.debug("Shutting down")
|
||||
original_handler(*args, **kwargs)
|
||||
|
||||
|
||||
|
|
@ -96,7 +97,7 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
|
|||
elif message_type == "select_context_item":
|
||||
self.select_context_item(data["id"], data["query"])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logger.debug(e)
|
||||
|
||||
def on_main_input(self, input: str):
|
||||
# Do something with user input
|
||||
|
|
@ -162,10 +163,10 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
|
|||
@router.websocket("/ws")
|
||||
async def websocket_endpoint(websocket: WebSocket, session: Session = Depends(websocket_session)):
|
||||
try:
|
||||
print("Received websocket connection at url: ", websocket.url)
|
||||
logger.debug(f"Received websocket connection at url: {websocket.url}")
|
||||
await websocket.accept()
|
||||
|
||||
print("Session started")
|
||||
logger.debug("Session started")
|
||||
session_manager.register_websocket(session.session_id, websocket)
|
||||
protocol = GUIProtocolServer(session)
|
||||
protocol.websocket = websocket
|
||||
|
|
@ -175,7 +176,7 @@ async def websocket_endpoint(websocket: WebSocket, session: Session = Depends(we
|
|||
|
||||
while AppStatus.should_exit is False:
|
||||
message = await websocket.receive_text()
|
||||
print("Received GUI message", message)
|
||||
logger.debug(f"Received GUI message {message}")
|
||||
if type(message) is str:
|
||||
message = json.loads(message)
|
||||
|
||||
|
|
@ -186,14 +187,14 @@ async def websocket_endpoint(websocket: WebSocket, session: Session = Depends(we
|
|||
|
||||
protocol.handle_json(message_type, data)
|
||||
except WebSocketDisconnect as e:
|
||||
print("GUI websocket disconnected")
|
||||
logger.debug("GUI websocket disconnected")
|
||||
except Exception as e:
|
||||
print("ERROR in gui websocket: ", e)
|
||||
logger.debug(f"ERROR in gui websocket: {e}")
|
||||
posthog_logger.capture_event("gui_error", {
|
||||
"error_title": e.__str__() or e.__repr__(), "error_message": '\n'.join(traceback.format_exception(e))})
|
||||
raise e
|
||||
finally:
|
||||
print("Closing gui websocket")
|
||||
logger.debug("Closing gui websocket")
|
||||
if websocket.client_state != WebSocketState.DISCONNECTED:
|
||||
await websocket.close()
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ from .gui import session_manager
|
|||
from .ide_protocol import AbstractIdeProtocolServer
|
||||
from ..libs.util.create_async_task import create_async_task
|
||||
from .session_manager import SessionManager
|
||||
from ..libs.util.logging import logger
|
||||
|
||||
import nest_asyncio
|
||||
nest_asyncio.apply()
|
||||
|
|
@ -37,7 +38,7 @@ class AppStatus:
|
|||
@staticmethod
|
||||
def handle_exit(*args, **kwargs):
|
||||
AppStatus.should_exit = True
|
||||
print("Shutting down")
|
||||
logger.debug("Shutting down")
|
||||
original_handler(*args, **kwargs)
|
||||
|
||||
|
||||
|
|
@ -140,7 +141,7 @@ class IdeProtocolServer(AbstractIdeProtocolServer):
|
|||
continue
|
||||
message_type = message["messageType"]
|
||||
data = message["data"]
|
||||
print("Received message while initializing", message_type)
|
||||
logger.debug(f"Received message while initializing {message_type}")
|
||||
if message_type == "workspaceDirectory":
|
||||
self.workspace_directory = data["workspaceDirectory"]
|
||||
elif message_type == "uniqueId":
|
||||
|
|
@ -154,9 +155,10 @@ class IdeProtocolServer(AbstractIdeProtocolServer):
|
|||
|
||||
async def _send_json(self, message_type: str, data: Any):
|
||||
if self.websocket.application_state == WebSocketState.DISCONNECTED:
|
||||
print("Tried to send message, but websocket is disconnected", message_type)
|
||||
logger.debug(
|
||||
f"Tried to send message, but websocket is disconnected: {message_type}")
|
||||
return
|
||||
print("Sending IDE message: ", message_type)
|
||||
logger.debug(f"Sending IDE message: {message_type}")
|
||||
await self.websocket.send_json({
|
||||
"messageType": message_type,
|
||||
"data": data
|
||||
|
|
@ -167,7 +169,7 @@ class IdeProtocolServer(AbstractIdeProtocolServer):
|
|||
return await asyncio.wait_for(self.sub_queue.get(message_type), timeout=timeout)
|
||||
except asyncio.TimeoutError:
|
||||
raise Exception(
|
||||
"IDE Protocol _receive_json timed out after 20 seconds", message_type)
|
||||
f"IDE Protocol _receive_json timed out after 20 seconds: {message_type}")
|
||||
|
||||
async def _send_and_receive_json(self, data: Any, resp_model: Type[T], message_type: str) -> T:
|
||||
await self._send_json(message_type, data)
|
||||
|
|
@ -354,7 +356,7 @@ class IdeProtocolServer(AbstractIdeProtocolServer):
|
|||
}, GetUserSecretResponse, "getUserSecret")
|
||||
return resp.value
|
||||
except Exception as e:
|
||||
print("Error getting user secret", e)
|
||||
logger.debug(f"Error getting user secret: {e}")
|
||||
return ""
|
||||
|
||||
async def saveFile(self, filepath: str):
|
||||
|
|
@ -437,15 +439,15 @@ class IdeProtocolServer(AbstractIdeProtocolServer):
|
|||
async def websocket_endpoint(websocket: WebSocket, session_id: str = None):
|
||||
try:
|
||||
await websocket.accept()
|
||||
print("Accepted websocket connection from, ", websocket.client)
|
||||
logger.debug(f"Accepted websocket connection from {websocket.client}")
|
||||
await websocket.send_json({"messageType": "connected", "data": {}})
|
||||
|
||||
# Start meilisearch
|
||||
try:
|
||||
await start_meilisearch()
|
||||
except Exception as e:
|
||||
print("Failed to start MeiliSearch")
|
||||
print(e)
|
||||
logger.debug("Failed to start MeiliSearch")
|
||||
logger.debug(e)
|
||||
|
||||
def handle_msg(msg):
|
||||
message = json.loads(msg)
|
||||
|
|
@ -455,7 +457,7 @@ async def websocket_endpoint(websocket: WebSocket, session_id: str = None):
|
|||
message_type = message["messageType"]
|
||||
data = message["data"]
|
||||
|
||||
print("Received IDE message: ", message_type)
|
||||
logger.debug(f"Received IDE message: {message_type}")
|
||||
create_async_task(
|
||||
ideProtocolServer.handle_json(message_type, data))
|
||||
|
||||
|
|
@ -473,16 +475,16 @@ async def websocket_endpoint(websocket: WebSocket, session_id: str = None):
|
|||
message = await websocket.receive_text()
|
||||
handle_msg(message)
|
||||
|
||||
print("Closing ide websocket")
|
||||
logger.debug("Closing ide websocket")
|
||||
except WebSocketDisconnect as e:
|
||||
print("IDE wbsocket disconnected")
|
||||
logger.debug("IDE wbsocket disconnected")
|
||||
except Exception as e:
|
||||
print("Error in ide websocket: ", e)
|
||||
logger.debug(f"Error in ide websocket: {e}")
|
||||
posthog_logger.capture_event("gui_error", {
|
||||
"error_title": e.__str__() or e.__repr__(), "error_message": '\n'.join(traceback.format_exception(e))})
|
||||
raise e
|
||||
finally:
|
||||
print("Closing ide websocket")
|
||||
logger.debug("Closing ide websocket")
|
||||
if websocket.client_state != WebSocketState.DISCONNECTED:
|
||||
await websocket.close()
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ from .ide import router as ide_router
|
|||
from .gui import router as gui_router
|
||||
from .session_manager import session_manager
|
||||
from ..libs.util.paths import getLogFilePath
|
||||
from ..libs.util.logging import logger
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
|
@ -33,7 +34,7 @@ app.add_middleware(
|
|||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
print("Health check")
|
||||
logger.debug("Health check")
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
|
|
@ -56,31 +57,6 @@ class Logger(object):
|
|||
return False
|
||||
|
||||
|
||||
def setup_logging():
|
||||
log_path = getLogFilePath()
|
||||
LOG_CONFIG = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'file': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': log_path,
|
||||
},
|
||||
},
|
||||
'root': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['file']
|
||||
}
|
||||
}
|
||||
|
||||
logger = Logger(log_path)
|
||||
print(f"Log path: {log_path}")
|
||||
# sys.stdout = logger
|
||||
# sys.stderr = logger
|
||||
print("Testing logs")
|
||||
|
||||
|
||||
try:
|
||||
# add cli arg for server port
|
||||
parser = argparse.ArgumentParser()
|
||||
|
|
@ -88,21 +64,19 @@ try:
|
|||
type=int, default=65432)
|
||||
args = parser.parse_args()
|
||||
except Exception as e:
|
||||
print("Error parsing command line arguments: ", e)
|
||||
logger.debug(f"Error parsing command line arguments: {e}")
|
||||
raise e
|
||||
|
||||
|
||||
def run_server():
|
||||
config = uvicorn.Config(app, host="0.0.0.0", port=args.port,
|
||||
# log_config=LOG_CONFIG
|
||||
)
|
||||
config = uvicorn.Config(app, host="0.0.0.0", port=args.port)
|
||||
server = uvicorn.Server(config)
|
||||
|
||||
server.run()
|
||||
|
||||
|
||||
async def cleanup_coroutine():
|
||||
print("Cleaning up sessions")
|
||||
logger.debug("Cleaning up sessions")
|
||||
for session_id in session_manager.sessions:
|
||||
await session_manager.persist_session(session_id)
|
||||
|
||||
|
|
@ -121,7 +95,7 @@ def cpu_usage_report():
|
|||
time.sleep(1)
|
||||
# Call cpu_percent again to get the CPU usage over the interval
|
||||
cpu_usage = process.cpu_percent(interval=None)
|
||||
print(f"CPU usage: {cpu_usage}%")
|
||||
logger.debug(f"CPU usage: {cpu_usage}%")
|
||||
|
||||
|
||||
atexit.register(cleanup)
|
||||
|
|
@ -139,9 +113,8 @@ if __name__ == "__main__":
|
|||
# cpu_thread = threading.Thread(target=cpu_usage_loop)
|
||||
# cpu_thread.start()
|
||||
|
||||
setup_logging()
|
||||
run_server()
|
||||
except Exception as e:
|
||||
print("Error starting Continue server: ", e)
|
||||
logger.debug(f"Error starting Continue server: {e}")
|
||||
cleanup()
|
||||
raise e
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import subprocess
|
|||
from meilisearch_python_async import Client
|
||||
|
||||
from ..libs.util.paths import getServerFolderPath
|
||||
from ..libs.util.logging import logger
|
||||
|
||||
|
||||
def ensure_meilisearch_installed() -> bool:
|
||||
|
|
@ -39,7 +40,7 @@ def ensure_meilisearch_installed() -> bool:
|
|||
shutil.rmtree(p, ignore_errors=True)
|
||||
|
||||
# Download MeiliSearch
|
||||
print("Downloading MeiliSearch...")
|
||||
logger.debug("Downloading MeiliSearch...")
|
||||
subprocess.run(
|
||||
f"curl -L https://install.meilisearch.com | sh", shell=True, check=True, cwd=serverPath)
|
||||
|
||||
|
|
@ -82,6 +83,6 @@ async def start_meilisearch():
|
|||
|
||||
# Check if MeiliSearch is running
|
||||
if not await check_meilisearch_running() or not was_already_installed:
|
||||
print("Starting MeiliSearch...")
|
||||
logger.debug("Starting MeiliSearch...")
|
||||
subprocess.Popen(["./meilisearch", "--no-analytics"], cwd=serverPath, stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.STDOUT, close_fds=True, start_new_session=True)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ from ..core.autopilot import Autopilot
|
|||
from .ide_protocol import AbstractIdeProtocolServer
|
||||
from ..libs.util.create_async_task import create_async_task
|
||||
from ..libs.util.errors import SessionNotFound
|
||||
from ..libs.util.logging import logger
|
||||
|
||||
|
||||
class Session:
|
||||
|
|
@ -61,7 +62,7 @@ class SessionManager:
|
|||
return self.sessions[session_id]
|
||||
|
||||
async def new_session(self, ide: AbstractIdeProtocolServer, session_id: Union[str, None] = None) -> Session:
|
||||
print("New session: ", session_id)
|
||||
logger.debug(f"New session: {session_id}")
|
||||
|
||||
full_state = None
|
||||
if session_id is not None and os.path.exists(getSessionFilePath(session_id)):
|
||||
|
|
@ -86,7 +87,7 @@ class SessionManager:
|
|||
return session
|
||||
|
||||
async def remove_session(self, session_id: str):
|
||||
print("Removing session: ", session_id)
|
||||
logger.debug(f"Removing session: {session_id}")
|
||||
if session_id in self.sessions:
|
||||
if session_id in self.registered_ides:
|
||||
ws_to_close = self.registered_ides[session_id].websocket
|
||||
|
|
@ -103,13 +104,13 @@ class SessionManager:
|
|||
|
||||
def register_websocket(self, session_id: str, ws: WebSocket):
|
||||
self.sessions[session_id].ws = ws
|
||||
print("Registered websocket for session", session_id)
|
||||
logger.debug(f"Registered websocket for session {session_id}")
|
||||
|
||||
async def send_ws_data(self, session_id: str, message_type: str, data: Any):
|
||||
if session_id not in self.sessions:
|
||||
raise SessionNotFound(f"Session {session_id} not found")
|
||||
if self.sessions[session_id].ws is None:
|
||||
# print(f"Session {session_id} has no websocket")
|
||||
# logger.debug(f"Session {session_id} has no websocket")
|
||||
return
|
||||
|
||||
await self.sessions[session_id].ws.send_json({
|
||||
|
|
|
|||
4
extension/package-lock.json
generated
4
extension/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.0.218",
|
||||
"version": "0.0.219",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.0.218",
|
||||
"version": "0.0.219",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
"displayName": "Continue",
|
||||
"pricing": "Free",
|
||||
"description": "The open-source coding autopilot",
|
||||
"version": "0.0.218",
|
||||
"version": "0.0.219",
|
||||
"publisher": "Continue",
|
||||
"engines": {
|
||||
"vscode": "^1.67.0"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue