log

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 7 Imported by: 1

README

component-log - Settings component for generating a log client

GoDoc

Bugs Code Smells Coverage Lines of Code Maintainability Rating Quality Gate Status Reliability Rating Security Rating Technical Debt Vulnerabilities

autoauto- [component-log - Settings component for generating a log client](#component-log---settings-component-for-generating-a-log-client)auto - [Overview](#overview)auto - [Quick Start](#quick-start)auto - [Status](#status)auto - [Contributing](#contributing)auto - [Building And Testing](#building-and-testing)auto - [License](#license)auto - [Contributing Agreement](#contributing-agreement)autoauto

Overview

This is a settings that enables constructing a log client. The resulting client is powered by logevent.

Quick Start

package main

import (
    "context"

    log "github.com/asecurityteam/component-log"
    "github.com/asecurityteam/settings/v2"
)

type AnEventToLog struct {
    Message string `logevent:"message,default=an-event"`
}

func main() {
    ctx := context.Background()
    envSource := settings.NewEnvSource(os.Environ())

    logger := log.New(ctx, envSource)
    logger.Info(AnEventToLog{})
}

Status

This project is in incubation which means we are not yet operating this tool in production and the interfaces are subject to change.

Contributing

Building And Testing

We publish a docker image called SDCLI that bundles all of our build dependencies. It is used by the included Makefile to help make building and testing a bit easier. The following actions are available through the Makefile:

  • make dep

    Install the project dependencies into a vendor directory

  • make lint

    Run our static analysis suite

  • make test

    Run unit tests and generate a coverage artifact

  • make integration

    Run integration tests and generate a coverage artifact

  • make coverage

    Report the combined coverage for unit and integration tests

License

This project is licensed under Apache 2.0. See LICENSE.txt for details.

Contributing Agreement

Atlassian requires signing a contributor's agreement before we can accept a patch. If you are an individual you can fill out the individual CLA. If you are contributing on behalf of your company then please fill out the corporate CLA.

Documentation

Index

Constants

View Source
const (
	// OutputStdout sends logs to stdout.
	OutputStdout = "STDOUT"
	// OutputNull sends logs to /dev/null.
	OutputNull = "NULL"
)

Variables

View Source
var LoggerFromContext = logevent.FromContext

LoggerFromContext is the concrete implementation of LogFn that should be used at runtime.

Functions

This section is empty.

Types

type Component

type Component struct{}

Component enables creating configured loggers.

func NewComponent

func NewComponent() *Component

NewComponent populates all the defaults.

func (*Component) New

func (*Component) New(_ context.Context, conf *Config) (Logger, error)

New creates a configured logger instance.

func (*Component) Settings

func (*Component) Settings() *Config

Settings generates a LoggerConfig with default values applied.

type Config

type Config struct {
	Level  string `description:"The minimum level of logs to emit. One of DEBUG, INFO, WARN, ERROR."`
	Output string `description:"Destination stream of the logs. One of STDOUT, NULL."`
}

Config contains all configuration values for creating a system logger.

func (*Config) Name

func (*Config) Name() string

Name of the configuration as it might appear in config files.

type LogFn

type LogFn func(context.Context) Logger

LogFn is the type that should be accepted by components that intend to log content using the context logger.

type Logger

type Logger = logevent.Logger

Logger is the project logging client interface. It is currently an alias to the logevent project.

func Load

func Load(ctx context.Context, source settings.Source, c *Component) (Logger, error)

Load is a convenience method for binding the source to the component.

func New

func New(ctx context.Context, source settings.Source) (Logger, error)

New is the top-level entry point for creating a new log client.

Jump to

Keyboard shortcuts

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