Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Changelog

All notable changes to this project are documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Releases are git-tagged. The submodules (`logsentry`, `goslog`) are tagged in
lockstep with the root module, e.g. `v1.0.7`, `logsentry/v1.0.7`, `goslog/v1.0.7`.

## [Unreleased]

## [1.1.0] - 2026-06-16

### Changed

- **Breaking:** migrate to `getsentry/sentry-go` v0.46.2 and Go 1.25; route
logging errors through `logsentry`; make `golog.ErrorHandler` a thread-safe
accessor (#14). `golog.ErrorHandler` changed from a package variable to a
getter function: replace `golog.ErrorHandler = fn` with
`golog.SetErrorHandler(fn)`, and read the handler via `golog.ErrorHandler()`
or `golog.ErrorHandlerOr(fallback)`.
- **logsentry:** structured log values now populate the Sentry event's `log`
context instead of the removed `Event.Extra`; a logged `type` key is sent as
`type_` (reserved-name remap) (#14).
- Bump `securego/gosec` to v2.27.1 in the `tools` submodule (stays on Go 1.25),
pulling along `google.golang.org/grpc` 1.81.1 and assorted `golang.org/x/*`
and `google.golang.org/*` updates.
- Replace `tag-release.sh` (version passed as an argument) with `tag-version.sh`,
which reads the release version from the `VERSION` file.

### Fixed

- UUID parsing now accepts UUID versions 6, 7 and 8.

### Documentation

- Add `CLAUDE.md` with guidance for AI coding agents working in the repo.
- Fix the tag prefix in the redact breaking-change note.

## [1.0.7] - 2026-04-14

### Added

- `Format.Location` for fixed-timezone time formatting.

## [1.0.6] - 2026-04-14

### Added

- Tag-driven struct field logging with `omit`/`redact` modifiers.
- `Timestamp` type for flexible log timestamp parsing.

### Changed

- Move gosec into the `tools` submodule; expand `test-workspace.sh`.
- Bump Go to 1.24.9 and update dependencies (incl. `grpc` 1.79.3).

### Documentation

- Document `Timestamp` and `Format` defaults in the README.

## [1.0.5] - 2026-02-12

### Fixed

- Use `v0.0.0-00010101000000-000000000000` for locally replaced module versions.

## [1.0.4] - 2026-02-12

### Fixed

- `logsentry.WriterConfig`: add nil checks for hub and format in
`NewWriterConfig`; handle a nil error in `WriteError`.
- Ensure `WriteError` implementations do not panic on a nil error.
- `IsTerminal`: add a `#nosec` directive for the file-descriptor conversion.

## [1.0.3] - 2026-02-10

### Changed

- `WriterConfig`: add `mergeWriterConfigs` and optimize
`uniqueNonNilWriterConfigs`.

## [1.0.2] - 2026-02-03

### Fixed

- `SubLoggerContext`: self-referential `DerivedConfig` causing a stack overflow.

## [1.0.1] - 2026-01-30

### Added

- `DynDerivedConfig`; keep `DerivedConfig` fast without a mutex.

### Fixed

- `CallbackWriter`: nil pointer dereference in all slice `Write` methods.
- `logsentry` writer: improve panic-recovery error handling; add recovery in
`CommitMessage` and `FlushUnderlying`.
- `logfile`: recover `RotatingWriter` after a failed rotation.

## [1.0.0] - 2026-01-28

### Added

- Initial tagged release: zero-allocation append-style text output, `Time`
attrib type for zero-allocation `time.Time` logging, and the `tag-release`
versioning script.

[Unreleased]: https://github.com/domonda/golog/compare/v1.1.0...HEAD
[1.1.0]: https://github.com/domonda/golog/compare/v1.0.7...v1.1.0
[1.0.7]: https://github.com/domonda/golog/compare/v1.0.6...v1.0.7
[1.0.6]: https://github.com/domonda/golog/compare/v1.0.5...v1.0.6
[1.0.5]: https://github.com/domonda/golog/compare/v1.0.4...v1.0.5
[1.0.4]: https://github.com/domonda/golog/compare/v1.0.3...v1.0.4
[1.0.3]: https://github.com/domonda/golog/compare/v1.0.2...v1.0.3
[1.0.2]: https://github.com/domonda/golog/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/domonda/golog/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/domonda/golog/releases/tag/v1.0.0
81 changes: 81 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# CLAUDE.md

Guidance for agents working in this repository.

## Project

`github.com/domonda/golog` — a fast, zero-allocation structured logging library for Go
(inspired by zerolog). Production-tested at domonda since 2023. Go 1.25.

The public API surface is large but mechanical (see `message.go`, ~87 typed `Message`
field methods). Read `doc.go` and `README.md` for the user-facing overview before adding
features; both must be kept in sync with code changes.

## Multi-module workspace

This is a `go.work` workspace (`go.work`) with several modules. The root module is
intentionally dependency-light; heavier integrations live in their own modules so users
don't pull in transitive deps they don't need.

| Path | Module | Notes |
| ------------- | ------------------------------------------ | ------------------------------------------------------------ |
| `.` | `github.com/domonda/golog` | Core library. Released as the root tag (`vX.Y.Z`). |
| `goslog/` | `github.com/domonda/golog/goslog` | `log/slog` backend. Separate module + tag (`goslog/vX.Y.Z`). |
| `logsentry/` | `github.com/domonda/golog/logsentry` | Sentry writer. Separate module + tag (`logsentry/vX.Y.Z`). |
| `benchmarks/` | `github.com/domonda/golog/benchmarks` | Comparative benchmarks vs zerolog/zap/logrus. Not released. |
| `examples/` | `github.com/domonda/golog/examples` | Runnable examples. Not released. |
| `tools/` | `github.com/domonda/golog/tools` | `go tool` directive for gosec only. Not released. |

`goslog` and `logsentry` `replace` the root with `..`, so local edits to the core are
picked up automatically.

Sub-packages **without** their own `go.mod` (part of the root module):
- `log/` — ready-to-use package-level logger (`log.Logger`, `log.Info(...)`, etc.),
configured from the `LOG_LEVEL` env var with terminal auto-detection (text on a TTY,
JSON otherwise). See `log/config.go`.
- `logfile/` — size-based rotating file writer.
- `mempool/` — generic pooling primitives (`Pointer[T]`, `Slice[T]`) used everywhere for
zero-alloc reuse.

## Build, test, lint

Always operate across all modules — a change to the root can break `goslog`/`logsentry`.

```bash
./test-workspace.sh # build, go vet, gosec, go test across all modules except tools (gosec also skips examples)
./test-workspace.sh -v # extra args are forwarded to `go test`
./run-gosec.sh # gosec on the root module only
```

Tests run with `-p 1 -count=1` (serial, no cache) because logging touches global state
(`GlobalPanicLevel`, `ErrorHandler`, the package registry).

Single module / single test during development:
```bash
go build ./... && go vet ./... && go test ./...
go test -run TestName ./...
go tool gosec ./... # gosec is wired via tools/go.mod `tool` directive
```

CI: `.github/workflows/go.yml` (build + `go test -v` on the root) and `gosec.yml`.

## Conventions specific to this repo

This is a **public, dependency-light library**, so the user's global Go conventions in
`~/.claude/CLAUDE.md` do NOT apply here:
- Uses the **standard library** `errors.New` / `fmt.Errorf`, **not** `go-errs`.
- UUIDs are plain **`[16]byte`** with helpers in `uuid.go` (`UUIDv4`, `ParseUUID`,
`FormatUUID`), **not** the `uu` package. The `Message.UUID` / `Writer.WriteUUID` API
takes `[16]byte`.
- Match the existing style: keep zero-allocation discipline (pool and reuse, avoid
`reflect` on the hot path), and add the corresponding `*_test.go` coverage — most files
have a paired test.

## Releasing

The `VERSION` file uses Go module version syntax — a leading `v` followed by semver
(`vMAJOR.MINOR.PATCH`, e.g. `v1.1.0`), matching the git release tags.

`./tag-version.sh [message]` reads the version from the `VERSION` file and tags the
root, `goslog/`, and `logsentry/` modules together (it prints the current tags first).
Ask before pushing tags.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.1.0
5 changes: 4 additions & 1 deletion go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvm
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
golang.org/x/crypto v0.51.0/go.mod h1:8AdwkbraGNABw2kOX6YFPs3WM22XqI4EXEd8g+x7Oc8=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -796,6 +797,7 @@ golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
golang.org/x/net v0.54.0/go.mod h1:Sj4oj8jK6XmHpBZU/zWHw3BV3abl4Kvi+Ut7cQcY+cQ=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -838,7 +840,6 @@ golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -904,6 +905,7 @@ golang.org/x/telemetry v0.0.0-20251203150158-8fff8a5912fc/go.mod h1:hKdjCMrbv9sk
golang.org/x/telemetry v0.0.0-20260109210033-bd525da824e2/go.mod h1:b7fPSJ0pKZ3ccUh8gnTONJxhn3c/PS6tyzQvyqw4iA8=
golang.org/x/telemetry v0.0.0-20260209163413-e7419c687ee4/go.mod h1:g5NllXBEermZrmR51cJDQxmJUHUOfRAaNyWBM+R+548=
golang.org/x/telemetry v0.0.0-20260311193753-579e4da9a98c/go.mod h1:TpUTTEp9frx7rTdLpC9gFG9kdI7zVLFTFFlqaH2Cncw=
golang.org/x/telemetry v0.0.0-20260508192327-42602be52be6/go.mod h1:Eqhaxk/wZsWEH8CRxLwj6xzEJbz7k1EFGqx7nyCoabE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
Expand Down Expand Up @@ -1007,6 +1009,7 @@ golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs
golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg=
golang.org/x/tools v0.43.0/go.mod h1:uHkMso649BX2cZK6+RpuIPXS3ho2hZo4FVwfoy1vIk0=
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
83 changes: 0 additions & 83 deletions tag-release.sh

This file was deleted.

Loading