Documentation ¶
Index ¶
- Constants
- func GetLink(project string, labels map[string]string) string
- func GetLinkAroundTime(project string, labels map[string]string, t time.Time, duration time.Duration) string
- func ParseURI(uri string) (string, string, bool)
- func RegisterSink(project string, name string, labels map[string]string) error
- type Sink
Constants ¶
const ( Scheme = "gcplogs" SeverityField = "severity" TimeField = "time" MessageField = "message" // TraceField is the field Google Cloud Logging looks for the // trace https://cloud.google.com/logging/docs/structured-logging TraceField = "logging.googleapis.com/trace" )
Variables ¶
This section is empty.
Functions ¶
func GetLink ¶
GetLink returns a link to the Cloud Logging console that shows logs matching the given labels. The link isn't stable because it doesn't pin the time.
func GetLinkAroundTime ¶
func GetLinkAroundTime(project string, labels map[string]string, t time.Time, duration time.Duration) string
GetLinkAroundTime returns a link to the logs query pinned at the specified time. It will show a time window specified by the duration around the time. Duration is rounded to the nearest second, minute or hour depending on its size
Types ¶
type Sink ¶
type Sink struct { // Set client if you want the sink to take ownership of the client and call close // If you don't then you must call Client.Close to flush the logs Client *logging.Client Logger *logging.Logger }
Sink implements zap.Sink interface. This lets zap send logs to Cloud Logging.
To use the sink:
Call RegisterSink; this will register register the sink with zap
Create a zap logger configuration in which the output path uses the URL gcplogs:///projects/${PROJECT}/logs/${LOGNAME}
For example: c. := zap.NewProductionConfig() c.OutputPaths = []string{"gcplogs:///projects/${PROJECT}/logs/${LOGNAME}", "stdout"}