log

package module
v0.0.0-...-f8cd1c6 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2025 License: MIT Imports: 8 Imported by: 0

README

go-log

A simple Go package for OpenTelemetry logging with OTLP HTTP export.

Installation

go get github.com/gokpm/go-log

Usage

package main

import (
    "context"
    "fmt"
    "os"
    "time"
    
    "github.com/gokpm/go-log"
)

func setup() error {
    config := log.Config{
        Ok:          true,
        Name:        "my-service",
        Environment: "production",
        URL:         "http://localhost:4318/v1/logs",
    }
    
    ctx := context.Background()
    _, err := log.Setup(ctx, config)
    return err
}

func main() {
    if err := setup(); err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
    
    defer log.Shutdown(5 * time.Second)
    
    // Use logger for logging...
}

Configuration

  • Ok: Enable/disable logging
  • Name: Service name
  • Environment: Deployment environment
  • URL: OTLP HTTP endpoint URL (default: http://localhost:4318/v1/logs)

Features

  • OTLP HTTP export with gzip compression
  • Automatic resource detection (hostname, service info)
  • Graceful shutdown with timeout
  • Batch processing for performance

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(config *Config) (olog.Logger, error)

func Shutdown

func Shutdown(timeout time.Duration) error

Types

type Config

type Config struct {
	Ok          bool
	Name        string
	Environment string
	URL         string
	DialTimeout time.Duration
}

Jump to

Keyboard shortcuts

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