Skip to content

Commit 9b59523

Browse files
committed
refactor: add configuration options to README
1 parent f2b929b commit 9b59523

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,57 @@ To turn off debugging, unset the `DEBUGO` environment variable:
7171
unset DEBUGO
7272
```
7373

74+
## Configuration
75+
76+
`debugo` allows you to customize its behavior through the `Options` struct. These options let you fine-tune how logs are output and processed.
77+
78+
### Available Options
79+
80+
```go
81+
type Options struct {
82+
// Forces log output independent of given namespace matching (default: false)
83+
ForceEnable bool
84+
// Use background colors over foreground colors (default: false)
85+
UseBackgroundColors bool
86+
// Use a static color (github.com/fatih/color) (default: random foreground color)
87+
Color *color.Color
88+
// Defines the pipe to output to, eg. stdOut (default: stdErr)
89+
Output *os.File
90+
// Write log files in their own go routine (maintains order)
91+
Threaded bool
92+
}
93+
```
94+
95+
### Using Options
96+
97+
To create a new logger with specific options, use the `NewWithOptions` function:
98+
99+
#### Example
100+
101+
```go
102+
package main
103+
104+
import (
105+
"github.com/yourusername/debugo"
106+
"github.com/fatih/color"
107+
"os"
108+
)
109+
110+
func main() {
111+
options := &debugo.Options{
112+
ForceEnable: true,
113+
UseBackgroundColors: false,
114+
Color: color.New(color.FgRed).Add(color.Underline),
115+
Output: os.Stdout,
116+
Threaded: true,
117+
}
118+
119+
debug, _ := debugo.NewWithOptions("myapp", options)
120+
121+
debug("This is a custom debug message with configured options.")
122+
}
123+
```
124+
74125
## Comparison to `debug-js`
75126

76127
While `debugo` is inspired by `debug-js`, it is a simplified version tailored for Go. It does not implement all features of `debug-js`, focusing on core debugging functionality for Go developers.

0 commit comments

Comments
 (0)