Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use standard logger with custom handler in python integrations #1279

Closed
eugene-kulak opened this issue Dec 10, 2020 · 2 comments · Fixed by #6085
Closed

Use standard logger with custom handler in python integrations #1279

eugene-kulak opened this issue Dec 10, 2020 · 2 comments · Fixed by #6085
Assignees
Labels
area/connectors Connector related issues CDK Connector Development Kit CDKv2 lang/python type/enhancement New feature or request

Comments

@eugene-kulak
Copy link
Contributor

eugene-kulak commented Dec 10, 2020

Tell us about the problem you're trying to solve

Currently, we are using AirbyteLogger

  • a custom logger. The problem is that even though it looks like standard one, it behaves differently and lacks some features, the following would not work:
logger.info("Message: %s, code: %d", message, code")

Other features like enable/disabled some levels, duplicate messages to other sources (files, network, monitoring) adding custom formatters and user context, all this would not work as well.

Describe the solution you’d like

Use the standard logger class.

Describe the alternative you’ve considered or used

Implement custom Handler instead (or Formatter) and attach it to a specific logger (by name or explicitly in the code).

class AirbyteLogFormatter(logging.Formatter):
    def format(record)
        message = super().format(record)
        log_message = AirbyteMessage(type="LOG", log=AirbyteLogMessage(level=record.level, message=message))
        return log_message.json(exclude_unset=True)

logger = logging.getLogger('airbyte.source.zabbix')
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler(stream=sys.stdout)
handler.setFormatter(AirbyteLogFormatter())
logger.addHandler(handler)

Additional context

Add any other context or screenshots about the feature request here.

┆Issue is synchronized with this Asana task by Unito

@eugene-kulak eugene-kulak added the type/enhancement New feature or request label Dec 10, 2020
@cgardens
Copy link
Contributor

@ChristopheDuong - is this something you'd be familiar with? if it is we might tackle it in the next few weeks.

@cgardens cgardens added this to the v0.9.0 milestone Dec 14, 2020
@ChristopheDuong ChristopheDuong removed their assignment Dec 15, 2020
@cgardens cgardens modified the milestones: v0.9.0, v0.10.0 Dec 16, 2020
@cgardens
Copy link
Contributor

@sherifnada assigning to you as a "connector stability" task. Up to you to decide if this is something we should do now or not.

eugene-kulak added a commit to eugene-kulak/airbyte that referenced this issue Dec 29, 2020
@cgardens cgardens removed this from the v0.10.0 milestone Jan 4, 2021
@sherifnada sherifnada removed their assignment Jan 12, 2021
@keu keu mentioned this issue Apr 1, 2021
@sherifnada sherifnada added area/connectors Connector related issues CDK Connector Development Kit lang/python labels Jun 7, 2021
@sherifnada sherifnada added this to the Connectors, September 3rd milestone Aug 25, 2021
@vitaliizazmic vitaliizazmic self-assigned this Aug 27, 2021
vitaliizazmic added a commit that referenced this issue Oct 7, 2021
vitaliizazmic added a commit that referenced this issue Oct 7, 2021
vitaliizazmic added a commit that referenced this issue Oct 12, 2021
vitaliizazmic added a commit that referenced this issue Oct 12, 2021
* CDK - using native logger with custom formatter

* CDK - using native logger(fix exception and add trace)

* CDK - using native logger in AirbyteEntrypoint

* CDK - CHANGELOG.md

* CDK - remove unnecessary imports

* CDK - fixing according to PR review

* CDK native logger #1279 - annotations

* CDK native logger #1279 - fixing according to PR review

* CDK standard logger #1279 - tests

* CDK standard logger #1279 - reformat

* Airbyte CDK #1279 - improve docstrings

* Airbyte CDK #1279 - improve log levels

* Airbyte CDK #1279 - fix init get source name

* Airbyte CDK #1279 - update test licence

* Airbyte CDK #1279 - bump version
vitaliizazmic added a commit that referenced this issue Oct 13, 2021
vitaliizazmic added a commit that referenced this issue Oct 13, 2021
…ich to start pulling data

* Source Freshdesk #6133 - add update since parameter to spec for tickets stream

* Source Freshdesk #6133 - fixing according to PR

* Source Freshdesk #6133 - fixing according to PR review

* Source Freshdesk #1279 - implement start date for all incremental streams

* Source Freshdesk #1279 - fixing start_date

* Source Freshdesk #1279 - reformat

* Source Freshdesk #1279 - bump and CHANGELOG.md
vitaliizazmic added a commit that referenced this issue Oct 13, 2021
vitaliizazmic added a commit that referenced this issue Oct 15, 2021
…evel from "WARN" to logging.WARN in self.logger.log
vitaliizazmic added a commit that referenced this issue Oct 15, 2021
vitaliizazmic added a commit that referenced this issue Oct 18, 2021
* Airbyte CDK native logger #1279 - fix import logger error

* Airbyte CDK native logger #1279 - source-paypal-transaction: change level from "WARN" to logging.WARN in self.logger.log

* Airbyte CDK native logger #1279 - source-s3: use native logger instead AirbyteLogger

* Airbyte CDK native logger #1279 - source-zuora: use native logger instead AirbyteLogger

* Airbyte CDK native logger #1279 - fix get logger
vitaliizazmic added a commit that referenced this issue Oct 22, 2021
… levels

* Airbyte CDK native logger #1279 - transforming Python log levels to Airbyte protocol log levels

* Airbyte CDK native logger #1279 - add test for level types transforming

* CDK standard logger #1279 - test for transform critical level to fatal
schlattk pushed a commit to schlattk/airbyte that referenced this issue Jan 4, 2022
* CDK - using native logger with custom formatter

* CDK - using native logger(fix exception and add trace)

* CDK - using native logger in AirbyteEntrypoint

* CDK - CHANGELOG.md

* CDK - remove unnecessary imports

* CDK - fixing according to PR review

* CDK native logger airbytehq#1279 - annotations

* CDK native logger airbytehq#1279 - fixing according to PR review

* CDK standard logger airbytehq#1279 - tests

* CDK standard logger airbytehq#1279 - reformat

* Airbyte CDK airbytehq#1279 - improve docstrings

* Airbyte CDK airbytehq#1279 - improve log levels

* Airbyte CDK airbytehq#1279 - fix init get source name

* Airbyte CDK airbytehq#1279 - update test licence

* Airbyte CDK airbytehq#1279 - bump version
schlattk pushed a commit to schlattk/airbyte that referenced this issue Jan 4, 2022
…ich to start pulling data

* Source Freshdesk airbytehq#6133 - add update since parameter to spec for tickets stream

* Source Freshdesk airbytehq#6133 - fixing according to PR

* Source Freshdesk airbytehq#6133 - fixing according to PR review

* Source Freshdesk airbytehq#1279 - implement start date for all incremental streams

* Source Freshdesk airbytehq#1279 - fixing start_date

* Source Freshdesk airbytehq#1279 - reformat

* Source Freshdesk airbytehq#1279 - bump and CHANGELOG.md
schlattk pushed a commit to schlattk/airbyte that referenced this issue Jan 4, 2022
* Airbyte CDK native logger airbytehq#1279 - fix import logger error

* Airbyte CDK native logger airbytehq#1279 - source-paypal-transaction: change level from "WARN" to logging.WARN in self.logger.log

* Airbyte CDK native logger airbytehq#1279 - source-s3: use native logger instead AirbyteLogger

* Airbyte CDK native logger airbytehq#1279 - source-zuora: use native logger instead AirbyteLogger

* Airbyte CDK native logger airbytehq#1279 - fix get logger
schlattk pushed a commit to schlattk/airbyte that referenced this issue Jan 4, 2022
… levels

* Airbyte CDK native logger airbytehq#1279 - transforming Python log levels to Airbyte protocol log levels

* Airbyte CDK native logger airbytehq#1279 - add test for level types transforming

* CDK standard logger airbytehq#1279 - test for transform critical level to fatal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues CDK Connector Development Kit CDKv2 lang/python type/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants