2 Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, version 3 of the License.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 "go.cypherpunks.ru/tai64n/v2"
30 sinkCert = make(chan string)
31 sinkErr = make(chan string)
32 sinkOK = make(chan string)
33 sinkOther = make(chan string)
34 sinkRedir = make(chan string)
35 sinkReq = make(chan string)
36 sinkTLS = make(chan string)
41 func sinker(c chan string, p string) {
42 tai := new(tai64n.TAI64N)
43 fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666))
49 fd.WriteString(s + "\n")
51 tai.FromTime(time.Now())
52 fd.WriteString(tai64n.Encode(tai[:]) + " " + s + "\n")
55 fd, err = os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666))
57 log.Printf("Sink error: %+v\n", err)
63 go sinker(sinkCert, filepath.Join(*fifos, "cert"))
64 go sinker(sinkErr, filepath.Join(*fifos, "err"))
65 go sinker(sinkOK, filepath.Join(*fifos, "ok"))
66 go sinker(sinkOther, filepath.Join(*fifos, "other"))
67 go sinker(sinkRedir, filepath.Join(*fifos, "redir"))
68 go sinker(sinkReq, filepath.Join(*fifos, "req"))
69 go sinker(sinkTLS, filepath.Join(*fifos, "tls"))