2020-03-07 16:02:27 -07:00
|
|
|
// Copyright 2019 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package event
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Log sends a log event with the supplied tag list to the exporter.
|
|
|
|
func Log(ctx context.Context, tags ...Tag) {
|
2020-03-20 10:00:56 -06:00
|
|
|
dispatch(ctx, makeEvent(LogType, sTags{}, tags))
|
2020-03-07 16:02:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Print takes a message and a tag list and combines them into a single event
|
|
|
|
// before delivering them to the exporter.
|
|
|
|
func Print(ctx context.Context, message string, tags ...Tag) {
|
2020-03-20 10:00:56 -06:00
|
|
|
dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message)}, tags))
|
2020-03-07 16:02:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Error takes a message and a tag list and combines them into a single event
|
|
|
|
// before delivering them to the exporter. It captures the error in the
|
|
|
|
// delivered event.
|
|
|
|
func Error(ctx context.Context, message string, err error, tags ...Tag) {
|
|
|
|
if err == nil {
|
|
|
|
err = errors.New(message)
|
|
|
|
message = ""
|
|
|
|
}
|
2020-03-20 10:00:56 -06:00
|
|
|
dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message), Err.Of(err)}, tags))
|
2020-03-07 16:02:27 -07:00
|
|
|
}
|