Documentation ¶
Index ¶
- func Debug(ctx context.Context, message string, attributes ...attribute.KeyValue)
- func Error(ctx context.Context, message string, attributes ...attribute.KeyValue)
- func Fatal(ctx context.Context, message string, attributes ...attribute.KeyValue)
- func Info(ctx context.Context, message string, attributes ...attribute.KeyValue)
- func ToContext(ctx context.Context, l *Logger) context.Context
- func Warn(ctx context.Context, message string, attributes ...attribute.KeyValue)
- type Exporter
- type GrpcExporter
- type JSONExporter
- type Logger
- func (l *Logger) Debug(ctx context.Context, message string, attributes ...attribute.KeyValue)
- func (l *Logger) Error(ctx context.Context, message string, attributes ...attribute.KeyValue)
- func (l *Logger) Fatal(ctx context.Context, message string, attributes ...attribute.KeyValue)
- func (l *Logger) Info(ctx context.Context, message string, attributes ...attribute.KeyValue)
- func (l *Logger) Warn(ctx context.Context, message string, attributes ...attribute.KeyValue)
- func (l *Logger) WithAttributes(attributes ...attribute.KeyValue) *Logger
- func (l *Logger) WithExporter(exporter Exporter) *Logger
- func (l *Logger) WithResource(resource *resource.Resource) *Logger
- func (l *Logger) WithSeverity(severity logsv1.SeverityNumber) *Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Exporter ¶
type Exporter interface {
ExportLogs(ctx context.Context, protoLogs []*logsv1.ResourceLogs) error
}
Exporter exports log records
type GrpcExporter ¶
type GrpcExporter struct {
// contains filtered or unexported fields
}
GrpcExporter exports logs using the oltp grpc log export service.
func NewGrpcExporter ¶
func NewGrpcExporter(ctx context.Context, address string, options ...grpc.DialOption) (*GrpcExporter, error)
NewGrpcExporter creates an exporter.
func (*GrpcExporter) ExportLogs ¶
func (g *GrpcExporter) ExportLogs(_ context.Context, protoLogs []*logsv1.ResourceLogs) error
ExportLogs exports logs.
type JSONExporter ¶
type JSONExporter struct {
// contains filtered or unexported fields
}
JSONExporter writes logs in json format.
func NewJSONExporter ¶
func NewJSONExporter() *JSONExporter
NewJSONExporter creates a new exported that writes json to stdout.
func (*JSONExporter) ExportLogs ¶
func (j *JSONExporter) ExportLogs(_ context.Context, protoLogs []*logsv1.ResourceLogs) error
ExportLogs exports logs.
func (*JSONExporter) WithWriter ¶
func (j *JSONExporter) WithWriter(w io.Writer) *JSONExporter
WithWriter sets the writer for the exporter. It is up to the caller to ensure the writer is locked. The exported writes logs one complete line at a time.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is an opentelemetry logger
func FromContext ¶
FromContext returns the Logger from the context. If no logger was added, a nop Logger is returned.
func NewLogger ¶
func NewLogger() *Logger
NewLogger creates a new Logger at Info severity. It does nothing with logs, so you must add an exporter.
func (*Logger) Debug ¶
Debug logs at debug severity. Attributes passed here are merged with those added WithAttributes.
func (*Logger) Error ¶
Error logs at error severity. Attributes passed here are merged with those added WithAttributes.
func (*Logger) Fatal ¶
Fatal logs at fatal severity. Attributes passed here are merged with those added WithAttributes.
func (*Logger) Info ¶
Info logs at info severity. Attributes passed here are merged with those added WithAttributes.
func (*Logger) Warn ¶
Warn logs at warn severity. Attributes passed here are merged with those added WithAttributes.
func (*Logger) WithAttributes ¶
WithResource returns a clone of the logger with the attributes merged with any existing ones on the Logger.
func (*Logger) WithExporter ¶
WithExporter returns a clone of the logger with the given exporter. This overrides any previously set exporter.
func (*Logger) WithResource ¶
WithResource returns a clone of the logger with the given resource. The resource is included with the exporter log records. This overrides any previously set resource.
func (*Logger) WithSeverity ¶
func (l *Logger) WithSeverity(severity logsv1.SeverityNumber) *Logger
WithSeverity returns a clone of the logger with the given severity. Logs below this severity will not be exported.