-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
Milestone
Description
Required prerequisites
- I have searched the Issue Tracker and Discussions that this hasn't already been reported. (+1 or comment there if it has.)
- Consider asking first in a Discussion.
Motivation
The camel.societies.workforce.workforce.Workforce class currently uses direct print() calls for logging informational messages, warnings, and errors (e.g., when a worker is created or a task fails). This approach tightly couples the core business logic of the Workforce with the presentation layer (console output).
This leads to several issues:
- Poor Extensibility: Users who want to redirect logs to a file, a UI, or a remote monitoring service cannot do so without modifying the core Workforce code.
- Inconsistent Logging: It mixes standard logger calls with print statements, making log management inconsistent.
- Hardcoded Formatting: The use of colorama for console coloring is hardcoded within the core logic, whereas formatting should be a concern of the presentation/logging layer.
Solution
- Define a
log_info(self, event: LogEvent)method in the abstract base classWorkforceCallback. - Implement this method in the concrete implementation class
WorkforceLogger. The implementation ofWorkforceLogger.log_infochecks thelevelfield of theLogEvent(such asinfo,warning,error) and uses Python's logging module (logger.info,logger.warning, etc.) to output the log. - Color processing (such as using colorama) should also be done in
WorkforceLoggeror other callbacks specifically responsible for console output, not in the coreWorkforceclass.
Alternatives
No response
Additional context
No response
fengju0213 and Wendong-Fan
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status