Skip to content

Commit 1b468a0

Browse files
[executors] feat: add enum for logger types
1 parent b1f99c7 commit 1b468a0

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

libs/executors/garf_executors/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ def setup_executor(
4848
'ApiExecutionContext',
4949
]
5050

51-
__version__ = '0.0.9'
51+
__version__ = '0.0.10'

libs/executors/garf_executors/entrypoints/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from __future__ import annotations
1717

18+
import enum
1819
import logging
1920
import sys
2021
from collections.abc import Sequence
@@ -89,8 +90,15 @@ class GarfParamsException(Exception):
8990
"""Defines exception for incorrect parameters."""
9091

9192

93+
class LoggerEnum(str, enum.Enum):
94+
local = 'local'
95+
rich = 'rich'
96+
97+
9298
def init_logging(
93-
loglevel: str = 'INFO', logger_type: str = 'local', name: str = __name__
99+
loglevel: str = 'INFO',
100+
logger_type: str | LoggerEnum = 'local',
101+
name: str = __name__,
94102
) -> logging.Logger:
95103
if logger_type == 'rich':
96104
logging.basicConfig(

libs/executors/tests/unit/entrypoints/test_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,11 @@ def test_parse(self, param_parser):
7979
},
8080
'template': {},
8181
}
82+
83+
84+
@pytest.mark.parametrize(
85+
'logger_type',
86+
['local', 'rich', utils.LoggerEnum.local, utils.LoggerEnum.rich],
87+
)
88+
def test_init_logging(logger_type):
89+
assert utils.init_logging(logger_type=logger_type)

0 commit comments

Comments
 (0)