logging
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¶
Index¶
- Constants
- Variables
- func IsDebugOrHigher() bool
- func LogLevel() string
- func LogOutput(t testing.T) (logOutput io.Writer, err error)
- func NewLoggingHTTPTransport(t http.RoundTripper) *loggingHttpTransport
- func NewSubsystemLoggingHTTPTransport(subsystem string, t http.RoundTripper) *loggingHttpTransport
- func NewTransport(name string, t http.RoundTripper) *transportdeprecated
- func SetOutput(t testing.T)
Constants¶
const (EnvLog = "TF_LOG"// See ValidLevelsEnvLogFile = "TF_LOG_PATH"// Set to a fileEnvAccLogFile = "TF_ACC_LOG_PATH"// Set to a file// EnvLogPathMask splits test log files by name.EnvLogPathMask = "TF_LOG_PATH_MASK")
These are the environmental variables that determine if we log, and ifwe log whether or not the log should go to a file.
const (// FieldHttpOperationType is the field key used by NewLoggingHTTPTransport// and NewSubsystemLoggingHTTPTransport when logging the type of HTTP operation via tflog.FieldHttpOperationType = "tf_http_op_type"// OperationHttpRequest is the field value used by NewLoggingHTTPTransport// and NewSubsystemLoggingHTTPTransport when logging an HTTP request via tflog.OperationHttpRequest = "request"// OperationHttpResponse is the field value used by NewLoggingHTTPTransport// and NewSubsystemLoggingHTTPTransport when logging an HTTP response via tflog.OperationHttpResponse = "response"// FieldHttpRequestMethod is the field key used by NewLoggingHTTPTransport// and NewSubsystemLoggingHTTPTransport when logging an HTTP request method via tflog.FieldHttpRequestMethod = "tf_http_req_method"// FieldHttpRequestUri is the field key used by NewLoggingHTTPTransport// and NewSubsystemLoggingHTTPTransport when logging an HTTP request URI via tflog.FieldHttpRequestUri = "tf_http_req_uri"// FieldHttpRequestProtoVersion is the field key used by NewLoggingHTTPTransport// and NewSubsystemLoggingHTTPTransport when logging an HTTP request HTTP version via tflog.FieldHttpRequestProtoVersion = "tf_http_req_version"// FieldHttpRequestBody is the field key used by NewLoggingHTTPTransport// and NewSubsystemLoggingHTTPTransport when logging an HTTP request body via tflog.FieldHttpRequestBody = "tf_http_req_body"// FieldHttpResponseProtoVersion is the field key used by NewLoggingHTTPTransport// and NewSubsystemLoggingHTTPTransport when logging an HTTP response protocol version via tflog.FieldHttpResponseProtoVersion = "tf_http_res_version"// FieldHttpResponseStatusCode is the field key used by NewLoggingHTTPTransport// and NewSubsystemLoggingHTTPTransport when logging an HTTP response status code via tflog.FieldHttpResponseStatusCode = "tf_http_res_status_code"// FieldHttpResponseStatusReason is the field key used by NewLoggingHTTPTransport// and NewSubsystemLoggingHTTPTransport when logging an HTTP response status reason phrase via tflog.FieldHttpResponseStatusReason = "tf_http_res_status_reason"// FieldHttpResponseBody is the field key used by NewLoggingHTTPTransport// and NewSubsystemLoggingHTTPTransport when logging an HTTP response body via tflog.FieldHttpResponseBody = "tf_http_res_body"// FieldHttpTransactionId is the field key used by NewLoggingHTTPTransport// and NewSubsystemLoggingHTTPTransport when logging an HTTP transaction via tflog.FieldHttpTransactionId = "tf_http_trans_id")
Variables¶
var ValidLevels = []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERROR"}Functions¶
funcIsDebugOrHigher¶
func IsDebugOrHigher()bool
IsDebugOrHigher returns whether or not the current log level is debug or trace
funcLogLevel¶
func LogLevel()string
LogLevel returns the current log level string based the environment vars
funcLogOutput¶
LogOutput determines where we should send logs (if anywhere) and the loglevel. This only effects this log.Print* functions called in the providerunder test. Dependency providers for the provider under test will have theirlogging controlled by Terraform itself and managed with the TF_ACC_LOG_PATHenvironment variable. Calls to tflog.* will have their output managed by thetfsdklog sink.
funcNewLoggingHTTPTransport¶added inv2.20.0
func NewLoggingHTTPTransport(thttp.RoundTripper) *loggingHttpTransport
NewLoggingHTTPTransport creates a wrapper around an *http.RoundTripper,designed to be used for the `Transport` field of http.Client.
This logs each pair of HTTP request/response that it handles.The logging is done via `tflog`, that is part of the terraform-plugin-loglibrary, included by this SDK.
The request/response is logged via tflog.Debug, using the context.Contextattached to the http.Request that the transport receives as inputof http.RoundTripper RoundTrip method.
It's responsibility of the developer using this transport, to ensure that eachhttp.Request it handles is configured with the SDK-initialized Provider Root Loggercontext.Context, that it's passed to all resources/data-sources/provider entry-points(i.e. schema.Resource fields like `CreateContext`, `ReadContext`, etc.).
This also gives the developer the flexibility to further configure thelogging behaviour via the above-mentioned context: please seehttps://www.terraform.io/plugin/log/writing.
funcNewSubsystemLoggingHTTPTransport¶added inv2.20.0
func NewSubsystemLoggingHTTPTransport(subsystemstring, thttp.RoundTripper) *loggingHttpTransport
NewSubsystemLoggingHTTPTransport creates a wrapper around an *http.RoundTripper,designed to be used for the `Transport` field of http.Client.
This logs each pair of HTTP request/response that it handles.The logging is done via `tflog`, that is part of the terraform-plugin-loglibrary, included by this SDK.
The request/response is logged via tflog.SubsystemDebug, using the context.Contextattached to the http.Request that the transport receives as inputof http.RoundTripper RoundTrip method, as well as the `subsystem` stringprovided at construction time.
It's responsibility of the developer using this transport, to ensure that eachhttp.Request it handles is configured with a Subsystem Loggercontext.Context that was initialized via tflog.NewSubsystem.
This also gives the developer the flexibility to further configure thelogging behaviour via the above-mentioned context: please seehttps://www.terraform.io/plugin/log/writing.
Please note: setting `subsystem` to an empty string it's equivalent tousing NewLoggingHTTPTransport.
funcNewTransportdeprecated
func NewTransport(namestring, thttp.RoundTripper) *transport
NewTransport creates a wrapper around a *http.RoundTripper,designed to be used for the `Transport` field of http.Client.
This logs each pair of HTTP request/response that it handles.The logging is done via Go standard library `log` package.
Deprecated: This will log the content of every http request/responseat `[DEBUG]` level, without any filtering. Any sensitive informationwill appear as-is in your logs. Please use NewSubsystemLoggingHTTPTransport instead.
Types¶
This section is empty.