Skip to main content

WorkforceLogger

Logs events and metrics for a Workforce instance.

init

Initializes the WorkforceLogger. Parameters:
  • workforce_id (str): The unique identifier for the workforce.

log_message

Logs a message to the console with color.

_log_event

Internal method to create and store a log entry. Parameters:
  • event_type (str): The type of event being logged. **kwargs: Additional data associated with the event.

log_task_created

Logs the creation of a new task.

log_task_decomposed

Logs the decomposition of a task into subtasks.

log_task_assigned

Logs the assignment of a task to a worker.

log_task_started

Logs when a worker starts processing a task.

log_task_updated

Logs updates made to a task.

log_task_completed

Logs the successful completion of a task.

log_task_failed

Logs the failure of a task.

log_worker_created

Logs the creation of a new worker.

log_worker_deleted

Logs the deletion of a worker.

log_queue_status

Logs the status of a task queue.

log_all_tasks_completed

reset_task_data

Resets logs and data related to tasks, preserving worker information.

dump_to_json

Dumps all log entries to a JSON file. Parameters:
  • file_path (str): The path to the JSON file.

_get_all_tasks_in_hierarchy

Recursively collect all tasks in the hierarchy starting from task_id.

_get_task_tree_string

Generate a string representation of the task tree.

get_ascii_tree_representation

Generates an ASCII tree representation of the current task hierarchy and worker status.

get_kpis

Calculates and returns key performance indicators from the logs.