Skip to content

Commit

Permalink
fixup! Fix flush exception thrown when LoggerProvider not configured
Browse files Browse the repository at this point in the history
  • Loading branch information
iurisilvio committed Jan 9, 2024
1 parent 3a3ea44 commit 2fe915e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def get_logger(
schema_url: Optional. Specifies the Schema URL of the emitted telemetry.
"""

def force_flush(self) -> None:
pass


class NoOpLoggerProvider(LoggerProvider):
"""The default LoggerProvider used when no LoggerProvider implementation is available."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,9 @@ def emit(self, record: logging.LogRecord) -> None:

def flush(self) -> None:
"""
Flushes the logging output. Skip flushing if logger is NoOp.
Flushes the logging output.
"""
if not isinstance(self._logger, NoOpLogger):
self._logger_provider.force_flush()
self._logger_provider.force_flush()


class Logger(APILogger):
Expand Down

0 comments on commit 2fe915e

Please sign in to comment.