-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathlogger_go1.22.go
More file actions
36 lines (30 loc) · 781 Bytes
/
logger_go1.22.go
File metadata and controls
36 lines (30 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//go:build go1.22
// +build go1.22
package log
import (
"encoding/base64"
)
// Base64 adds base64 encoding of the value to the entry.
func (e *Entry) Base64(key string, value []byte) *Entry {
if e == nil {
return nil
}
e.buf = append(e.buf, ',', '"')
e.buf = append(e.buf, key...)
e.buf = append(e.buf, '"', ':', '"')
e.buf = base64.StdEncoding.AppendEncode(e.buf, value)
e.buf = append(e.buf, '"')
return e
}
// Base64URL adds base64 url encoding of the value to the entry.
func (e *Entry) Base64URL(key string, value []byte) *Entry {
if e == nil {
return nil
}
e.buf = append(e.buf, ',', '"')
e.buf = append(e.buf, key...)
e.buf = append(e.buf, '"', ':', '"')
e.buf = base64.URLEncoding.AppendEncode(e.buf, value)
e.buf = append(e.buf, '"')
return e
}