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

Problem with print statements in Logger #1344

Closed
ambitious-octopus opened this issue Jan 27, 2025 · 1 comment · Fixed by #1345
Closed

Problem with print statements in Logger #1344

ambitious-octopus opened this issue Jan 27, 2025 · 1 comment · Fixed by #1345
Assignees

Comments

@ambitious-octopus
Copy link
Contributor

ambitious-octopus commented Jan 27, 2025

Issue Type

Bug

Source

pip (model-compression-toolkit)

MCT Version

2.1.1

OS Platform and Distribution

Linux Ubuntu 22.04

Python version

3.11

Describe the issue

We’ve identified an issue with the Logger class in the current implementation (cc @Laughing-q ). Specifically, the use of print statements within the info and warning methods is causing problems with logging suppression and control. This behavior is not ideal for a logging utility, as it bypasses the logging framework and makes it difficult to manage log output effectively.

def info(msg: str):
"""
Log a message at 'info' severity.
Args:
msg: Message to log.
"""
print(msg)
Logger.get_logger().info(msg)
@staticmethod
def warning(msg: str):
"""
Log a message at 'warning' severity.
Args:
msg: Message to log.
"""
print(msg)
Logger.get_logger().warning(msg)

Additional problems:

The print statements in the info and warning methods directly output messages to the console, regardless of the logging level or configuration. This bypasses the logging framework, making it impossible to suppress these messages when needed (e.g., in production environments where only errors or critical logs are required).

The print statements create inconsistency in log handling. For example, if the logging level is set to ERROR or CRITICAL, the info and warning logs should not be displayed. However, because of the print statements, these messages are still printed to the console, which defeats the purpose of setting a logging level.

Since the print statements duplicate the log messages, the same message appears twice: once from the print statement and once from the actual logger. This redundancy can clutter the console and log files, making it harder to read and analyze logs.

Expected behaviour

No response

Code to reproduce the issue

Steps to Reproduce:

1. Set the logging level to ERROR or CRITICAL.

2. Call `Logger.info("Test message")` or `Logger.warning("Test message")`.

3. Observe that the message is still printed to the console despite the logging level.

Log output

No response

@ambitious-octopus ambitious-octopus changed the title Problem with print Statements in Logger Problem with print statements in Logger Jan 27, 2025
@ofirgo ofirgo assigned lior-dikstein and elad-c and unassigned lior-dikstein Jan 27, 2025
@elad-c
Copy link
Collaborator

elad-c commented Jan 27, 2025

Hi @ambitious-octopus ,
Thank you for bringing this to our attention. It will be fixed in the next nightly version (#1345)

@elad-c elad-c linked a pull request Jan 27, 2025 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants