logging

package
Version: v0.8.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2020 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger repesents stackdriver logger.

func NewLogger

func NewLogger(conf config.Config, projectID string) (*Logger, error)

NewLogger returns initialized *Logger

func (*Logger) Add

func (l *Logger) Add(data WriteData) error

Add adds the log entry to write spool.

func (*Logger) CreateWriteRequest

func (l *Logger) CreateWriteRequest(rows []*SDK.LogEntry, logName string) *SDK.WriteLogEntriesRequest

CreateWriteRequest creates *SDK.WriteLogEntriesRequest from WriteData.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...interface{})

Errorf logging error information.

func (*Logger) FlushAll

func (l *Logger) FlushAll() error

FlushAll executes Write operation from the write spool.

func (*Logger) SetCommonForceFields

func (l *Logger) SetCommonForceFields(fields []string)

SetCommonForceFields sets common FourceSendsFields.

func (*Logger) SetCommonLables

func (l *Logger) SetCommonLables(labels map[string]string)

SetCommonLables sets common labels.

func (*Logger) SetCommonLogName

func (l *Logger) SetCommonLogName(logName string)

SetCommonLogName sets common Resource.

func (*Logger) SetCommonNullFields

func (l *Logger) SetCommonNullFields(fields []string)

SetCommonNullFields sets common NullFields.

func (*Logger) SetCommonPartialSuccess

func (l *Logger) SetCommonPartialSuccess(partialSuccess bool)

SetCommonPartialSuccess sets common PartialSuccess.

func (*Logger) SetCommonResource

func (l *Logger) SetCommonResource(r *Resource)

SetCommonResource sets common Resource.

func (*Logger) SetLogger added in v0.5.0

func (l *Logger) SetLogger(logger log.Logger)

SetLogger sets internal API logger.

func (*Logger) Write

func (l *Logger) Write(data WriteData) error

Write sends log data to stackdriver's log.

type Resource

type Resource struct {
	Labels          map[string]string `json:"labels,omitempty"`
	Type            string            `json:"type,omitempty"`
	ForceSendFields []string          `json:"-"`
	NullFields      []string          `json:"-"`
}

Resource is wrapper struct for SDK.MonitoredResource.

type Severity

type Severity string

Severity is wrapper struct for Log Severity.

const (
	SeverityDefault   Severity = "DEFAULT"
	SeverityDebug     Severity = "DEBUG"
	SeverityInfo      Severity = "INFO"
	SeverityNotice    Severity = "NOTICE"
	SeverityWarning   Severity = "WARNING"
	SeverityError     Severity = "ERROR"
	SeverityCritical  Severity = "CRITICAL"
	SeverityAlert     Severity = "ALERT"
	SeverityEmergency Severity = "EMERGENCY"
)

severity list

type WriteData

type WriteData struct {
	Data            interface{} // required
	LogName         string      // required if commonLogName is empty
	Severity        Severity
	Labels          map[string]string
	PartialSuccess  bool
	Resource        *Resource
	Timestamp       time.Time
	InsertId        string
	Request         *http.Request
	Response        *http.Response
	Operation       *SDK.LogEntryOperation
	ForceSendFields []string
	NullFields      []string
}

WriteData is data struct for LogEntry data.

func (*WriteData) LogEntryList

func (d *WriteData) LogEntryList(projectID string) ([]*SDK.LogEntry, error)

LogEntryList converts WriteData to *LogEntry.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL