aboutsummaryrefslogtreecommitdiffstats
path: root/client/go/internal/admin/trace/trace.go
blob: 449784adb915b1751a464c1ce65b5e30c877d6a0 (plain) (blame)
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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Author: arnej

// handling of informational output
package trace

import (
	"fmt"
)

type outputLevel int

const (
	levelError outputLevel = iota - 2
	levelWarning
	levelNone
	levelInfo
	levelTrace
	levelDebug
	levelSpam
)

var currentOutputLevel outputLevel = levelInfo

func AdjustVerbosity(howMuch int) {
	currentOutputLevel = (outputLevel)(howMuch + int(currentOutputLevel))
}

func Silent() {
	currentOutputLevel = levelNone
}

func outputTracing(l outputLevel, v ...interface{}) {
	if l > currentOutputLevel {
		return
	}
	msg := fmt.Sprintln(v...)
	logMessage(l, msg)
}

func Info(v ...interface{}) {
	outputTracing(levelInfo, v...)
}

func Trace(v ...interface{}) {
	outputTracing(levelTrace, v...)
}

func Debug(v ...interface{}) {
	outputTracing(levelDebug, v...)
}

func SpamDebug(v ...interface{}) {
	outputTracing(levelSpam, v...)
}

func Warning(v ...interface{}) {
	outputTracing(levelWarning, v...)
}