Documentation
¶
Overview ¶
Package gaelog provides easy Stackdriver Logging on Google App Engine Standard second generation runtimes.
Index ¶
- Constants
- type Logger
- func (lg *Logger) Alert(v interface{})
- func (lg *Logger) Alertf(format string, v ...interface{})
- func (lg *Logger) Close() error
- func (lg *Logger) Critical(v interface{})
- func (lg *Logger) Criticalf(format string, v ...interface{})
- func (lg *Logger) Debug(v interface{})
- func (lg *Logger) Debugf(format string, v ...interface{})
- func (lg *Logger) Emergency(v interface{})
- func (lg *Logger) Emergencyf(format string, v ...interface{})
- func (lg *Logger) Error(v interface{})
- func (lg *Logger) Errorf(format string, v ...interface{})
- func (lg *Logger) Info(v interface{})
- func (lg *Logger) Infof(format string, v ...interface{})
- func (lg *Logger) Log(severity logging.Severity, v interface{})
- func (lg *Logger) Logf(severity logging.Severity, format string, v ...interface{})
- func (lg *Logger) Notice(v interface{})
- func (lg *Logger) Noticef(format string, v ...interface{})
- func (lg *Logger) Warning(v interface{})
- func (lg *Logger) Warningf(format string, v ...interface{})
Constants ¶
const ( // DefaultLogID is the default log ID of the underlying Stackdriver Logging logger. Request // logs are logged under the ID "request_log", so use "app_log" for consistency. To use a // different ID create your logger with NewWithID. DefaultLogID = "app_log" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
A Logger logs messages to Stackdriver Logging (though in certain cases it may fall back to the standard library's "log" package; see New). Logs will be correlated with requests in Stackdriver.
func NewWithID ¶
NewWithID creates a new Logger. The Logger is initialized using environment variables that are present on App Engine:
- GOOGLE_CLOUD_PROJECT
- GAE_SERVICE
- GAE_VERSION
The given log ID will be passed through to the underlying Stackdriver Logging logger.
Additionally, options (of type LoggerOption, from cloud.google.com/go/logging) will be passed through to the underlying Stackdriver Logging logger. Note that the option CommonResource will have no effect because the MonitoredResource is set when each log entry is made, thus overriding any value set with CommonResource. This is intended: much of the value of this package is in setting up the MonitoredResource so that log entries correlate with requests.
The Logger will be valid in all cases, even when the error is non-nil. In the case of a non-nil error the Logger will fall back to the standard library's "log" package. There are three cases in which the error will be non-nil:
- Any of the aforementioned environment variables are not set.
- The given http.Request does not have the X-Cloud-Trace-Context header.
- Initialization of the underlying Stackdriver Logging client produced an error.
func (*Logger) Close ¶
Close closes the Logger, ensuring all logs are flushed and closing the underlying Stackdriver Logging client.
func (*Logger) Critical ¶
func (lg *Logger) Critical(v interface{})
Critical calls Log with critical severity.
func (*Logger) Emergency ¶
func (lg *Logger) Emergency(v interface{})
Emergency calls Log with emergency severity.
func (*Logger) Emergencyf ¶
Emergencyf calls Logf with emergency severity.
func (*Logger) Log ¶
Log logs with the given severity. v must be either a string, or something that marshals via the encoding/json package to a JSON object (and not any other type of JSON value).
func (*Logger) Logf ¶
Logf logs with the given severity. Remaining arguments are handled in the manner of fmt.Printf.
func (*Logger) Notice ¶
func (lg *Logger) Notice(v interface{})
Notice calls Log with notice severity.