File: interface.go

package info (click to toggle)
golang-code.forgejo-f3-gof3 3.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,952 kB
  • sloc: sh: 100; makefile: 65
file content (70 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download
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
// Copyright Earl Warren <contact@earl-warren.org>
// Copyright Loïc Dachary <loic@dachary.org>
// SPDX-License-Identifier: MIT

package logger

import (
	"bytes"
)

type Level int

const (
	_             = iota
	Message Level = iota
	Trace   Level = iota
	Debug   Level = iota
	Info    Level = iota
	Warn    Level = iota
	Error   Level = iota
	Fatal   Level = iota
)

var toString = map[Level]string{
	Message: "message",
	Trace:   "trace",
	Debug:   "debug",
	Info:    "info",
	Warn:    "warn",
	Error:   "error",
	Fatal:   "fatal",
}

func (l Level) String() string {
	s, ok := toString[l]
	if ok {
		return s
	}
	return "undefined"
}

type Fun func(string, ...any)

type CaptureInterface interface {
	Interface
	GetBuffer() *bytes.Buffer
	String() string
	Reset()
}

type MessageInterface interface {
	Message(string, ...any)
	Trace(string, ...any)
	Debug(string, ...any)
	Info(string, ...any)
	Warn(string, ...any)
	Error(string, ...any)
	Fatal(string, ...any)
	Log(skip int, level Level, message string, args ...any)
}

type ManageInterface interface {
	SetLevel(level Level)
	GetLevel() Level
}

type Interface interface {
	MessageInterface
	ManageInterface
}