class CoroutineLogger extends Logger

Logger implementation for coroutine-based Task execution.

Instead of writing to a socket for IPC (which requires pcntl_fork), this logger writes directly to the Task instance's shared state. This is safe because Swoole coroutines are cooperatively scheduled within the same thread and share memory.

Properties

protected string $streamBuffer

The buffer for streaming text.

from  Logger

Methods

__construct(Task $task)

Create a new CoroutineLogger instance.

void
line(string $message)

Log a line to the task output.

void
partial(string $chunk)

Append a chunk of text, accumulating on the current line(s).

void
commitPartial()

Commit the accumulated partial text and start fresh.

void
success(string $message)

Log a success message.

void
warning(string $message)

Log a warning message.

void
error(string $message)

Log an error message.

void
label(string $message)

Update the task label.

void
subLabel(string $message)

Update the task sub-label. Pass an empty string to clear.

void
write(string $message, string|null $type = null)

Write a message to the socket.

from  Logger
string
prefix(string $type, string $message)

Prefix a message with the identifier and type.

from  Logger

Details

at line 22
__construct(Task $task)

Create a new CoroutineLogger instance.

Parameters

Task $task

at line 30
void line(string $message)

Log a line to the task output.

Parameters

string $message

Return Value

void

at line 78
void partial(string $chunk)

Append a chunk of text, accumulating on the current line(s).

Parameters

string $chunk

Return Value

void

at line 87
void commitPartial()

Commit the accumulated partial text and start fresh.

Return Value

void

at line 38
void success(string $message)

Log a success message.

Parameters

string $message

Return Value

void

at line 46
void warning(string $message)

Log a warning message.

Parameters

string $message

Return Value

void

at line 54
void error(string $message)

Log an error message.

Parameters

string $message

Return Value

void

at line 62
void label(string $message)

Update the task label.

Parameters

string $message

Return Value

void

at line 70
void subLabel(string $message)

Update the task sub-label. Pass an empty string to clear.

Parameters

string $message

Return Value

void

in Logger at line 92
protected void write(string $message, string|null $type = null)

Write a message to the socket.

Parameters

string $message
string|null $type

Return Value

void

in Logger at line 108
protected string prefix(string $type, string $message)

Prefix a message with the identifier and type.

Parameters

string $type
string $message

Return Value

string