{"modulePath":"github.com/coder/envbuilder","version":"v1.3.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package log\n\n## Constants\n\n```go\nconst (\n\tLevelTrace = Level(codersdk.LogLevelTrace)\n\tLevelDebug = Level(codersdk.LogLevelDebug)\n\tLevelInfo  = Level(codersdk.LogLevelInfo)\n\tLevelWarn  = Level(codersdk.LogLevelWarn)\n\tLevelError = Level(codersdk.LogLevelError)\n)\n```\nBelow constants are the same as their codersdk equivalents.\n\n## Functions\n\n```go\nfunc HijackLogrus(lvl Level, callback func(entry *logrus.Entry))\n```\nHijackLogrus hijacks the logrus logger and calls the callback for each log entry. This is an abuse of logrus, the package that Kaniko uses, but it exposes no other way to obtain the log entries.\n\n```go\nfunc ToLogrus(lvl Level) logrus.Level\n```\n\n```go\nfunc Writer(logf Func) (io.Writer, func())\n```\nWriter returns an io.Writer that logs all writes in a separate goroutine. It is the responsibility of the caller to call the returned function to stop the goroutine.\n\n## Types\n\n```go\ntype Func func(l Level, msg string, args ...any)\n```\n\n```go\nfunc Coder(ctx context.Context, coderURL *url.URL, token string) (logger Func, closer func(), err error)\n```\nCoder establishes a connection to the Coder instance located at coderURL and authenticates using token. It then establishes a dRPC connection to the Agent API and begins sending logs. If the version of Coder does not support the Agent API, it will fall back to using the PatchLogs endpoint. The closer is used to close the logger and to wait at most logSendGracePeriod for logs to be sent. Cancelling the context will close the logs immediately without waiting for logs to be sent.\n\n```go\nfunc New(w io.Writer, verbose bool) Func\n```\nNew logs to the provided io.Writer.\n\n```go\nfunc Wrap(fs ...Func) Func\n```\nWrap wraps the provided LogFuncs into a single Func.\n\n```go\ntype Level string\n```\n\n```go\nfunc FromLogrus(lvl logrus.Level) Level\n```\n\n","path":"github.com/coder/envbuilder/log","name":"log","synopsis":"","isRedistributable":true}
