feat(logger): fix logger type issues

This commit is contained in:
psychedelicious 2023-05-21 20:24:37 +10:00 committed by Kent Keirsey
parent 1b75d899ae
commit d14b02e93f
3 changed files with 17 additions and 17 deletions

View File

@ -1,12 +1,12 @@
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654)
from logging import Logger
import os
from types import ModuleType
from invokeai.app.services.image_record_storage import SqliteImageRecordStorage
from invokeai.app.services.images import ImageService
from invokeai.app.services.urls import LocalUrlService
import invokeai.backend.util.logging as logger
from invokeai.backend.util.logging import InvokeAILogger
from ..services.default_graphs import create_system_graphs
from ..services.latent_storage import DiskLatentsStorage, ForwardCacheLatentsStorage
@ -40,6 +40,9 @@ def check_internet() -> bool:
return False
logger = InvokeAILogger.getLogger()
class ApiDependencies:
"""Contains and initializes all dependencies for the API"""

View File

@ -1,9 +1,6 @@
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654) and the InvokeAI Team
from types import ModuleType
from invokeai.app.services.image_record_storage import (
ImageRecordStorageBase,
)
from logging import Logger
from invokeai.app.services.images import ImageService
from invokeai.app.services.metadata import MetadataServiceBase
from invokeai.app.services.urls import UrlServiceBase
@ -41,7 +38,7 @@ class InvocationServices:
self,
model_manager: ModelManager,
events: EventServiceBase,
logger: ModuleType,
logger: Logger,
latents: LatentsStorageBase,
images: ImageFileStorageBase,
metadata: MetadataServiceBase,

View File

@ -76,16 +76,16 @@ class InvokeAILogFormatter(logging.Formatter):
reset = "\x1b[0m"
# 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
# Format Map
FORMATS = {
logging.DEBUG: cyan + format + reset,
logging.INFO: grey + format + reset,
logging.WARNING: yellow + format + reset,
logging.ERROR: red + format + reset,
logging.CRITICAL: bold_red + format + reset
logging.DEBUG: cyan + log_format + reset,
logging.INFO: grey + log_format + reset,
logging.WARNING: yellow + log_format + reset,
logging.ERROR: red + log_format + reset,
logging.CRITICAL: bold_red + log_format + reset
}
def format(self, record):
@ -98,13 +98,13 @@ class InvokeAILogger(object):
loggers = dict()
@classmethod
def getLogger(self, name: str = 'InvokeAI') -> logging.Logger:
if name not in self.loggers:
def getLogger(cls, name: str = 'InvokeAI') -> logging.Logger:
if name not in cls.loggers:
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
fmt = InvokeAILogFormatter()
ch.setFormatter(fmt)
logger.addHandler(ch)
self.loggers[name] = logger
return self.loggers[name]
cls.loggers[name] = logger
return cls.loggers[name]