mirror of https://github.com/CIRCL/lookyloo
chg: Normalize logging on the config file settings
parent
d5e06a895a
commit
9995371916
|
@ -10,7 +10,7 @@ from collections import defaultdict
|
|||
from collections.abc import Mapping
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
from typing import Dict, List
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from redis import Redis
|
||||
|
||||
|
@ -22,7 +22,7 @@ logging.config.dictConfig(get_config('logging'))
|
|||
|
||||
class Archiver(AbstractManager):
|
||||
|
||||
def __init__(self, loglevel: int=logging.INFO):
|
||||
def __init__(self, loglevel: Optional[int]=None):
|
||||
super().__init__(loglevel)
|
||||
self.script_name = 'archiver'
|
||||
self.redis = Redis(unix_socket_path=get_socket_path('cache'))
|
||||
|
|
|
@ -23,7 +23,7 @@ logging.config.dictConfig(get_config('logging'))
|
|||
|
||||
class AsyncCapture(AbstractManager):
|
||||
|
||||
def __init__(self, loglevel: int=logging.INFO):
|
||||
def __init__(self, loglevel: Optional[int]=None):
|
||||
super().__init__(loglevel)
|
||||
self.script_name = 'async_capture'
|
||||
self.only_global_lookups: bool = get_config('generic', 'only_global_lookups')
|
||||
|
|
|
@ -5,6 +5,8 @@ import logging.config
|
|||
import os
|
||||
import shutil
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from lookyloo.default import AbstractManager, get_config
|
||||
from lookyloo.exceptions import MissingUUID, NoValidHarFile
|
||||
from lookyloo.lookyloo import Lookyloo
|
||||
|
@ -16,7 +18,7 @@ logging.config.dictConfig(get_config('logging'))
|
|||
|
||||
class BackgroundIndexer(AbstractManager):
|
||||
|
||||
def __init__(self, loglevel: int=logging.INFO):
|
||||
def __init__(self, loglevel: Optional[int]=None):
|
||||
super().__init__(loglevel)
|
||||
self.lookyloo = Lookyloo()
|
||||
self.script_name = 'background_indexer'
|
||||
|
|
|
@ -5,7 +5,7 @@ import logging
|
|||
import logging.config
|
||||
from collections import Counter
|
||||
from datetime import date, timedelta
|
||||
from typing import Any, Dict
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from lookyloo.lookyloo import Lookyloo
|
||||
from lookyloo.default import AbstractManager, get_config, get_homedir, safe_create_dir
|
||||
|
@ -16,7 +16,7 @@ logging.config.dictConfig(get_config('logging'))
|
|||
|
||||
class Processing(AbstractManager):
|
||||
|
||||
def __init__(self, loglevel: int=logging.INFO):
|
||||
def __init__(self, loglevel: Optional[int]=None):
|
||||
super().__init__(loglevel)
|
||||
self.script_name = 'processing'
|
||||
self.lookyloo = Lookyloo()
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
import logging
|
||||
import logging.config
|
||||
|
||||
from subprocess import Popen
|
||||
from typing import Optional
|
||||
|
||||
from lookyloo.default import get_config, get_homedir, AbstractManager
|
||||
|
||||
|
@ -11,7 +13,7 @@ logging.config.dictConfig(get_config('logging'))
|
|||
|
||||
class Website(AbstractManager):
|
||||
|
||||
def __init__(self, loglevel: int=logging.INFO):
|
||||
def __init__(self, loglevel: Optional[int]=None):
|
||||
super().__init__(loglevel)
|
||||
self.script_name = 'website'
|
||||
self.process = self._launch_website()
|
||||
|
|
|
@ -13,17 +13,17 @@ from typing import List, Optional, Tuple
|
|||
from redis import Redis
|
||||
from redis.exceptions import ConnectionError as RedisConnectionError
|
||||
|
||||
from .helpers import get_socket_path
|
||||
from .helpers import get_socket_path, get_config
|
||||
|
||||
|
||||
class AbstractManager(ABC):
|
||||
|
||||
script_name: str
|
||||
|
||||
def __init__(self, loglevel: int=logging.DEBUG):
|
||||
self.loglevel = loglevel
|
||||
def __init__(self, loglevel: Optional[int]=None):
|
||||
self.loglevel: int = loglevel if loglevel is not None else get_config('generic', 'loglevel') or logging.INFO
|
||||
self.logger = logging.getLogger(f'{self.__class__.__name__}')
|
||||
self.logger.setLevel(loglevel)
|
||||
self.logger.setLevel(self.loglevel)
|
||||
self.logger.info(f'Initializing {self.__class__.__name__}')
|
||||
self.process: Optional[Popen] = None
|
||||
self.__redis = Redis(unix_socket_path=get_socket_path('cache'), db=1, decode_responses=True)
|
||||
|
|
Loading…
Reference in New Issue