logpolicy
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
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¶
- func LogHost() stringdeprecated
- func LogURL() string
- func LogsDir(logf logger.Logf) string
- func MakeDialFunc(netMon *netmon.Monitor, logf logger.Logf) netx.DialFunc
- func NewLogtailTransport(host string, netMon *netmon.Monitor, health *health.Tracker, logf logger.Logf) http.RoundTripperdeprecated
- type Config
- type Options
- type Policy
- type TransportOptions
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcLogURL¶added 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.
funcLogsDir¶added inv1.38.0
LogsDir returns the directory to use for log configuration andbuffer storage.
funcMakeDialFunc¶added inv1.40.0
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¶
Config represents an instance of logs in a collection.
funcConfigFromBytes¶
ConfigFromBytes parses a Config from its JSON encoding.
funcConfigFromFile¶added inv1.28.0
ConfigFromFile reads a Config from a JSON file.
funcNewConfig¶added inv1.28.0
NewConfig creates a Config with collection and a newly generated PrivateID.
typeOptions¶added 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.
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.
func (*Policy)SetVerbosityLevel¶added inv1.4.0
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.
typeTransportOptions¶added 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)New¶added inv1.80.0
func (optsTransportOptions) New()http.RoundTripper
New returns an HTTP Transport particularly suited to uploading logsto the given host name. See [DialContext] for details on how it works.