Skip to content

Commit d59166a

Browse files
committed
chore: sync template files
1 parent 14bdf3c commit d59166a

1 file changed

Lines changed: 38 additions & 123 deletions

File tree

README.md

Lines changed: 38 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,41 @@
1515
1616
-->
1717

18-
<h1 align="center">AtomicGo | splitslog</h1>
18+
<h1 align="center">AtomicGo | template</h1>
1919

2020
<p align="center">
21-
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fatomicgo.dev%2Fapi%2Fshields%2Fsplitslog&style=flat-square" alt="Downloads">
21+
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fatomicgo.dev%2Fapi%2Fshields%2Ftemplate&style=flat-square" alt="Downloads">
2222

23-
<a href="https://github.com/atomicgo/splitslog/releases">
24-
<img src="https://img.shields.io/github/v/release/atomicgo/splitslog?style=flat-square" alt="Latest Release">
23+
<a href="https://github.com/atomicgo/template/releases">
24+
<img src="https://img.shields.io/github/v/release/atomicgo/template?style=flat-square" alt="Latest Release">
2525
</a>
2626

27-
<a href="https://codecov.io/gh/atomicgo/splitslog" target="_blank">
28-
<img src="https://img.shields.io/github/actions/workflow/status/atomicgo/splitslog/go.yml?style=flat-square" alt="Tests">
27+
<a href="https://codecov.io/gh/atomicgo/template" target="_blank">
28+
<img src="https://img.shields.io/github/actions/workflow/status/atomicgo/template/go.yml?style=flat-square" alt="Tests">
2929
</a>
3030

31-
<a href="https://codecov.io/gh/atomicgo/splitslog" target="_blank">
32-
<img src="https://img.shields.io/codecov/c/gh/atomicgo/splitslog?color=magenta&logo=codecov&style=flat-square" alt="Coverage">
31+
<a href="https://codecov.io/gh/atomicgo/template" target="_blank">
32+
<img src="https://img.shields.io/codecov/c/gh/atomicgo/template?color=magenta&logo=codecov&style=flat-square" alt="Coverage">
3333
</a>
3434

35-
<a href="https://codecov.io/gh/atomicgo/splitslog">
36-
<!-- unittestcount:start --><img src="https://img.shields.io/badge/Unit_Tests-1-magenta?style=flat-square" alt="Unit test count"><!-- unittestcount:end -->
35+
<a href="https://codecov.io/gh/atomicgo/template">
36+
<!-- unittestcount:start --><img src="https://img.shields.io/badge/Unit_Tests-3-magenta?style=flat-square" alt="Unit test count"><!-- unittestcount:end -->
3737
</a>
3838

3939
<a href="https://opensource.org/licenses/MIT" target="_blank">
4040
<img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square" alt="License: MIT">
4141
</a>
4242

43-
<a href="https://goreportcard.com/report/github.com/atomicgo/splitslog" target="_blank">
44-
<img src="https://goreportcard.com/badge/github.com/atomicgo/splitslog?style=flat-square" alt="Go report">
43+
<a href="https://goreportcard.com/report/github.com/atomicgo/template" target="_blank">
44+
<img src="https://goreportcard.com/badge/github.com/atomicgo/template?style=flat-square" alt="Go report">
4545
</a>
4646

4747
</p>
4848

4949
---
5050

5151
<p align="center">
52-
<strong><a href="https://pkg.go.dev/atomicgo.dev/splitslog#section-documentation" target="_blank">Documentation</a></strong>
52+
<strong><a href="https://pkg.go.dev/atomicgo.dev/template#section-documentation" target="_blank">Documentation</a></strong>
5353
|
5454
<strong><a href="https://github.com/atomicgo/atomicgo/blob/main/CONTRIBUTING.md" target="_blank">Contributing</a></strong>
5555
|
@@ -68,7 +68,7 @@
6868
</tbody>
6969
</table>
7070
</p>
71-
<h3 align="center"><pre>go get atomicgo.dev/splitslog</pre></h3>
71+
<h3 align="center"><pre>go get atomicgo.dev/template</pre></h3>
7272
<p align="center">
7373
<table>
7474
<tbody>
@@ -80,15 +80,17 @@
8080

8181
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
8282

83-
# splitslog
83+
# template
8484

8585
```go
86-
import "atomicgo.dev/splitslog"
86+
import "atomicgo.dev/template"
8787
```
8888

89-
Package splitslog provides a handler that splits log records to different handlers based on their level.
89+
Package template is used to generate new AtomicGo repositories.
9090

91-
The most common use case is to split logs to stdout and stderr based on their level.
91+
Write the description of the module here. You can use \*\*markdown\*\*\! This description should clearly explain what the package does.
92+
93+
Example description: https://golang.org/src/encoding/gob/doc.go
9294

9395

9496

@@ -98,67 +100,37 @@ The most common use case is to split logs to stdout and stderr based on their le
98100
package main
99101

100102
import (
101-
"log/slog"
102-
"os"
103+
"fmt"
103104

104-
"atomicgo.dev/splitslog"
105+
"atomicgo.dev/template"
105106
)
106107

107108
func main() {
108-
splitter := splitslog.Splitter{
109-
// Debug and info messages are printed to stdout.
110-
slog.LevelDebug: slog.NewJSONHandler(os.Stdout, nil),
111-
slog.LevelInfo: slog.NewJSONHandler(os.Stdout, nil),
112-
113-
// Warn and error messages are printed to stderr.
114-
slog.LevelWarn: slog.NewJSONHandler(os.Stderr, nil),
115-
slog.LevelError: slog.NewJSONHandler(os.Stderr, nil),
116-
}
117-
118-
handler := splitslog.NewSplitHandler(splitter)
119-
logger := slog.New(handler)
109+
fmt.Println(template.HelloWorld())
110+
}
111+
```
120112

121-
logger.Info("info message prints to stdout")
122-
logger.Error("error message prints to stderr")
113+
#### Output
123114

124-
// stdout: {"time":"2023-09-07T16:56:22.563817+02:00","level":"INFO","msg":"info message prints to stdout"}
125-
// stderr: {"time":"2023-09-07T16:56:22.564103+02:00","level":"ERROR","msg":"error message prints to stderr"}
126-
}
115+
```
116+
Hello, World!
127117
```
128118

129119

130120

131121
## Index
132122

133-
- [type SplitHandler](<#SplitHandler>)
134-
- [func NewSplitHandler\(splitter Splitter\) \*SplitHandler](<#NewSplitHandler>)
135-
- [func \(h \*SplitHandler\) Enabled\(ctx context.Context, level slog.Level\) bool](<#SplitHandler.Enabled>)
136-
- [func \(h \*SplitHandler\) Handle\(ctx context.Context, record slog.Record\) error](<#SplitHandler.Handle>)
137-
- [func \(h \*SplitHandler\) WithAttrs\(attrs \[\]slog.Attr\) slog.Handler](<#SplitHandler.WithAttrs>)
138-
- [func \(h \*SplitHandler\) WithGroup\(name string\) slog.Handler](<#SplitHandler.WithGroup>)
139-
- [type Splitter](<#Splitter>)
140-
123+
- [func HelloWorld\(\) string](<#HelloWorld>)
141124

142-
<a name="SplitHandler"></a>
143-
## type [SplitHandler](<https://github.com/atomicgo/splitslog/blob/main/splitslog.go#L15-L19>)
144125

145-
SplitHandler is a handler that splits log records to different handlers based on their level.
126+
<a name="HelloWorld"></a>
127+
## func [HelloWorld](<https://github.com/atomicgo/template/blob/main/template.go#L4>)
146128

147129
```go
148-
type SplitHandler struct {
149-
Splitter Splitter
150-
// contains filtered or unexported fields
151-
}
130+
func HelloWorld() string
152131
```
153132

154-
<a name="NewSplitHandler"></a>
155-
### func [NewSplitHandler](<https://github.com/atomicgo/splitslog/blob/main/splitslog.go#L22>)
156-
157-
```go
158-
func NewSplitHandler(splitter Splitter) *SplitHandler
159-
```
160-
161-
NewSplitHandler returns a new SplitHandler.
133+
HelloWorld returns \`Hello, World\!\`.
162134

163135

164136

@@ -168,80 +140,23 @@ NewSplitHandler returns a new SplitHandler.
168140
package main
169141

170142
import (
171-
"log/slog"
172-
"os"
143+
"fmt"
173144

174-
"atomicgo.dev/splitslog"
145+
"atomicgo.dev/template"
175146
)
176147

177148
func main() {
178-
splitter := splitslog.Splitter{
179-
// Debug and info messages are printed to stdout.
180-
slog.LevelDebug: slog.NewJSONHandler(os.Stdout, nil),
181-
slog.LevelInfo: slog.NewJSONHandler(os.Stdout, nil),
182-
183-
// Warn and error messages are printed to stderr.
184-
slog.LevelWarn: slog.NewJSONHandler(os.Stderr, nil),
185-
slog.LevelError: slog.NewJSONHandler(os.Stderr, nil),
186-
}
187-
188-
handler := splitslog.NewSplitHandler(splitter)
189-
logger := slog.New(handler)
190-
191-
logger.Info("info message prints to stdout")
192-
logger.Error("error message prints to stderr")
193-
194-
// stdout: {"time":"2023-09-07T16:56:22.563817+02:00","level":"INFO","msg":"info message prints to stdout"}
195-
// stderr: {"time":"2023-09-07T16:56:22.564103+02:00","level":"ERROR","msg":"error message prints to stderr"}
149+
fmt.Println(template.HelloWorld())
196150
}
197151
```
198152

153+
#### Output
199154

200-
201-
<a name="SplitHandler.Enabled"></a>
202-
### func \(\*SplitHandler\) [Enabled](<https://github.com/atomicgo/splitslog/blob/main/splitslog.go#L40>)
203-
204-
```go
205-
func (h *SplitHandler) Enabled(ctx context.Context, level slog.Level) bool
206-
```
207-
208-
Enabled implements Handler.Enabled.
209-
210-
<a name="SplitHandler.Handle"></a>
211-
### func \(\*SplitHandler\) [Handle](<https://github.com/atomicgo/splitslog/blob/main/splitslog.go#L45>)
212-
213-
```go
214-
func (h *SplitHandler) Handle(ctx context.Context, record slog.Record) error
215155
```
216-
217-
Handle implements Handler.Handle.
218-
219-
<a name="SplitHandler.WithAttrs"></a>
220-
### func \(\*SplitHandler\) [WithAttrs](<https://github.com/atomicgo/splitslog/blob/main/splitslog.go#L62>)
221-
222-
```go
223-
func (h *SplitHandler) WithAttrs(attrs []slog.Attr) slog.Handler
156+
Hello, World!
224157
```
225158

226-
WithAttrs implements Handler.WithAttrs.
227159

228-
<a name="SplitHandler.WithGroup"></a>
229-
### func \(\*SplitHandler\) [WithGroup](<https://github.com/atomicgo/splitslog/blob/main/splitslog.go#L71>)
230-
231-
```go
232-
func (h *SplitHandler) WithGroup(name string) slog.Handler
233-
```
234-
235-
WithGroup implements Handler.WithGroup.
236-
237-
<a name="Splitter"></a>
238-
## type [Splitter](<https://github.com/atomicgo/splitslog/blob/main/splitslog.go#L12>)
239-
240-
Splitter is a map of log levels to handlers. The default log levels \(slog.LevelDebug, slog.LevelInfo, slog.LevelWarn, slog.LevelError\) must be present, otherwise the SplitHandler panics.
241-
242-
```go
243-
type Splitter map[slog.Level]slog.Handler
244-
```
245160

246161
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
247162

0 commit comments

Comments
 (0)