Documentation
¶
Overview ¶
Package logpolicy manages the creation or reuse of logtail loggers, caching collection instance state on disk for use on future runs of programs 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) func(ctx context.Context, netw, addr string) (net.Conn, error)
- func NewLogtailTransport(host string, netMon *netmon.Monitor, health *health.Tracker, logf logger.Logf) http.RoundTripper
- type Config
- type Policy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogURL ¶ added in v1.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.
func LogsDir ¶ added in v1.38.0
LogsDir returns the directory to use for log configuration and buffer storage.
func MakeDialFunc ¶ added in v1.40.0
func MakeDialFunc(netMon *netmon.Monitor, logf logger.Logf) func(ctx context.Context, netw, addr string) (net.Conn, error)
MakeDialFunc creates a net.Dialer.DialContext function specialized for use by 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 where Tailscaled is manipulating the routing table.
func NewLogtailTransport ¶ added in v1.20.0
func NewLogtailTransport(host string, netMon *netmon.Monitor, health *health.Tracker, logf logger.Logf) http.RoundTripper
NewLogtailTransport returns an HTTP Transport particularly suited to uploading logs to the given host name. See DialContext for details on how it works.
The netMon parameter is optional. It should be specified in environments where Tailscaled is manipulating the routing table.
The logf parameter is optional; if non-nil, logs are printed using the provided function; if nil, log.Printf will be used instead.
Types ¶
type Config ¶
Config represents an instance of logs in a collection.
func ConfigFromBytes ¶
ConfigFromBytes parses a Config from its JSON encoding.
func ConfigFromFile ¶ added in v1.28.0
ConfigFromFile reads a Config from a JSON file.
func NewConfig ¶ added in v1.28.0
NewConfig creates a Config with collection and a newly generated PrivateID.
type Policy ¶
type Policy struct { // Logtail is the logger. Logtail *logtail.Logger // PublicID is the logger's instance identifier. PublicID logid.PublicID // Logf is where to write informational messages about this Logger. Logf logger.Logf }
Policy is a logger and its public ID.
func New ¶
func New(collection string, netMon *netmon.Monitor, health *health.Tracker, logf logger.Logf) *Policy
New returns a new log policy (a logger and its instance ID) for a given collection name.
The netMon parameter is optional. It should be specified in environments where Tailscaled is manipulating the routing table.
The logf parameter is optional; if non-nil, information logs (e.g. when migrating state) are sent to that logger, and global changes to the log package are avoided. If nil, logs will be printed using log.Printf.
func NewWithConfigPath ¶ added in v1.32.0
func NewWithConfigPath(collection, dir, cmdName string, netMon *netmon.Monitor, health *health.Tracker, logf logger.Logf) *Policy
NewWithConfigPath is identical to New, but uses the specified directory and command name. If either is empty, it derives them automatically.
The netMon parameter is optional. It should be specified in environments where Tailscaled is manipulating the routing table.
func (*Policy) SetVerbosityLevel ¶ added in v1.4.0
SetVerbosityLevel controls the verbosity level that should be written to stderr. 0 is the default (not verbose). Levels 1 or higher are increasingly verbose.
It should not be changed concurrently with log writes.