LogEndpoint
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 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
stdoutorstderr, which are reserved for debugging.
Parameters
- name: str
The name of the logging endpoint
Returns
LogEndpoint instance
Throws
- NotFound — If the endpoint doesn't exist or can't be created.
- NameTooLong — If the name is too long.
- InvalidSyntax — If the name is invalid.
endpoint = LogEndpoint.open("my_logs")write
View sourcewrite(msg: bytes | str) -> NoneWrite 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
endpoint = LogEndpoint.open("my_logs")endpoint.write("Text message")endpoint.write(b"Binary data")