Movatterモバイル変換


[0]ホーム

URL:


logpolicy

package
v1.92.2Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2025 License:BSD-3-ClauseImports:51Imported by:27

Details

Repository

github.com/tailscale/tailscale

Links

Documentation

Overview

Package logpolicy manages the creation or reuse of logtail loggers,caching collection instance state on disk for use on future runs ofprograms on the same machine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcLogHostdeprecatedadded inv1.20.0

func LogHost()string

LogHost returns the hostname only (without port) of the configuredlogtail server, or the default.

Deprecated: Use LogURL instead.

funcLogURLadded inv1.32.0

func LogURL()string

LogURL is the base URL for the configured logtail server, or the default.It is guaranteed to not terminate with any forward slashes.

funcLogsDiradded inv1.38.0

func LogsDir(logflogger.Logf)string

LogsDir returns the directory to use for log configuration andbuffer storage.

funcMakeDialFuncadded inv1.40.0

func MakeDialFunc(netMon *netmon.Monitor, logflogger.Logf)netx.DialFunc

MakeDialFunc creates a net.Dialer.DialContext function specialized for useby logtail.It does the following:

  • If DNS lookup fails, consults the bootstrap DNS list of Tailscale hostnames.
  • If TLS connection fails, try again using LetsEncrypt's built-in root certificate,for the benefit of older OS platforms which might not include it.

The netMon parameter is optional. It should be specified in environments whereTailscaled is manipulating the routing table.

funcNewLogtailTransportdeprecatedadded inv1.20.0

func NewLogtailTransport(hoststring, netMon *netmon.Monitor, health *health.Tracker, logflogger.Logf)http.RoundTripper

Deprecated: UseTransportOptions.New instead.

Types

typeConfig

type Config struct {CollectionstringPrivateIDlogid.PrivateIDPublicIDlogid.PublicID}

Config represents an instance of logs in a collection.

funcConfigFromBytes

func ConfigFromBytes(jsonEnc []byte) (*Config,error)

ConfigFromBytes parses a Config from its JSON encoding.

funcConfigFromFileadded inv1.28.0

func ConfigFromFile(statefilestring) (*Config,error)

ConfigFromFile reads a Config from a JSON file.

funcNewConfigadded inv1.28.0

func NewConfig(collectionstring) *Config

NewConfig creates a Config with collection and a newly generated PrivateID.

func (*Config)Saveadded inv1.28.0

func (c *Config) Save(stateFilestring)error

Save writes the JSON representation of c to stateFile.

func (*Config)ToBytes

func (c *Config) ToBytes() []byte

ToBytes returns the JSON representation of c.

func (*Config)Validateadded inv1.28.0

func (c *Config) Validate(collectionstring)error

Validate verifies that the Config matches the collection,and that the PrivateID and PublicID pair are sensible.

typeOptionsadded inv1.80.0

type Options struct {// Collection is a required collection to upload logs under.// Collection is a namespace for the type logs.// For example, logs for a node use "tailnode.log.tailscale.io".Collectionstring// Dir is an optional directory to store the log configuration.// If empty, [LogsDir] is used.Dirstring// CmdName is an optional name of the current binary.// If empty, [version.CmdName] is used.CmdNamestring// NetMon is an optional parameter for monitoring.// If non-nil, it's used to do faster interface lookups.NetMon *netmon.Monitor// Health is an optional parameter for health status.// If non-nil, it's used to construct the default HTTP client.Health *health.Tracker// Bus is an optional parameter for communication on the eventbus.// If non-nil, it's passed to logtail for use in interface monitoring.// TODO(cmol): Make this non-optional when it's plumbed in by the clients.Bus *eventbus.Bus// Logf is an optional logger to use.// If nil, [log.Printf] will be used instead.Logflogger.Logf// HTTPC is an optional client to use upload logs.// If nil, [TransportOptions.New] is used to construct a new client// with that particular transport sending logs to the default logs server.HTTPC *http.Client// MaxBufferSize is the maximum size of the log buffer.// This controls the amount of logs that can be temporarily stored// before the logs can be successfully upload.// If zero, a default buffer size is chosen.MaxBufferSizeint// MaxUploadSize is the maximum size per upload.// This should only be set by clients that have been authenticated// with the logging service as having a higher upload limit.// If zero, a default upload size is chosen.MaxUploadSizeint}

Options is used to construct aPolicy.

func (Options)Newadded inv1.80.0

func (optsOptions) New() *Policy

New returns a new log policy (a logger and its instance ID).

typePolicy

type Policy struct {// Logtail is the logger.Logtail *logtail.Logger// PublicID is the logger's instance identifier.// It may be the zero value if logging is not in use.PublicIDlogid.PublicID// Logf is where to write informational messages about this Logger.Logflogger.Logf}

Policy is a logger and its public ID.

funcNewdeprecated

func New(collectionstring, netMon *netmon.Monitor, health *health.Tracker, logflogger.Logf) *Policy

Deprecated: UseOptions.New instead.

func (*Policy)Close

func (p *Policy) Close()

Close immediately shuts down the logger.

func (*Policy)SetVerbosityLeveladded inv1.4.0

func (p *Policy) SetVerbosityLevel(levelint)

SetVerbosityLevel controls the verbosity level that should bewritten to stderr. 0 is the default (not verbose). Levels 1 or higherare increasingly verbose.

It should not be changed concurrently with log writes.

func (*Policy)Shutdown

func (p *Policy) Shutdown(ctxcontext.Context)error

Shutdown gracefully shuts down the logger, finishing any currentlog upload if it can be done before ctx is canceled.

typeTransportOptionsadded inv1.80.0

type TransportOptions struct {// Host is the optional hostname of the logs server.// If empty, then [logtail.DefaultHost] is used.Hoststring// NetMon is an optional parameter for monitoring.// If non-nil, it's used to do faster interface lookups.NetMon *netmon.Monitor// Health is an optional parameter for health status.// If non-nil, it's used to construct the default HTTP client.Health *health.Tracker// Logf is an optional logger to use.// If nil, [log.Printf] will be used instead.Logflogger.Logf// TLSClientConfig is an optional TLS configuration to use.// If non-nil, the configuration will be cloned.TLSClientConfig *tls.Config}

TransportOptions is used to construct anhttp.RoundTripper.

func (TransportOptions)Newadded inv1.80.0

New returns an HTTP Transport particularly suited to uploading logsto the given host name. See [DialContext] for details on how it works.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp