-
Notifications
You must be signed in to change notification settings - Fork 39
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
Conversation
There was a problem hiding this 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?
DEBUG = logging.DEBUG | ||
INFO = logging.INFO | ||
WARNING = logging.WARNING | ||
ERROR = logging.ERROR | ||
CRITICAL = logging.CRITICAL |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
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}' |
There was a problem hiding this comment.
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
modules/video_input/video_input.py
Outdated
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) |
There was a problem hiding this comment.
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
Added logging example in main_2024 and video_input