MCPcopy Index your code
hub / github.com/apex/log

github.com/apex/log @v1.9.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.9.0 ↗ · + Follow
224 symbols 786 edges 45 files 150 documented · 67% 16 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Structured logging for golang

Package log implements a simple structured logging API inspired by Logrus, designed with centralization in mind. Read more on Medium.

Handlers

  • apexlogs – handler for Apex Logs
  • cli – human-friendly CLI output
  • discard – discards all logs
  • es – Elasticsearch handler
  • graylog – Graylog handler
  • json – JSON output handler
  • kinesis – AWS Kinesis handler
  • level – level filter handler
  • logfmt – logfmt plain-text formatter
  • memory – in-memory handler for tests
  • multi – fan-out to multiple handlers
  • papertrail – Papertrail handler
  • text – human-friendly colored output
  • delta – outputs the delta between log calls and spinner

Example

Example using the Apex Logs handler.

package main

import (
    "errors"
    "time"

    "github.com/apex/log"
)

func main() {
    ctx := log.WithFields(log.Fields{
        "file": "something.png",
        "type": "image/png",
        "user": "tobi",
    })

    for range time.Tick(time.Millisecond * 200) {
        ctx.Info("upload")
        ctx.Info("upload complete")
        ctx.Warn("upload retry")
        ctx.WithError(errors.New("unauthorized")).Error("upload failed")
        ctx.Errorf("failed to upload %s", "img.png")
    }
}

Build Status GoDoc

Extension points exported contracts — how you extend this code

Handler (Interface)
Handler is used to handle log events, outputting them to stdio or sending them to remote services. See the "handlers" di [14 …
logger.go
Interface (Interface)
Interface represents the API of both Logger and Entry. [2 implementers]
interface.go
Elasticsearch (Interface)
TODO(tj): allow dumping logs to stderr on timeout TODO(tj): allow custom format that does not include .fields etc TODO(t
handlers/es/es.go
Option (FuncType)
Option function.
handlers/apexlogs/apexlogs.go
Fielder (Interface)
Fielder is an interface for providing fields to custom types. [1 implementers]
logger.go
HandlerFunc (FuncType)
The HandlerFunc type is an adapter to allow the use of ordinary functions as log handlers. If f is a function with the a
logger.go

Core symbols most depended-on inside this repo

Info
called by 36
interface.go
NewEntry
called by 21
entry.go
SetHandler
called by 18
pkg.go
Error
called by 17
interface.go
WithError
called by 14
interface.go
WithFields
called by 13
pkg.go
New
called by 13
handlers/memory/memory.go
mergedFields
called by 12
entry.go

Shape

Function 100
Method 91
Struct 21
Interface 5
TypeAlias 4
FuncType 3

Languages

Go100%

Modules by API surface

logger.go27 symbols
entry.go20 symbols
pkg.go18 symbols
interface.go16 symbols
handlers/delta/delta.go13 symbols
logger_test.go11 symbols
handlers/apexlogs/apexlogs.go11 symbols
pkg_test.go9 symbols
entry_test.go9 symbols
handlers/es/es.go8 symbols
levels.go6 symbols
default.go6 symbols

For agents

$ claude mcp add log \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact