charmbracelet / charmbracelet/log

Indent all keyvals

Open
#118 4 comments 3 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3.4k
Forks
103
PR merge metrics
No merged PRs in 30d

Description

Hi, thanks a lot for creating this package!

I have been playing around with it a bit today, but I have not been able to find a way that ensures that the `keyvals` always gets indented.

To illustrate what I mean, I've created this program:

```go
package main

import (
"os"

"github.com/charmbracelet/log"
)

const (
userId = "31c572eb-abb8-4907-b4ad-9c66799c4895"
orderId = "6b3508f9-cfbe-41d7-8c4d-d4c399bee604"
)

func main() {
logger := log.New(os.Stdout)
logger.Info("Successfully placed order.",
"user_id", userId,
"order_id", orderId,
)
}

```

Running itprints the message as a single line like this:

Screenshot 2024-04-16 at 20 45 25

However, I looked a bit at the code, and saw that there was an indentation separator. Is there a way to ensure that it gets applied to all keyvals without having to add newlines to each value like this:

```go
logger.Info("Successfully placed order.",
"user_id", userId+"\n",
"order_id", orderId+"\n",
)
```

Screenshot 2024-04-16 at 20 49 01

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the shown main program and inspect the package's indentation separator and logging-formatting entry points. Determine how key-value pairs are rendered, then verify that all keyvals are indented without requiring embedded newlines; the issue provides no named files or tests to run.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.