Documentation ¶
Index ¶
- func Critical(ctx context.Context, err error)
- func Criticalc(ctx context.Context, code int, format string, args ...any) error
- func Criticale(ctx context.Context, format string, args ...any) error
- func Criticalf(ctx context.Context, format string, args ...any)
- func Debug(ctx context.Context, err error)
- func Debugc(ctx context.Context, code int, format string, args ...any) error
- func Debuge(ctx context.Context, format string, args ...any) error
- func Debugf(ctx context.Context, format string, args ...any)
- func Error(ctx context.Context, err error)
- func Errorc(ctx context.Context, code int, format string, args ...any) error
- func Errore(ctx context.Context, format string, args ...any) error
- func Errorf(ctx context.Context, format string, args ...any)
- func Info(ctx context.Context, err error)
- func Infoc(ctx context.Context, code int, format string, args ...any) error
- func Infoe(ctx context.Context, format string, args ...any) error
- func Infof(ctx context.Context, format string, args ...any)
- func Panic(ctx context.Context, rcvr any) string
- func SetLogger(ctx context.Context, logger *Logger) context.Context
- func SetResponseStatus(ctx context.Context, status int)
- func Warning(ctx context.Context, err error)
- func Warningc(ctx context.Context, code int, format string, args ...any) error
- func Warninge(ctx context.Context, format string, args ...any) error
- func Warningf(ctx context.Context, format string, args ...any)
- type Duration
- type Entry
- type EntryChild
- type EntryHTTPRequest
- type EntrySourceLocation
- type Logger
- func (l *Logger) AddApplicationLog(severity Severity, file string, line int64, function string, msg string, ...)
- func (l *Logger) IsLogging(severity Severity) bool
- func (l *Logger) SetOuttedSeverity(severity Severity)
- func (l *Logger) WriteJob(ctx context.Context)
- func (l *Logger) WriteRequest(r *http.Request, at time.Time, dr time.Duration)
- 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
func (*Middleware) Handle ¶
func (m *Middleware) Handle(next http.Handler) http.Handler
Handle ... ロガーを初期化する
func (*Middleware) SetLogger ¶ added in v1.3.0
func (m *Middleware) SetLogger(ctx context.Context) context.Context
func (*Middleware) WriteJob ¶ added in v1.3.0
func (m *Middleware) WriteJob(ctx context.Context)
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, ) Job( severity Severity, traceID string, applicationLogs []*EntryChild, ) Application( severity Severity, traceID string, msg string, file string, line int64, function string, at time.Time, ) }
Writer ... ログの出力
func NewWriterStackdriver ¶
func NewWriterStdout ¶
func NewWriterStdout() Writer