summaryrefslogtreecommitdiff
path: root/internal/log/log_test.go
blob: 40f6420a43f1f93d54ede36472a3f3470b4cd6c8 (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// GoToSocial
// Copyright (C) GoToSocial Authors admin@gotosocial.org
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

package log_test

import (
	"testing"

	"code.superseriousbusiness.org/gotosocial/internal/log"
	"codeberg.org/gruf/go-kv/v2"
)

func TestInlineability(t *testing.T) {
	t.Skip()

	// to check the output of this run:
	// go test -gcflags=all='-m=2' ./internal/log/ -run=TestInlineability 2>&1 | grep 'internal/log/log_test.go.*cannot inline'
	//
	// the output should not include any
	// of the below log package func calls.

	ctx := t.Context()
	const s = "hello world"

	log.Debug(ctx, s)
	log.Debugf(ctx, s)
	log.DebugKV(ctx, "key", s)
	log.DebugKVs(ctx, kv.Fields{{K: "key", V: s}}...)

	log.Info(ctx, s)
	log.Infof(ctx, s)
	log.InfoKV(ctx, "key", s)
	log.InfoKVs(ctx, kv.Fields{{K: "key", V: s}}...)

	log.Warn(ctx, s)
	log.Warnf(ctx, s)
	log.WarnKV(ctx, "key", s)
	log.WarnKVs(ctx, kv.Fields{{K: "key", V: s}}...)

	log.Error(ctx, s)
	log.Errorf(ctx, s)
	log.ErrorKV(ctx, "key", s)
	log.ErrorKVs(ctx, kv.Fields{{K: "key", V: s}}...)

	log.Panic(ctx, s)
	log.Panicf(ctx, s)
	log.PanicKV(ctx, "key", s)
	log.PanicKVs(ctx, kv.Fields{{K: "key", V: s}}...)

	log.Print(s)
	log.Printf(s)

	e := log.New()
	e = e.WithContext(ctx)
	e = e.WithField("key", s)
	e = e.WithFields(kv.Fields{{K: "key", V: s}}...)

	e.Debug(s)
	e.Debugf(s)

	e.Info(s)
	e.Infof(s)

	e.Warn(s)
	e.Warnf(s)

	e.Error(s)
	e.Errorf(s)

	e.Panic(s)
	e.Panicf(s)

	e.Print(s)
	e.Printf(s)
}