googlelogdemo: github.com/bugreplaydev/googlelogdemo Index | Examples | Files

package googlelogdemo

import "github.com/bugreplaydev/googlelogdemo"

Index

Examples

Package Files

googlelogdemo.go

Constants

const (
    LevelDefault   = "DEFAULT"
    LevelDebug     = "DEBUG"
    LevelInfo      = "INFO"
    LevelNotice    = "NOTICE"
    LevelWarning   = "WARNING"
    LevelError     = "ERROR"
    LevelCritical  = "CRITICAL"
    LevelAlert     = "ALERT"
    LevelEmergency = "EMERGENCY"
)

type CloudLogger Uses

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

CloudLogger will write structured logs to the cloud.

Code:

//normally you'd get the request from a Handler,
r := new(http.Request)
logger, err := NewAppEngineLogger(r, "myprojectid", "mylogsID")
err = logger.WriteLogEntry(LevelDebug, struct {
    EventName string
    EventID   string
}{
    EventName: "NewUser",
    EventID:   "qxzzr65",
})
if err != nil {
    panic(err)
}

Code:

logger, err := New("myserviceaccount", "myprivatekey", "myprojectid", "mylogname")
if err != nil {
    panic(err)
}
err = logger.WriteLogEntry(LevelDebug, struct {
    EventName string
    EventID   string
}{
    EventName: "NewUser",
    EventID:   "qxzzr65",
})
if err != nil {
    panic(err)
}

func New Uses

func New(serviceAccount, privateKey, projectID, logsID string) (*CloudLogger, error)

func NewAppEngineLogger Uses

func NewAppEngineLogger(r *http.Request, projectID, logsID string) (*CloudLogger, error)

func (*CloudLogger) WriteLogEntry Uses

func (cl *CloudLogger) WriteLogEntry(severity string, e interface{}) error

Package googlelogdemo imports 10 packages (graph). Updated 2016-09-07. Refresh now. Tools for package owners.