add log monitoring

This commit is contained in:
Vladimir Mandic
2023-06-28 10:35:15 -04:00
parent c90e9965c7
commit 5a341b1182
15 changed files with 77 additions and 9 deletions
+7 -2
View File
@@ -25,6 +25,7 @@ from modules import devices
errors.install()
def upscaler_to_index(name: str):
try:
return [x.name.lower() for x in shared.sd_upscalers].index(name.lower())
@@ -157,8 +158,12 @@ class Api:
return True
raise HTTPException(status_code=401, detail="Unauthorized", headers={"WWW-Authenticate": "Basic"})
def get_log_buffer(self):
return shared.log.buffer
def get_log_buffer(self, req: models.LogRequest = Depends()):
lines = shared.log.buffer[:req.lines] if req.lines > 0 else shared.log.buffer.copy()
if req.clear:
shared.log.buffer.clear()
return lines
def get_selectable_script(self, script_name, script_runner):
if script_name is None or script_name == "":
+4
View File
@@ -173,6 +173,10 @@ class PNGInfoResponse(BaseModel):
info: str = Field(title="Image info", description="A string with the parameters used to generate the image")
items: dict = Field(title="Items", description="An object containing all the info the image had")
class LogRequest(BaseModel):
lines: int = Field(default=100, title="Lines", description="How many lines to return")
clear: bool = Field(default=False, title="Clear", description="Should the log be cleared after returning the lines?")
class ProgressRequest(BaseModel):
skip_current_image: bool = Field(default=False, title="Skip current image", description="Skip current image serialization")