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

Added multiprocessing logging module #169

Closed
wants to merge 8 commits into from

Conversation

TongguangZhang
Copy link
Contributor

Added logging example in main_2024 and video_input

Copy link
Contributor Author

@TongguangZhang TongguangZhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't really decide how to implement this custom logging module - should I try to make it as similar to the default logging module as possible or make it consistent with our other modules?

Comment on lines +4 to +8
DEBUG = logging.DEBUG
INFO = logging.INFO
WARNING = logging.WARNING
ERROR = logging.ERROR
CRITICAL = logging.CRITICAL
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this so so that modules trying to log don't have to import the logging module just for the logging levels

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we create a separate file and store these values as an enum?

Comment on lines 10 to 15
def message_and_metadata(message, frame):
function_name = frame.f_code.co_name
filename = frame.f_code.co_filename
line_number = inspect.getframeinfo(frame).lineno

return f'[{filename} | {function_name} | {line_number}] {message}'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the frame object cannot be pickled so you can't put it in a queue, this is why we need this helper function, since we probably don't want to write this every time we want to log

Comment on lines 34 to 35
multiprocess_logging.log_message(f'image size {image.shape}', multiprocess_logging.DEBUG, frame, self.logging_queue)
# self.logging_queue.queue.put((multiprocess_logging.message_and_metadata(f'image size {image.shape}', frame), logging.DEBUG), block=False)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are the 2 methods I'm thinking about using right now - the second method is more consistent with our current modules, where we put things in queues, the first method is more similar to how the default logging module is used

@TongguangZhang TongguangZhang deleted the multiprocessing_logging branch March 29, 2024 21:48
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 this pull request may close these issues.

2 participants