scribe

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: GPL-3.0 Imports: 3 Imported by: 10

README

scribe

The one part of HLHV that has decent code.

Scribe is a thread safe logging system that uses semantic symbols to make logs easier to read. It is built specifically for HLHV cells. It wraps the standard log library.

It has the ability to manage a directory of log files, separating them by date.

Here is some example output, generated by the HLHV queen cell:

2022/07/03 20:02:04 ... starting hlhv queen cell
2022/07/03 20:02:04 ... reading config file
2022/07/03 20:02:04 ... arming cell wrangler on port 2001
2022/07/03 20:02:04 ... arming https server on port 4343
2022/07/03 20:02:04 ... firing
2022/07/03 20:02:04 .// startup sequence complete, resuming normal operation
2022/07/03 20:02:09 --> new connection
2022/07/03 20:02:09 .// accepted cell
2022/07/03 20:02:09 -=E mount on @/
2022/07/03 20:02:12 ->? request for "localhost:4343/" by 127.0.0.1:39442
2022/07/03 20:02:12 --> new connection
2022/07/03 20:02:12 .// accepted band

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Print

func Print(t MessageType, level LogLevel, content ...interface{})

Print queues a single message to be logged/

func PrintConnect

func PrintConnect(level LogLevel, content ...interface{})

PrintConnect logs a message of type connect. This should be used to log a * client connecting.

func PrintDisconnect

func PrintDisconnect(level LogLevel, content ...interface{})

PrintDisconnect logs a message of type disconnect. This should be used to log * a client disconnecting.

func PrintDone

func PrintDone(level LogLevel, content ...interface{})

PrintDone logs a message of type done. This should be used to log the * successful completion of a task.

func PrintError

func PrintError(level LogLevel, content ...interface{})

PrintError logs a message of type error. This should be used when an * operation encounters a problem. This typically causes the operation to halt. * This should not log an event that causes a goroutine or the entire program * to stop.

func PrintFatal

func PrintFatal(level LogLevel, content ...interface{})

PrintFatal logs a message of type fatal. This should be used to log errors * that caused a goroutine, internal communication channel, or the entire * program to terminate.

func PrintInfo

func PrintInfo(level LogLevel, content ...interface{})

PrintDone logs a message of type info. This should be used to log * informational messages and general observations the program makes that could * be useful to whoever is reading the log.

func PrintMount

func PrintMount(level LogLevel, content ...interface{})

PrintMount logs a message of type mount. This should be used to log a client * mounting successfully.

func PrintProgress

func PrintProgress(level LogLevel, content ...interface{})

PrintProgress logs a message of type progress. This should be used to log * steps of an overall task.

func PrintRequest

func PrintRequest(level LogLevel, content ...interface{})

PrintRequest logs a message of type request. This should be used to log an * external request made by a client.

func PrintResolve

func PrintResolve(level LogLevel, content ...interface{})

PrintResolve logs a message of type resolve. This should be used when a * request made by a client was resolved successfully.

func PrintUnmount

func PrintUnmount(level LogLevel, content ...interface{})

PrintUnmount logs a message of type unmount This should be used to log a * client unmounting successfully.

func PrintWarning

func PrintWarning(level LogLevel, content ...interface{})

PrintWarning logs a message of type warning. This should be used to log a * problem which did not cause an error. Useful for logging suspicious behavior * or insecure configuration parameters.

func SetLogDirectory

func SetLogDirectory(directoryName string)

SetLogDirectory sets the directory logs are to be written to. In this * directory, log files will be created with a name formatted like this: * * YYYY-MM-DD.log * * When a message is logged, and a day has passed since the last message, a new * file is created.

func SetLogLevel

func SetLogLevel(level LogLevel)

SetLogLevel sets the log level. Only messages with the specified log level * or higher will be logged.

func Stop added in v0.2.0

func Stop()

Stop causes scribe to log all remaning things, and then completely stop. this * function waits until that has happened.

func UnsetLogDirectory

func UnsetLogDirectory()

UnsetLogDirectory causes the logging system to stop writing to files, and * sets all output to stdout.

Types

type LogLevel

type LogLevel int

LogLevel specifies what messages are to be logged, and what messages are to * be ignored.

const (
	// Print any and all info for debugging purposes.
	LogLevelDebug LogLevel = 0
	// Only print some info, such as logging requests and connections, and
	// errors
	LogLevelNormal LogLevel = 1
	// Only print errors
	LogLevelError LogLevel = 2
	// Completely disable logging. You DO NOT want to do this!
	LogLevelNone LogLevel = 3
)

All log levels.

type Message

type Message struct {
	// The type of the message
	Type MessageType
	// The importance of a message
	Level LogLevel
	// The message content (what gets printed)
	Content []interface{}
}

Message structs are sent down Scribe's message channel. They contain * information about the message to be logged.

type MessageType

type MessageType int

Different types of message. These determine what kind of symbol is displayed * on a message.

const (
	// ...
	Progress MessageType = iota
	// .//
	Done
	// (i)
	Info
	// !!!
	Warning
	// ERR
	Error
	// XXX
	Fatal
	// ->?
	Request
	// ->!
	Resolve
	// -->
	Connect
	// -=E
	Mount
	// <--
	Disconnect
	// X=-
	Unmount
	// =#=
	Bind
	// =X=
	Unbind
)

All message types.

Jump to

Keyboard shortcuts

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