mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(logger): fix logger type issues
This commit is contained in:
parent
1b75d899ae
commit
d14b02e93f
@ -1,12 +1,12 @@
|
|||||||
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654)
|
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654)
|
||||||
|
|
||||||
|
from logging import Logger
|
||||||
import os
|
import os
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from invokeai.app.services.image_record_storage import SqliteImageRecordStorage
|
from invokeai.app.services.image_record_storage import SqliteImageRecordStorage
|
||||||
from invokeai.app.services.images import ImageService
|
from invokeai.app.services.images import ImageService
|
||||||
from invokeai.app.services.urls import LocalUrlService
|
from invokeai.app.services.urls import LocalUrlService
|
||||||
|
from invokeai.backend.util.logging import InvokeAILogger
|
||||||
import invokeai.backend.util.logging as logger
|
|
||||||
|
|
||||||
from ..services.default_graphs import create_system_graphs
|
from ..services.default_graphs import create_system_graphs
|
||||||
from ..services.latent_storage import DiskLatentsStorage, ForwardCacheLatentsStorage
|
from ..services.latent_storage import DiskLatentsStorage, ForwardCacheLatentsStorage
|
||||||
@ -40,6 +40,9 @@ def check_internet() -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
logger = InvokeAILogger.getLogger()
|
||||||
|
|
||||||
|
|
||||||
class ApiDependencies:
|
class ApiDependencies:
|
||||||
"""Contains and initializes all dependencies for the API"""
|
"""Contains and initializes all dependencies for the API"""
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654) and the InvokeAI Team
|
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654) and the InvokeAI Team
|
||||||
|
|
||||||
from types import ModuleType
|
from logging import Logger
|
||||||
from invokeai.app.services.image_record_storage import (
|
|
||||||
ImageRecordStorageBase,
|
|
||||||
)
|
|
||||||
from invokeai.app.services.images import ImageService
|
from invokeai.app.services.images import ImageService
|
||||||
from invokeai.app.services.metadata import MetadataServiceBase
|
from invokeai.app.services.metadata import MetadataServiceBase
|
||||||
from invokeai.app.services.urls import UrlServiceBase
|
from invokeai.app.services.urls import UrlServiceBase
|
||||||
@ -41,7 +38,7 @@ class InvocationServices:
|
|||||||
self,
|
self,
|
||||||
model_manager: ModelManager,
|
model_manager: ModelManager,
|
||||||
events: EventServiceBase,
|
events: EventServiceBase,
|
||||||
logger: ModuleType,
|
logger: Logger,
|
||||||
latents: LatentsStorageBase,
|
latents: LatentsStorageBase,
|
||||||
images: ImageFileStorageBase,
|
images: ImageFileStorageBase,
|
||||||
metadata: MetadataServiceBase,
|
metadata: MetadataServiceBase,
|
||||||
|
@ -76,16 +76,16 @@ class InvokeAILogFormatter(logging.Formatter):
|
|||||||
reset = "\x1b[0m"
|
reset = "\x1b[0m"
|
||||||
|
|
||||||
# Log Format
|
# Log Format
|
||||||
format = "[%(asctime)s]::[%(name)s]::%(levelname)s --> %(message)s"
|
log_format = "[%(asctime)s]::[%(name)s]::%(levelname)s --> %(message)s"
|
||||||
## More Formatting Options: %(pathname)s, %(filename)s, %(module)s, %(lineno)d
|
## More Formatting Options: %(pathname)s, %(filename)s, %(module)s, %(lineno)d
|
||||||
|
|
||||||
# Format Map
|
# Format Map
|
||||||
FORMATS = {
|
FORMATS = {
|
||||||
logging.DEBUG: cyan + format + reset,
|
logging.DEBUG: cyan + log_format + reset,
|
||||||
logging.INFO: grey + format + reset,
|
logging.INFO: grey + log_format + reset,
|
||||||
logging.WARNING: yellow + format + reset,
|
logging.WARNING: yellow + log_format + reset,
|
||||||
logging.ERROR: red + format + reset,
|
logging.ERROR: red + log_format + reset,
|
||||||
logging.CRITICAL: bold_red + format + reset
|
logging.CRITICAL: bold_red + log_format + reset
|
||||||
}
|
}
|
||||||
|
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
@ -98,13 +98,13 @@ class InvokeAILogger(object):
|
|||||||
loggers = dict()
|
loggers = dict()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getLogger(self, name: str = 'InvokeAI') -> logging.Logger:
|
def getLogger(cls, name: str = 'InvokeAI') -> logging.Logger:
|
||||||
if name not in self.loggers:
|
if name not in cls.loggers:
|
||||||
logger = logging.getLogger(name)
|
logger = logging.getLogger(name)
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
ch = logging.StreamHandler()
|
ch = logging.StreamHandler()
|
||||||
fmt = InvokeAILogFormatter()
|
fmt = InvokeAILogFormatter()
|
||||||
ch.setFormatter(fmt)
|
ch.setFormatter(fmt)
|
||||||
logger.addHandler(ch)
|
logger.addHandler(ch)
|
||||||
self.loggers[name] = logger
|
cls.loggers[name] = logger
|
||||||
return self.loggers[name]
|
return cls.loggers[name]
|
||||||
|
Loading…
Reference in New Issue
Block a user