gdDocumentation0.8.0

API reference

GD.log

Entry for ordered I/O of one line at a time with a consistent level, time, and destination. flush waits for earlier output.

Methods

setup

setup(name: String = "", level: String = "info") -> void

Set the logger name and minimum level.

Parameters

NameTypeDefaultDescription
nameString""Name used to register or look up the corresponding entry.
levelString"info"Minimum or selected log severity name.

Return value

void

No value is returned.

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

set_file

set_file(path: String) -> void

Set the file receiving appended log lines.

Parameters

NameTypeDefaultDescription
pathStringRequiredFilesystem path; relative paths use the execution directory and access follows configured permissions.

Return value

void

No value is returned.

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

set_time

set_time(on: bool) -> void

Configure whether log lines include a timestamp.

Parameters

NameTypeDefaultDescription
onboolRequiredTrue enables the setting; false disables it.

Return value

void

No value is returned.

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

set_color

set_color(on: bool) -> void

Configure terminal color output.

Parameters

NameTypeDefaultDescription
onboolRequiredTrue enables the setting; false disables it.

Return value

void

No value is returned.

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

write

write(level: String, msg: String, extra: Variant = null) -> Variant, Err

Write a line at a level selected by name.

Parameters

NameTypeDefaultDescription
levelStringRequiredMinimum or selected log severity name.
msgStringRequiredMessage text associated with this operation.
extraVariantnullAdditional structured values to include with the log message.

Return value

Variant, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

debug

debug(msg: String, extra: Variant = null) -> Variant, Err

Write a debug-level line.

Parameters

NameTypeDefaultDescription
msgStringRequiredMessage text associated with this operation.
extraVariantnullAdditional structured values to include with the log message.

Return value

Variant, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

info

info(msg: String, extra: Variant = null) -> Variant, Err

Write an info-level line.

Parameters

NameTypeDefaultDescription
msgStringRequiredMessage text associated with this operation.
extraVariantnullAdditional structured values to include with the log message.

Return value

Variant, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

warn

warn(msg: String, extra: Variant = null) -> Variant, Err

Write a warning-level line.

Parameters

NameTypeDefaultDescription
msgStringRequiredMessage text associated with this operation.
extraVariantnullAdditional structured values to include with the log message.

Return value

Variant, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

error

error(msg: String, extra: Variant = null) -> Variant, Err

Write an error-level line.

Parameters

NameTypeDefaultDescription
msgStringRequiredMessage text associated with this operation.
extraVariantnullAdditional structured values to include with the log message.

Return value

Variant, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

result

result(error: Err, msg: String) -> Variant, Err

Log a failed operation's error.

Parameters

NameTypeDefaultDescription
errorErrRequiredError value to classify when choosing an HTTP status.
msgStringRequiredMessage text associated with this operation.

Return value

Variant, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

write_async

write_async(level: String, msg: String, extra: Variant = null) -> await Variant, Err

Write a line at a level selected by name.

Parameters

NameTypeDefaultDescription
levelStringRequiredMinimum or selected log severity name.
msgStringRequiredMessage text associated with this operation.
extraVariantnullAdditional structured values to include with the log message.

Return value

await Variant, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

debug_async

debug_async(msg: String, extra: Variant = null) -> await Variant, Err

Write a debug-level line.

Parameters

NameTypeDefaultDescription
msgStringRequiredMessage text associated with this operation.
extraVariantnullAdditional structured values to include with the log message.

Return value

await Variant, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

info_async

info_async(msg: String, extra: Variant = null) -> await Variant, Err

Write an info-level line.

Parameters

NameTypeDefaultDescription
msgStringRequiredMessage text associated with this operation.
extraVariantnullAdditional structured values to include with the log message.

Return value

await Variant, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

warn_async

warn_async(msg: String, extra: Variant = null) -> await Variant, Err

Write a warning-level line.

Parameters

NameTypeDefaultDescription
msgStringRequiredMessage text associated with this operation.
extraVariantnullAdditional structured values to include with the log message.

Return value

await Variant, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

error_async

error_async(msg: String, extra: Variant = null) -> await Variant, Err

Write an error-level line.

Parameters

NameTypeDefaultDescription
msgStringRequiredMessage text associated with this operation.
extraVariantnullAdditional structured values to include with the log message.

Return value

await Variant, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

result_async

result_async(error: Err, msg: String) -> await Variant, Err

Log a failed operation's error.

Parameters

NameTypeDefaultDescription
errorErrRequiredError value to classify when choosing an HTTP status.
msgStringRequiredMessage text associated with this operation.

Return value

await Variant, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

format

format(level: String, msg: String, extra: Variant = null) -> String

Format a log line without writing it.

Parameters

NameTypeDefaultDescription
levelStringRequiredMinimum or selected log severity name.
msgStringRequiredMessage text associated with this operation.
extraVariantnullAdditional structured values to include with the log message.

Return value

String

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

flush

flush() -> Variant, Err

Return a signal after preceding file output completes.

Parameters

No parameters.

Return value

Variant, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

flush_async

flush_async() -> await Variant, Err

Return a signal after preceding file output completes.

Parameters

No parameters.

Return value

await Variant, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.