LogEndpoint

Classin logfastly-compute 0.1.3View source

Extends FastlyResource[wit_log.Endpoint].

Interface to a Fastly logging endpoint.

Logging endpoints send log data to configured Real-Time Log Streaming destinations. Configure endpoints through the Fastly web interface or API.

with LogEndpoint.open("my_logs") as endpoint:
endpoint.write("Application started")
endpoint.write(b"Binary log data")

Methods

open

staticView source
open(name: str) -> Self

Open a logging endpoint by name.

Names are case sensitive. Calling open() with a name that doesn't correspond to any logging endpoint available in your service will still return a usable endpoint, and writes to that endpoint will succeed. Refer to your service dashboard to diagnose missing log events.

Currently, the conditions on an endpoint name are:

  • It must not be empty.
  • It must not contain newlines (\n) or colons (:).
  • It must not be stdout or stderr, which are reserved for debugging.

Parameters

name: str

The name of the logging endpoint

Returns

Self

LogEndpoint instance

Throws

endpoint = LogEndpoint.open("my_logs")
write(msg: bytes | str) -> None

Write data to the logging endpoint.

Each call to write() with a non-empty message produces a single log event.

Parameters

msg: bytes | str

The message to write (bytes or string). Strings are UTF-8 encoded.

Returns

None
endpoint = LogEndpoint.open("my_logs")
endpoint.write("Text message")
endpoint.write(b"Binary data")