accesslog

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

README

component-accesslog - Settings component for logging HTTP accesslogs

GoDoc

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

Overview

This is a settings that enables constructing a RoundTripper that logs meta data on RoundTrip, such as the HTTP Method, time it takes to complete the HTTP request, path and query parameters, etc.

Quick Start

package main

import (
    "context"
    "net/http"

    accesslog "github.com/asecurityteam/component-accesslog"
)

func main() {
    ctx := context.Background()
	accessLogComponent := AccessLogComponent{}
    accessLogConfig := accessLogComponent.Settings()
    wrapper, _ := accessLogComponent.New(ctx, accessLogConfig)
    transport := wrapper(http.DefaultTransport)
    client := &http.Client{Transport: transport}
    req, _ := http.NewRequest(http.MethodGet, "www.google.com", http.NoBody)

    // should see accesslogs
    _, _ := j.HTTPClient.Do(req)

}

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

This section is empty.

Variables

This section is empty.

Functions

func New

New is the top-level entrypoint for creating an `http.Transport` decorator that emits an access logline on every `RoundTrip`.

Useful when configuring a `Component` outside of the hierarchy of a surrounding appliation.

Types

type Component

type Component struct{}

Component is a logging plugin.

func NewComponent

func NewComponent() *Component

NewComponent initializes a Component with default values.

func (*Component) New

New generates the middleware.

func (*Component) Settings

func (m *Component) Settings() *Config

Settings generates a config populated with defaults.

type Config

type Config struct{}

Config modifies the behavior of the access logs.

func (*Config) Name

func (*Config) Name() string

Name of the config root.

Jump to

Keyboard shortcuts

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