Documentation
¶
Index ¶
- func Criticalc(ctx context.Context, code int, format string, args ...interface{}) error
- func Criticale(ctx context.Context, format string, args ...interface{}) error
- func Criticalf(ctx context.Context, format string, args ...interface{})
- func Criticalm(ctx context.Context, method string, err error)
- func Debugc(ctx context.Context, code int, format string, args ...interface{}) error
- func Debuge(ctx context.Context, format string, args ...interface{}) error
- func Debugf(ctx context.Context, format string, args ...interface{})
- func Debugm(ctx context.Context, method string, err error)
- func Errorc(ctx context.Context, code int, format string, args ...interface{}) error
- func Errore(ctx context.Context, format string, args ...interface{}) error
- func Errorf(ctx context.Context, format string, args ...interface{})
- func Errorm(ctx context.Context, method string, err error)
- func Infoc(ctx context.Context, code int, format string, args ...interface{}) error
- func Infoe(ctx context.Context, format string, args ...interface{}) error
- func Infof(ctx context.Context, format string, args ...interface{})
- func Infom(ctx context.Context, method string, err error)
- func Panic(ctx context.Context, rcvr interface{}) string
- func SetLogger(ctx context.Context, logger *Logger) context.Context
- func SetResponseStatus(ctx context.Context, status int)
- func Warningc(ctx context.Context, code int, format string, args ...interface{}) error
- func Warninge(ctx context.Context, format string, args ...interface{}) error
- func Warningf(ctx context.Context, format string, args ...interface{})
- func Warningm(ctx context.Context, method string, err error)
- type Duration
- type Entry
- type EntryChild
- type EntryHTTPRequest
- type EntrySourceLocation
- type Logger
- type Middleware
- type Severity
- type Time
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetResponseStatus ¶
SetResponseStatus ... レスポンスのステータスコードを設定する
Types ¶
type Duration ¶
Duration ... ProtocolBufferのフォーマット
func (Duration) MarshalJSON ¶
MarshalJSON ... JSONに変換
type Entry ¶
type Entry struct {
Severity string `json:"severity"`
HTTPRequest *EntryHTTPRequest `json:"httpRequest,omitempty"`
Time Time `json:"time"`
Trace string `json:"logging.googleapis.com/trace"`
TraceID string `json:"traceId"`
Childs []*EntryChild `json:"childs"`
Message string `json:"message,omitempty"`
}
Entry ... 構造ログ定義 https://cloud.google.com/logging/docs/agent/configuration#special-fields
type EntryChild ¶
type EntryChild struct {
Severity string `json:"severity"`
Message string `json:"message"`
Time Time `json:"time"`
}
EntryChild ... 子ログの構造ログ定義
type EntryHTTPRequest ¶
type EntryHTTPRequest struct {
RequestMethod string `json:"requestMethod"`
RequestURL string `json:"requestUrl"`
RequestSize int64 `json:"requestSize,string,omitempty"`
Status int `json:"status"`
ResponseSize int64 `json:"responseSize,string,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
Referer string `json:"referer,omitempty"`
Latency Duration `json:"latency,omitempty"`
CacheLookup *bool `json:"cacheLookup,omitempty"`
CacheHit *bool `json:"cacheHit,omitempty"`
CacheValidatedWithOriginServer *bool `json:"cacheValidatedWithOriginServer,omitempty"`
CacheFillBytes *int64 `json:"cacheFillBytes,string,omitempty"`
Protocol string `json:"protocol"`
}
EntryHTTPRequest ... HTTPリクエストの構造ログ定義 https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#httprequest
type EntrySourceLocation ¶
type EntrySourceLocation struct {
File string `json:"file,omitempty"`
Line int64 `json:"line,string,omitempty"`
Function string `json:"function,omitempty"`
}
EntrySourceLocation ... SourceLocationの構造ログ定義 https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#logentrysourcelocation
type Logger ¶
type Logger struct {
Writer Writer
MinOutSeverity Severity
MaxOuttedSeverity Severity
TraceID string
ResponseStatus int
ApplicationLogs []*EntryChild
}
Logger ... ロガー
func (*Logger) AddApplicationLog ¶
func (l *Logger) AddApplicationLog(severity Severity, file string, line int64, function string, msg string, at time.Time)
AddApplicationLog ... アプリケーションログ履歴を記録する
func (*Logger) SetOuttedSeverity ¶
SetOuttedSeverity ... 出力された最大のレベルを設定
type Middleware ¶
Middleware ... ロガー
func NewMiddleware ¶
func NewMiddleware(writer Writer, minOutSeverity string) *Middleware
NewMiddleware ... ミドルウェアを作成する
type Severity ¶
type Severity int
Severity ... ログレベル spec: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#logseverity
const ( // SeverityDefault ... ログレベル: Default SeverityDefault Severity = 0 // SeverityDebug ... ログレベル: Debug SeverityDebug Severity = 100 // SeverityInfo ... ログレベル: Info SeverityInfo Severity = 200 // SeverityWarning ... ログレベル: Warning SeverityWarning Severity = 400 // SeverityError ... ログレベル: Error SeverityError Severity = 500 // SeverityCritical ... ログレベル: Critical SeverityCritical Severity = 600 )
type Writer ¶
type Writer interface {
Request(
severity Severity,
traceID string,
applicationLogs []*EntryChild,
r *http.Request,
status int,
at time.Time,
dr time.Duration)
Application(
severity Severity,
traceID string,
msg string,
file string,
line int64,
function string,
at time.Time)
}
Writer ... ログの出力
func NewWriterStackdriver ¶
NewWriterStackdriver ... ログ出力を作成する