diff options
author | rtz12 <koenig@fagott.pw> | 2016-10-11 18:53:22 (UTC) |
---|---|---|
committer | rtz12 <koenig@fagott.pw> | 2016-10-11 18:53:22 (UTC) |
commit | fbd746aef8c78067593f901afb0f255574392499 (patch) | |
tree | 10b91eabfc5696d5e0fe27f1649bd72b9ed461e5 /bin | |
parent | bf51b2e4a035a988b9e9cef737966846c619dace (diff) |
NSA implementiert
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/generate-events | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/bin/generate-events b/bin/generate-events new file mode 100755 index 0000000..c4a0c1c --- /dev/null +++ b/bin/generate-events | |||
@@ -0,0 +1,38 @@ | |||
1 | #!/bin/bash | ||
2 | events=$(cat) | ||
3 | echo 'package eventlogging | ||
4 | /* | ||
5 | * THIS FILE IS AUTOGENERATED | ||
6 | * DO NOT EDIT MANUALLY!!! | ||
7 | */ | ||
8 | |||
9 | import ( | ||
10 | "fagott.pw/charakterin" | ||
11 | ) | ||
12 | |||
13 | ' | ||
14 | |||
15 | echo "var Events = []string{" | ||
16 | while read event | ||
17 | do | ||
18 | cat <<EOT | ||
19 | "$event", | ||
20 | EOT | ||
21 | done <<<"$events" | ||
22 | echo '} | ||
23 | ' | ||
24 | |||
25 | while read event | ||
26 | do | ||
27 | funcName=$(sed -r 's/(^|_)(.)([^_]*)/\2\L\3/g' <<<$event) | ||
28 | cat <<EOT | ||
29 | func (l *EventLogger) ${funcName}(user *charakterin.User, data ${funcName}Data) { | ||
30 | if user != nil { | ||
31 | data.User = user.Name | ||
32 | data.UserAgent = user.Agent | ||
33 | } | ||
34 | l.base.Log("$event", data) | ||
35 | } | ||
36 | |||
37 | EOT | ||
38 | done <<<"$events" | ||