{"modulePath":"github.com/effective-security/xlog","version":"v1.0.71","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package stackdriver\n\nPackage stackdriver provides xlog's Google Cloud Logging (formerly Stackdriver) formatter. It writes local JSON records; it does not upload logs or provide a Cloud Logging client.\n\nExample:\n\n\tformatter := stackdriver.NewFormatter(os.Stdout, \"app\")\n\txlog.SetFormatter(formatter)\n\tlogger := xlog.NewPackageLogger(\"example.com/app\", \"main\")\n\tlogger.KV(xlog.INFO, \"attempt\", 1)\n\nOutput fields include logName, component, timestamp, severity, message (an object), and sourceLocation. TRACE and DEBUG both map to DEBUG. Configure options before logging. Values use JSON encoding: strings retain their type, integers remain JSON numbers, durations and display enums become strings, and custom JSON marshalers control their representation. The formatter also implements xlog.ErrorFormatter to report encoding and destination failures.\n\n## Variables\n\n```go\nvar MaxLogMessageLength = 2 * 1024\n```\nMaxLogMessageLength limits plain messages in bytes before appending \"...\". It does not limit KV fields. Configure it before logging; negative values panic when formatting a message. This is independent of xlog.FormatMaxLogLength.\n\n## Functions\n\n```go\nfunc NewFormatter(w io.Writer, logName string, ops ...xlog.FormatterOption) xlog.Formatter\n```\nNewFormatter returns a Stackdriver formatter for xlog, writing log entries as Stackdriver-compatible JSON. logName sets the Stackdriver log name. Options apply before the destination is bound, so xlog.WithSink takes effect immediately and delivers rendered records on the sink worker.\n\n```go\nfunc String(value any) string\n```\nString returns JSON without HTML escaping. Errors without json.Marshaler support use their detailed text. Encoding failures are ignored and return an empty string. This helper is separate from the formatter's KV encoding.\n\n","path":"github.com/effective-security/xlog/stackdriver","name":"stackdriver","synopsis":"Package stackdriver provides xlog's Google Cloud Logging (formerly Stackdriver) formatter.","isRedistributable":true}
