Skip to content

Commit

Permalink
attempt #2
Browse files Browse the repository at this point in the history
  • Loading branch information
maxi297 committed Oct 4, 2024
1 parent 7d34283 commit 067ba83
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
3 changes: 1 addition & 2 deletions airbyte-cdk/python/airbyte_cdk/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from requests import PreparedRequest, Response, Session

logger = init_logger("airbyte")
message_logger = logging.getLogger("messagelogger")

VALID_URL_SCHEMES = ["https"]
CLOUD_DEPLOYMENT_MODE = "cloud"
Expand Down Expand Up @@ -264,7 +263,7 @@ def launch(source: Source, args: List[str]) -> None:
for message in source_entrypoint.run(parsed_args):
# simply printing is creating issues for concurrent CDK as Python uses different two instructions to print: one for the message and
# the other for the break line. Adding `\n` to the message ensure that both are printed at the same time
message_logger.info(message)
logger.info(message, extra={"as_is": True})


def _init_internal_request_filter() -> None:
Expand Down
15 changes: 2 additions & 13 deletions airbyte-cdk/python/airbyte_cdk/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,13 @@
"disable_existing_loggers": False,
"formatters": {
"airbyte": {"()": "airbyte_cdk.logger.AirbyteLogFormatter", "format": "%(message)s"},
"as-is": {"format": "%(message)s"},
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout",
"formatter": "airbyte",
},
"console_as-is": {
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout",
"formatter": "as-is",
},
},
"loggers": {
"messagelogger": {
"handlers": ["console_as-is"],
"level": "INFO",
"propagate": False,
}
},
"root": {
"handlers": ["console"],
Expand Down Expand Up @@ -74,6 +61,8 @@ class AirbyteLogFormatter(logging.Formatter):
def format(self, record: logging.LogRecord) -> str:
"""Return a JSON representation of the log message"""
airbyte_level = self.level_mapping.get(record.levelno, Level.INFO)
if "as_is" in record.__dict__.keys():
return record.msg
if airbyte_level == Level.DEBUG:
extras = self.extract_extra_args_from_record(record)
debug_dict = {"type": "DEBUG", "message": record.getMessage(), "data": extras}
Expand Down

0 comments on commit 067ba83

Please sign in to comment.