About this project
slogcp is a specialized `slog.Handler` for Go applications designed to integrate seamlessly with Google Cloud's observability stack. It allows developers to continue using the standard library's `log/slog` API while automatically emitting structured JSON logs compatible with Google Cloud Logging. This library is particularly useful for microservices running on Cloud Run, Cloud Functions, GKE, App Engine, or Compute Engine.
Key features include automatic correlation with Cloud Trace via OpenTelemetry span context, support for Cloud Error Reporting with proper stack traces and service context, and built-in middleware for HTTP and gRPC services to derive request-scoped loggers. It also provides Pub/Sub integration for trace propagation across message queues. By writing directly to stdout/stderr, slogcp leverages GCP's native log ingestion, reducing CPU overhead compared to using the official Cloud Logging client library. It supports dynamic level control, attribute rewriting, and integrates easily with other slog-based tools like masq for redaction and timberjack for log rotation.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.