Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit 2ce1d18

Browse files
[client] Improve logger to accept metadata to improve log management (#517)
1 parent efec0a8 commit 2ce1d18

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

pycti/connector/opencti_connector_helper.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -906,17 +906,21 @@ def get_opencti_token(self) -> Optional[Union[bool, int, str]]:
906906
def get_connector(self) -> OpenCTIConnector:
907907
return self.connector
908908

909-
def log_error(self, msg: str) -> None:
910-
LOGGER.error(msg)
909+
def log_error(self, msg: str, meta=None) -> None:
910+
extra = None if meta is None else {"attributes": meta}
911+
LOGGER.error(msg, exc_info=1, extra=extra)
911912

912-
def log_info(self, msg: str) -> None:
913-
LOGGER.info(msg)
913+
def log_info(self, msg: str, meta=None) -> None:
914+
extra = None if meta is None else {"attributes": meta}
915+
LOGGER.info(msg, extra=extra)
914916

915-
def log_debug(self, msg: str) -> None:
916-
LOGGER.debug(msg)
917+
def log_debug(self, msg: str, meta=None) -> None:
918+
extra = None if meta is None else {"attributes": meta}
919+
LOGGER.debug(msg, extra=extra)
917920

918-
def log_warning(self, msg: str) -> None:
919-
LOGGER.warning(msg)
921+
def log_warning(self, msg: str, meta=None) -> None:
922+
extra = None if meta is None else {"attributes": meta}
923+
LOGGER.warning(msg, extra=extra)
920924

921925
def date_now(self) -> str:
922926
"""get the current date (UTC)

0 commit comments

Comments
 (0)