log

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 22 Imported by: 5 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package log defined a logger

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger represents file system transaction logger

func New

func New(config *config.Stream, ID string, fs afs.Service) (*Logger, error)

New creates a transaction logger

func (*Logger) Close

func (l *Logger) Close() (err error)

Close closes logger

func (*Logger) Log

func (l *Logger) Log(message msg.Message) (err error)

Log logs a message

Example
package main

import (
	"github.com/viant/afs"
	"github.com/viant/tapper/config"
	"github.com/viant/tapper/log"
	"github.com/viant/tapper/msg"
	"github.com/viant/tapper/msg/json"

	slog "log"
)

func main() {

	cfg := &config.Stream{
		URL:   "/tmp/logfile.log",
		Codec: "gzip",
		Rotation: &config.Rotation{
			EveryMs: 100,
			URL:     "/tmp/logfile.log.[yyyyMMdd_HH]-%v",
		},
	}
	logger, err := log.New(cfg, "myID", afs.New())
	if err != nil {
		slog.Fatal(err)
	}
	provider := msg.NewProvider(2048, 32, json.New)

	for i := 0; i < 100; i++ {
		message := provider.NewMessage()
		message.PutString("k1", "value1")
		message.PutInt("k2", 2)
		message.PutStrings("k3", []string{"1", "3"})
		err = logger.Log(message)
		if err != nil {
			slog.Fatal(err)
		}
		message.Free()
	}
	logger.Close()
}

func (*Logger) Merge added in v0.7.0

func (l *Logger) Merge(ctx context.Context, from *Logger) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL