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

[Feature-Request] Implement best practice for Python logging #1132

Closed
hexbabe opened this issue Oct 31, 2023 · 0 comments · Fixed by #1135
Closed

[Feature-Request] Implement best practice for Python logging #1132

hexbabe opened this issue Oct 31, 2023 · 0 comments · Fixed by #1135
Assignees
Labels
enhancement New feature or request

Comments

@hexbabe
Copy link

hexbabe commented Oct 31, 2023

Problem
The module I am writing logs INFO logs to std.out. logger.py in depthai_sdk overrides my own logger config and writes INFO logs to std.err.

Proposed Solution
Please refactor the logging logic in the Python SDK to use a custom logger object rather than using basicConfig and modifying the root logger for the entire logging package. This way if users want to modify the depthai logging config they can do so by using getLogger rather than messing with logging globally.

# example
# Create a logger for your module, using the module's name
logger = logging.getLogger(__name__)

# Configure the logger for your module
logger.setLevel(logging.INFO)  # Set the desired log level
handler = logging.StreamHandler()  # Add a handler (e.g., to the console)
formatter = logging.Formatter('[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
@hexbabe hexbabe added the enhancement New feature or request label Oct 31, 2023
@hexbabe hexbabe closed this as completed Oct 31, 2023
@hexbabe hexbabe closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2023
@hexbabe hexbabe reopened this Oct 31, 2023
@hexbabe hexbabe changed the title [Feature-Request] Configurable logger setup [Feature-Request] Implement best practice for Python logging Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants