logger

package
v0.0.0-...-b1b0329 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OffLevelString     = "off"
	NoneLevelString    = "none"
	DefaultLevelString = "default"
)

Variables

This section is empty.

Functions

func AssertEqual

func AssertEqual(expected, actual interface{}, msgAndArgs ...interface{}) bool

func AssertEqualf

func AssertEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func AssertFalse

func AssertFalse(value bool, msgAndArgs ...interface{}) bool

func AssertFalsef

func AssertFalsef(value bool, msg string, args ...interface{}) bool

func AssertNil

func AssertNil(object interface{}, msgAndArgs ...interface{}) bool

func AssertNilF

func AssertNilF(object interface{}, msg string, args ...interface{}) bool

func AssertNotNil

func AssertNotNil(object interface{}, msgAndArgs ...interface{}) bool

func AssertNotNilF

func AssertNotNilF(object interface{}, msg string, args ...interface{}) bool

func AssertTrue

func AssertTrue(value bool, msgAndArgs ...interface{}) bool

func AssertTruef

func AssertTruef(value bool, msg string, args ...interface{}) bool

func Debugf

func Debugf(format string, args ...interface{})

func Error

func Error(args ...interface{})

func Errorf

func Errorf(format string, args ...interface{})

func Fatal

func Fatal(args ...interface{})

func FatalIfError

func FatalIfError(err error, args ...interface{})

func Fatalf

func Fatalf(format string, args ...interface{})

func FatalfIfError

func FatalfIfError(err error, format string, args ...interface{})

func GetLevelString

func GetLevelString(level Level) string

func Infof

func Infof(format string, args ...interface{})

func Log

func Log(level Level, msg interface{})

Log outputs the log message/object at specified level using logger.

func Logf

func Logf(level Level, format string, args []interface{})

Logf outputs formatted log message at specified level using logger.

func NodeLogf

func NodeLogf(nodeid NodeId, level Level, format string, args ...interface{})

NodeLogf logs a formatted log message for the specific nodeid; correct NodeLogger object will be auto-found.

func Panic

func Panic(args ...interface{})

func PanicIfError

func PanicIfError(err error, args ...interface{})

func Panicf

func Panicf(format string, args ...interface{})

func PanicfIfError

func PanicfIfError(err error, format string, args ...interface{})

func Println

func Println(msg string)

Println prints a message for the user at the current console/CLI, to stdout, without logging fields.

func SetLevel

func SetLevel(lv Level)

SetLevel sets the log level

func SetOutput

func SetOutput(outputs []string)

SetOutput sets the output writer e.g. logger.SetOutput([]string{"stderr", "otns.log"}) // for @DEBUG: generate a log output file.

func SetStdoutCallback

func SetStdoutCallback(cb StdoutCallback)

SetStdoutCallback sets a callback, that the logger will call when new log content was written to stdout/stderr.

func TraceError

func TraceError(format string, args ...interface{})

TraceError prints the stack and error

func Tracef

func Tracef(format string, args ...interface{})

func Warnf

func Warnf(format string, args ...interface{})

Types

type Level

type Level int8

Level is the log-level for logging what happens in the simulation as a whole, or to watch an individual node. Values inherit OT logging.h values and extend these with OT-NS specific items.

const (
	MicroLevel   Level = 7
	TraceLevel   Level = 6
	DebugLevel   Level = 5
	InfoLevel    Level = 4
	NoteLevel    Level = 3
	WarnLevel    Level = 2
	ErrorLevel   Level = 1
	PanicLevel   Level = 0
	FatalLevel   Level = -1
	OffLevel     Level = -2
	MinLevel           = OffLevel
	DefaultLevel       = InfoLevel
)

func GetLevel

func GetLevel() Level

GetLevel get the current log level

func ParseLevelString

func ParseLevelString(level string) (Level, error)

func ParseOtLogLine

func ParseOtLogLine(line string) (bool, Level)

ParseOtLogLine attempts to parse line as an OT generated log line with timestamp/level/message. Returns true if successful and also returns the determined log level of the log line.

type NodeLogger

type NodeLogger struct {
	Id NodeId
	// contains filtered or unexported fields
}

NodeLogger is a node-specific log object. Levels and output file can be set per individual node.

func GetNodeLogger

func GetNodeLogger(outputDir string, simulationId int, cfg *NodeConfig) *NodeLogger

GetNodeLogger gets the NodeLogger instance for the given ( simulation ID, node config ) and configures it.

func (*NodeLogger) Close

func (nl *NodeLogger) Close()

Close closes the node log file and also saves/displays any pending entries.

func (*NodeLogger) Debugf

func (nl *NodeLogger) Debugf(format string, args ...interface{})

func (*NodeLogger) DisplayPendingLogEntries

func (nl *NodeLogger) DisplayPendingLogEntries(ts uint64)

DisplayPendingLogEntries displays all pending log entries for the node, using given simulation time ts. This includes writing any pending entries to the node log file.

func (*NodeLogger) Error

func (nl *NodeLogger) Error(err error)

func (*NodeLogger) Errorf

func (nl *NodeLogger) Errorf(format string, args ...interface{})

func (*NodeLogger) Info

func (nl *NodeLogger) Info(format string)

func (*NodeLogger) Infof

func (nl *NodeLogger) Infof(format string, args ...interface{})

func (*NodeLogger) IsFileEnabled

func (nl *NodeLogger) IsFileEnabled() bool

IsFileEnabled returns true if logging to file is currently enabled, false if not.

func (*NodeLogger) IsLevelVisible

func (nl *NodeLogger) IsLevelVisible(level Level) bool

func (*NodeLogger) Log

func (nl *NodeLogger) Log(level Level, msg string)

func (*NodeLogger) LogOt

func (nl *NodeLogger) LogOt(levelAndMsg string)

LogOt logs a complete OT format log string, which includes timestamp, log level character, and the log message. The right level to log is automatically determined.

func (*NodeLogger) Logf

func (nl *NodeLogger) Logf(level Level, format string, args []interface{})

func (*NodeLogger) Panicf

func (nl *NodeLogger) Panicf(format string, args ...interface{})

func (*NodeLogger) SetDisplayLevel

func (nl *NodeLogger) SetDisplayLevel(level Level)

func (*NodeLogger) SetFileLevel

func (nl *NodeLogger) SetFileLevel(level Level)

func (*NodeLogger) Tracef

func (nl *NodeLogger) Tracef(format string, args ...interface{})

func (*NodeLogger) Warn

func (nl *NodeLogger) Warn(format string)

func (*NodeLogger) Warnf

func (nl *NodeLogger) Warnf(format string, args ...interface{})

type StdoutCallback

type StdoutCallback interface {
	OnStdout()
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL