Skip to content

Commit

Permalink
address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ohmayr committed Dec 2, 2024
1 parent 8514389 commit a157d8c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions google/api_core/client_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@
"httpRequest",
"rpcName",
"serviceName",
"credentialsType",
"credentialInfo",
"universeDomain",
"request",
"response",
"metadata",
"retryAttempt",
] # Additional fields to be Logged.


# TODO(https://github.com/googleapis/python-api-core/issues/763): Expand documentation.
def logger_configured(logger):
def logger_configured(logger) -> bool:
"""Determines whether `logger` has non-default configuration
Args:
Expand All @@ -32,7 +38,6 @@ def logger_configured(logger):
)


# TODO(https://github.com/googleapis/python-api-core/issues/763): Expand documentation.
def initialize_logging():
"""Initializes "google" loggers, partly based on the environment variable
Expand All @@ -55,7 +60,6 @@ def initialize_logging():
_LOGGING_INITIALIZED = True


# TODO(https://github.com/googleapis/python-api-core/issues/763): Expand documentation.
def parse_logging_scopes(scopes: Optional[str] = None) -> List[str]:
"""Returns a list of logger names.
Expand All @@ -76,7 +80,6 @@ def parse_logging_scopes(scopes: Optional[str] = None) -> List[str]:
return namespaces


# TODO(https://github.com/googleapis/python-api-core/issues/763): Expand documentation.
def configure_defaults(logger):
"""Configures `logger` to emit structured info to stdout."""
if not logger_configured(logger):
Expand All @@ -88,8 +91,7 @@ def configure_defaults(logger):
logger.addHandler(console_handler)


# TODO(https://github.com/googleapis/python-api-core/issues/763): Expand documentation.
def setup_logging(scopes=""):
def setup_logging(scopes: str=""):
"""Sets up logging for the specified `scopes`.
If the loggers specified in `scopes` have not been previously
Expand Down Expand Up @@ -122,11 +124,11 @@ def setup_logging(scopes=""):
base_logger.propagate = False


# TODO(https://github.com/googleapis/python-api-core/issues/763): Add documentation.
# TODO(https://github.com/googleapis/python-api-core/issues/763): Expand documentation.
class StructuredLogFormatter(logging.Formatter):
# TODO(https://github.com/googleapis/python-api-core/issues/761): ensure that additional fields such as
# function name, file name, and line no. appear in a log output.
def format(self, record):
def format(self, record: logging.LogRecord):
log_obj = {
"timestamp": self.formatTime(record),
"severity": record.levelname,
Expand Down

0 comments on commit a157d8c

Please sign in to comment.