{"modulePath":"github.com/hyperhq/hypercli","version":"v1.10.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package jsonlog\n\nPackage jsonlog provides helper functions to parse and print time (time.Time) as JSON.\n\n## Constants\n\n```go\nconst (\n\t// RFC3339NanoFixed is our own version of RFC339Nano because we want one\n\t// that pads the nano seconds part with zeros to ensure\n\t// the timestamps are aligned in the logs.\n\tRFC3339NanoFixed = \"2006-01-02T15:04:05.000000000Z07:00\"\n\t// JSONFormat is the format used by FastMarshalJSON\n\tJSONFormat = `\"` + time.RFC3339Nano + `\"`\n)\n```\n\n## Functions\n\n```go\nfunc FastTimeMarshalJSON(t time.Time) (string, error)\n```\nFastTimeMarshalJSON avoids one of the extra allocations that time.MarshalJSON is making.\n\n## Types\n\n```go\ntype JSONLog struct {\n\t// Log is the log message\n\tLog string `json:\"log,omitempty\"`\n\t// Stream is the log source\n\tStream string `json:\"stream,omitempty\"`\n\t// Created is the created timestamp of log\n\tCreated time.Time `json:\"time\"`\n}\n```\nJSONLog represents a log message, typically a single entry from a given log stream. JSONLogs can be easily serialized to and from JSON and support custom formatting.\n\n```go\nfunc (jl *JSONLog) Format(format string) (string, error)\n```\nFormat returns the log formatted according to format If format is nil, returns the log message If format is json, returns the log marshaled in json format By default, returns the log with the log time formatted according to format.\n\n```go\nfunc (mj *JSONLog) MarshalJSON() ([]byte, error)\n```\nMarshalJSON marshals the JSONLog.\n\n```go\nfunc (mj *JSONLog) MarshalJSONBuf(buf *bytes.Buffer) error\n```\nMarshalJSONBuf marshals the JSONLog and stores the result to a bytes.Buffer.\n\n```go\nfunc (jl *JSONLog) Reset()\n```\nReset resets the log to nil.\n\n```go\ntype JSONLogs struct {\n\tLog     []byte `json:\"log,omitempty\"`\n\tStream  string `json:\"stream,omitempty\"`\n\tCreated string `json:\"time\"`\n\n\t// json-encoded bytes\n\tRawAttrs json.RawMessage `json:\"attrs,omitempty\"`\n}\n```\nJSONLogs is based on JSONLog. It allows marshalling JSONLog from Log as \\[]byte and an already marshalled Created timestamp.\n\n```go\nfunc (mj *JSONLogs) MarshalJSONBuf(buf *bytes.Buffer) error\n```\nMarshalJSONBuf is based on the same method from JSONLog It has been modified to take into account the necessary changes.\n\n","path":"github.com/hyperhq/hypercli/pkg/jsonlog","name":"jsonlog","synopsis":"Package jsonlog provides helper functions to parse and print time (time.Time) as JSON.","isRedistributable":true}
