> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Camel.societies.workforce.workforce logger

<a id="camel.societies.workforce.workforce_logger" />

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger" />

## WorkforceLogger

```python theme={"system"}
class WorkforceLogger(WorkforceCallback, WorkforceMetrics):
```

Logs events and metrics for a Workforce instance.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.__init__" />

### **init**

```python theme={"system"}
def __init__(self, workforce_id: str):
```

Initializes the WorkforceLogger.

**Parameters:**

* **workforce\_id** (str): The unique identifier for the workforce.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_message" />

### log\_message

```python theme={"system"}
def log_message(self, event: LogEvent):
```

Logs a message to the console with color.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger._log_event" />

### \_log\_event

```python theme={"system"}
def _log_event(self, event_type: str, **kwargs: Any):
```

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.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_created" />

### log\_task\_created

```python theme={"system"}
def log_task_created(self, event: TaskCreatedEvent):
```

Logs the creation of a new task.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_decomposed" />

### log\_task\_decomposed

```python theme={"system"}
def log_task_decomposed(self, event: TaskDecomposedEvent):
```

Logs the decomposition of a task into subtasks.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_assigned" />

### log\_task\_assigned

```python theme={"system"}
def log_task_assigned(self, event: TaskAssignedEvent):
```

Logs the assignment of a task to a worker.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_started" />

### log\_task\_started

```python theme={"system"}
def log_task_started(self, event: TaskStartedEvent):
```

Logs when a worker starts processing a task.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_updated" />

### log\_task\_updated

```python theme={"system"}
def log_task_updated(self, event: TaskUpdatedEvent):
```

Logs updates made to a task.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_completed" />

### log\_task\_completed

```python theme={"system"}
def log_task_completed(self, event: TaskCompletedEvent):
```

Logs the successful completion of a task.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_failed" />

### log\_task\_failed

```python theme={"system"}
def log_task_failed(self, event: TaskFailedEvent):
```

Logs the failure of a task.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_worker_created" />

### log\_worker\_created

```python theme={"system"}
def log_worker_created(self, event: WorkerCreatedEvent):
```

Logs the creation of a new worker.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_worker_deleted" />

### log\_worker\_deleted

```python theme={"system"}
def log_worker_deleted(self, event: WorkerDeletedEvent):
```

Logs the deletion of a worker.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_queue_status" />

### log\_queue\_status

```python theme={"system"}
def log_queue_status(self, event: QueueStatusEvent):
```

Logs the status of a task queue.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_all_tasks_completed" />

### log\_all\_tasks\_completed

```python theme={"system"}
def log_all_tasks_completed(self, event: AllTasksCompletedEvent):
```

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.reset_task_data" />

### reset\_task\_data

```python theme={"system"}
def reset_task_data(self):
```

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

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.dump_to_json" />

### dump\_to\_json

```python theme={"system"}
def dump_to_json(self, file_path: str):
```

Dumps all log entries to a JSON file.

**Parameters:**

* **file\_path** (str): The path to the JSON file.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger._get_all_tasks_in_hierarchy" />

### \_get\_all\_tasks\_in\_hierarchy

```python theme={"system"}
def _get_all_tasks_in_hierarchy(self, task_id: str):
```

Recursively collect all tasks in the hierarchy starting from
task\_id.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger._get_task_tree_string" />

### \_get\_task\_tree\_string

```python theme={"system"}
def _get_task_tree_string(
    self,
    task_id: str,
    prefix: str = '',
    is_last: bool = True
):
```

Generate a string representation of the task tree.

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.get_ascii_tree_representation" />

### get\_ascii\_tree\_representation

```python theme={"system"}
def get_ascii_tree_representation(self):
```

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

<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.get_kpis" />

### get\_kpis

```python theme={"system"}
def get_kpis(self):
```

Calculates and returns key performance indicators from the logs.
