Skip to content

Commit e6818a6

Browse files
committed
remove cyclic
1 parent b8b3826 commit e6818a6

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from typing import NotRequired, TypedDict
2+
3+
4+
class LogExtra(TypedDict):
5+
log_uid: NotRequired[str]
6+
log_oec: NotRequired[str]
7+
8+
9+
def get_log_record_extra(
10+
*,
11+
user_id: int | str | None = None,
12+
error_code: str | None = None,
13+
) -> LogExtra | None:
14+
extra: LogExtra = {}
15+
16+
if user_id:
17+
assert int(user_id) > 0 # nosec
18+
extra["log_uid"] = f"{user_id}"
19+
if error_code:
20+
extra["log_oec"] = error_code
21+
22+
return extra or None

packages/service-library/src/servicelib/logging_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from common_library.errors_classes import OsparcErrorMixin
66
from common_library.json_serialization import json_dumps, representation_encoder
77

8-
from .logging_utils import LogExtra, get_log_record_extra
8+
from .logging_base import LogExtra, get_log_record_extra
99

1010
_logger = logging.getLogger(__name__)
1111

packages/service-library/src/servicelib/logging_utils.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
from datetime import datetime
1818
from inspect import getframeinfo, stack
1919
from pathlib import Path
20-
from typing import Any, Final, NotRequired, TypeAlias, TypedDict, TypeVar
20+
from typing import Any, Final, TypeAlias, TypedDict, TypeVar
2121

2222
from common_library.json_serialization import json_dumps
2323
from settings_library.tracing import TracingSettings
2424

25+
from .logging_base import LogExtra
2526
from .logging_errors import create_troubleshootting_log_kwargs
2627
from .logging_utils_filtering import GeneralLogFilter, LoggerName, MessageSubstring
2728
from .tracing import setup_log_tracing
@@ -61,27 +62,6 @@
6162
}
6263

6364

64-
class LogExtra(TypedDict):
65-
log_uid: NotRequired[str]
66-
log_oec: NotRequired[str]
67-
68-
69-
def get_log_record_extra(
70-
*,
71-
user_id: int | str | None = None,
72-
error_code: str | None = None,
73-
) -> LogExtra | None:
74-
extra: LogExtra = {}
75-
76-
if user_id:
77-
assert int(user_id) > 0 # nosec
78-
extra["log_uid"] = f"{user_id}"
79-
if error_code:
80-
extra["log_oec"] = error_code
81-
82-
return extra or None
83-
84-
8565
class CustomFormatter(logging.Formatter):
8666
"""Custom Formatter does these 2 things:
8767
1. Overrides 'funcName' with the value of 'func_name_override', if it exists.

0 commit comments

Comments
 (0)