forked from bizon-data/bizon-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add log levels and e2e testing
- Loading branch information
1 parent
13e7e8c
commit d30ed16
Showing
5 changed files
with
93 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,23 @@ | ||
from abc import ABC, abstractmethod | ||
from enum import Enum | ||
from typing import Dict, List | ||
|
||
from loguru import logger | ||
|
||
from bizon.alerting.models import AlertingConfig, AlertMethod | ||
|
||
|
||
class LogLevel(str, Enum): | ||
DEBUG = "DEBUG" | ||
INFO = "INFO" | ||
WARNING = "WARNING" | ||
ERROR = "ERROR" | ||
CRITICAL = "CRITICAL" | ||
from bizon.alerting.models import AlertingConfig, AlertMethod, LogLevel | ||
|
||
|
||
class AbstractAlert(ABC): | ||
|
||
def __init__(self, type: AlertMethod, config: AlertingConfig): | ||
def __init__(self, type: AlertMethod, config: AlertingConfig, log_levels: List[LogLevel] = [LogLevel.ERROR]): | ||
self.type = type | ||
self.config = config | ||
self.log_levels = log_levels | ||
|
||
@abstractmethod | ||
def handler(self, message: Dict) -> None: | ||
pass | ||
|
||
def add_handlers(self, levels: List[LogLevel] = [LogLevel.ERROR]) -> None: | ||
def add_handlers(self) -> None: | ||
levels = [level.value for level in self.log_levels] | ||
for level in levels: | ||
logger.add(self.handler, level=level, format="{message}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters