mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
added get_log_level and set_log_level operations to the app route
This commit is contained in:
parent
8d77c5ca96
commit
603989dc0d
@ -1,9 +1,22 @@
|
|||||||
|
from enum import Enum
|
||||||
|
from fastapi import Body
|
||||||
from fastapi.routing import APIRouter
|
from fastapi.routing import APIRouter
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from invokeai.backend.image_util.patchmatch import PatchMatch
|
from invokeai.backend.image_util.patchmatch import PatchMatch
|
||||||
from invokeai.version import __version__
|
from invokeai.version import __version__
|
||||||
|
|
||||||
|
from ..dependencies import ApiDependencies
|
||||||
|
from invokeai.backend.util.logging import logging
|
||||||
|
|
||||||
|
class LogLevel(int, Enum):
|
||||||
|
NotSet = logging.NOTSET
|
||||||
|
Debug = logging.DEBUG
|
||||||
|
Info = logging.INFO
|
||||||
|
Warning = logging.WARNING
|
||||||
|
Error = logging.ERROR
|
||||||
|
Critical = logging.CRITICAL
|
||||||
|
|
||||||
app_router = APIRouter(prefix="/v1/app", tags=["app"])
|
app_router = APIRouter(prefix="/v1/app", tags=["app"])
|
||||||
|
|
||||||
|
|
||||||
@ -34,3 +47,27 @@ async def get_config() -> AppConfig:
|
|||||||
if PatchMatch.patchmatch_available():
|
if PatchMatch.patchmatch_available():
|
||||||
infill_methods.append('patchmatch')
|
infill_methods.append('patchmatch')
|
||||||
return AppConfig(infill_methods=infill_methods)
|
return AppConfig(infill_methods=infill_methods)
|
||||||
|
|
||||||
|
@app_router.get(
|
||||||
|
"/logging",
|
||||||
|
operation_id="get_log_level",
|
||||||
|
responses={200: {"description" : "The operation was successful"}},
|
||||||
|
response_model = LogLevel,
|
||||||
|
)
|
||||||
|
async def get_log_level(
|
||||||
|
) -> LogLevel:
|
||||||
|
"""Returns the log level"""
|
||||||
|
return LogLevel(ApiDependencies.invoker.services.logger.level)
|
||||||
|
|
||||||
|
@app_router.post(
|
||||||
|
"/logging",
|
||||||
|
operation_id="set_log_level",
|
||||||
|
responses={200: {"description" : "The operation was successful"}},
|
||||||
|
response_model = LogLevel,
|
||||||
|
)
|
||||||
|
async def set_log_level(
|
||||||
|
level: LogLevel = Body(description="New log verbosity level"),
|
||||||
|
) -> LogLevel:
|
||||||
|
"""Sets the log verbosity level"""
|
||||||
|
ApiDependencies.invoker.services.logger.setLevel(level)
|
||||||
|
return LogLevel(ApiDependencies.invoker.services.logger.level)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user