Documentation ¶
Overview ¶
Package logtail sends logs to log.tailscale.io.
Index ¶
- Constants
- func Disable()
- type Buffer
- type Config
- type Encoder
- type Logger
- func (l *Logger) Close()deprecated
- func (l *Logger) Flush() error
- func (l *Logger) Logf(format string, args ...any)
- func (l *Logger) PrivateID() PrivateID
- func (l *Logger) SetLinkMonitor(lm *monitor.Mon)
- func (l *Logger) SetVerbosityLevel(level int)
- func (l *Logger) Shutdown(ctx context.Context) error
- func (l *Logger) Write(buf []byte) (int, error)
- type PrivateID
- type PublicID
Constants ¶
const ( // CollectionNode is the name of a logtail Config.Collection // for tailscaled (or equivalent: IPNExtension, Android app). CollectionNode = "tailnode.log.tailscale.io" )
const DefaultHost = "log.tailscale.io"
DefaultHost is the default host name to upload logs to when Config.BaseURL isn't provided.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Buffer ¶
type Buffer interface { // TryReadLine tries to read a log line from the ring buffer. // If no line is available it returns a nil slice. // If the ring buffer is closed it returns io.EOF. // // The returned slice may point to data that will be overwritten // by a subsequent call to TryReadLine. TryReadLine() ([]byte, error) // Write writes a log line into the ring buffer. // // Write takes ownership of the provided slice. Write([]byte) (int, error) }
func NewMemoryBuffer ¶
type Config ¶
type Config struct { Collection string // collection name, a domain name PrivateID PrivateID // private ID for the primary log stream CopyPrivateID PrivateID // private ID for a log stream that is a superset of this log stream BaseURL string // if empty defaults to "https://log.tailscale.io" HTTPC *http.Client // if empty defaults to http.DefaultClient SkipClientTime bool // if true, client_time is not written to logs LowMemory bool // if true, logtail minimizes memory use TimeNow func() time.Time // if set, substitutes uses of time.Now Stderr io.Writer // if set, logs are sent here instead of os.Stderr StderrLevel int // max verbosity level to write to stderr; 0 means the non-verbose messages only Buffer Buffer // temp storage, if nil a MemoryBuffer NewZstdEncoder func() Encoder // if set, used to compress logs for transmission // MetricsDelta, if non-nil, is a func that returns an encoding // delta in clientmetrics to upload alongside existing logs. // It can return either an empty string (for nothing) or a string // that's safe to embed in a JSON string literal without further escaping. MetricsDelta func() string // FlushDelay is how long to wait to accumulate logs before // uploading them. // // If zero, a default value is used. (currently 2 seconds) // // Negative means to upload immediately. FlushDelay time.Duration // IncludeProcID, if true, results in an ephemeral process identifier being // included in logs. The ID is random and not guaranteed to be globally // unique, but it can be used to distinguish between different instances // running with same PrivateID. IncludeProcID bool // IncludeProcSequence, if true, results in an ephemeral sequence number // being included in the logs. The sequence number is incremented for each // log message sent, but is not persisted across process restarts. IncludeProcSequence bool }
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger writes logs, splitting them as configured between local logging facilities and uploading to a log server.
func (*Logger) Flush ¶
Flush uploads all logs to the server. It blocks until complete or there is an unrecoverable error.
func (*Logger) PrivateID ¶
PrivateID returns the logger's private log ID.
It exists for internal use only.
func (*Logger) SetLinkMonitor ¶
SetLinkMonitor sets the optional the link monitor.
It should not be changed concurrently with log writes and should only be set once.
func (*Logger) SetVerbosityLevel ¶
SetVerbosityLevel controls the verbosity level that should be written to stderr. 0 is the default (not verbose). Levels 1 or higher are increasingly verbose.
type PrivateID ¶
type PrivateID [32]byte
PrivateID represents an instance that write logs. Private IDs are only shared with the server when writing logs.
func NewPrivateID ¶
Safely generate a new PrivateId for use in Config objects. You should persist this across runs of an instance of your app, so that it can append to the same log file on each run.
func ParsePrivateID ¶
ParsePrivateID returns a PrivateID from its hex (String) representation.
func (PrivateID) MarshalText ¶
func (*PrivateID) UnmarshalText ¶
type PublicID ¶
PublicID represents an instance in the logs service for reading and adoption. The public ID value is a SHA-256 hash of a private ID.
func MustParsePublicID ¶
MustParsePublicID calls ParsePublicID and panics in case of an error. It is intended for use with constant strings, typically in tests.
func ParsePublicID ¶
ParsePublicID returns a PublicID from its hex (String) representation.
func (PublicID) MarshalText ¶
func (*PublicID) UnmarshalText ¶
Directories ¶
Path | Synopsis |
---|---|
Package backoff provides a back-off timer type.
|
Package backoff provides a back-off timer type. |
example
|
|
logreprocess
The logreprocess program tails a log and reprocesses it.
|
The logreprocess program tails a log and reprocesses it. |
logtail
The logtail program logs stdin.
|
The logtail program logs stdin. |
Package filch is a file system queue that pilfers your stderr.
|
Package filch is a file system queue that pilfers your stderr. |