-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathzalgo_formatter.go
60 lines (47 loc) · 1.27 KB
/
zalgo_formatter.go
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package logzalgo
import (
"bytes"
"fmt"
"github.com/sirupsen/logrus"
"github.com/kortschak/zalgo"
)
// New corrupts a default logrus logger, making it much better at logging stuff.
func New() *logrus.Logger {
thatThing := logrus.New()
thatThing.Formatter = NewZalgoFormatterrrrrr()
return thatThing
}
// ZalgoFormatter, just look at it, don't touch it.
type ZalgoFormatter struct {
victim *logrus.TextFormatter
pain *bytes.Buffer
z *zalgo.Corrupter
}
// NewZalgoFormatterrrrrr gives you a new Zalgo formatterrrrrr...!
func NewZalgoFormatterrrrrr() *ZalgoFormatter {
pain := bytes.NewBuffer(nil)
z := zalgo.NewCorrupter(pain)
z.Zalgo = func(n int, r rune, z *zalgo.Corrupter) bool {
z.Up += 0.1
z.Middle += complex(0.01, 0.01)
z.Down += complex(real(z.Down)*0.1, 0)
return false
}
return &ZalgoFormatter{
victim: &logrus.TextFormatter{},
pain: pain,
z: z,
}
}
// Format Formats Stuff™.
func (zal *ZalgoFormatter) Format(entry *logrus.Entry) ([]byte, error) {
zal.pain.Reset()
zal.z.Up = complex(0, 0.2)
zal.z.Middle = complex(0, 0.2)
zal.z.Down = complex(0.001, 0.3)
victimsWish := entry.Message
_, _ = fmt.Fprint(zal.z, victimsWish)
victimsReality := zal.pain.String()
entry.Message = victimsReality
return zal.victim.Format(entry)
}