Categorygithub.com/DataDrake/waterlog
modulepackage
1.2.0
Repository: https://github.com/datadrake/waterlog.git
Documentation: pkg.go.dev

# README

waterlog

Go Logging that just works

Go Report Card GoDoc license

Motivation

Logging is terribly boring, but can be an important part of a project. This library provides logging capabilities that attempt to "spice up" what is otherwise a very utilitarian aspect of programming.

Goals

  • Styling that is easy to look at
  • More granular logging severities ("levels")
  • Compatibility with the existing log.Logger interface

Implementation

Waterlog consists of two sets of code. The first is an implementation in Go which is able to be used as a drop-in replacement for the Go log.Logger. The second is a set of Makefile definitions that provide similar styling for GNU Make project.

Message Types

The traditional log.Logger implementation only provides three different message types:

TypeBehavior
FatalLog message and os.Exit(1)
PanicLog message and panic()
PrintLog message

For each level it also supports a Print, Printf, and Println variant of the output.

Waterlog, on the other hand, provides a total of 8 message types. These levels also support Print, Printf, and Println output modes. Unlike log.Logger, Waterlog supports logging levels which correspond with these message types. Higher levels allow more types of message to be shown. The logging level may be changed at any time by the SetLevel() method. The psuedo-type Disable is also provided to allow quiet operation. A default level of Fatal is assigned to new Waterlog instances. Lastly, Print messages are always written as unformatted text with no timestamp and ignore the logging level.

TypeBehaviorLevel
DisableNo messages0
PanicRuntime "exception" message and panic()1
FatalUnrecoverable error message and os.Exit(1)2
ErrorRecoverable error message3
WarnWarning message4
GoodSuccess message5
InfoGeneral information message6
DebugDeveloper Debug information.7
PrintAlways print unstyled textn/a

Examples

format.Full Logger

Go format.Full Example

format.Min Logger

Go format.Min Example

format.Un Logger

Go format.Un Example

Makefile

Makefile Example

License

Copyright 2017-2021 Bryan T. Meyers [email protected]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

Debug is a styled Print.
Debugf is a styled Printf.
Debugln is a styled Println.
Error is a styled Print.
Errorf is a styled Printf.
Errorln is a styled Println.
Fatal is a styled Print followed by os.Exit(1).
Fatalf is a styled Printf followed by os.Exit(1).
Fatalln is a styled Println followed by os.Exit(1).
Flags returns the output flags for std.
Good is a styled Print.
Goodf is a styled Printf.
Goodln is a styled Println.
Info is a styled Print.
Infof is a styled Printf.
Infoln is a styled Println.
Level returns the logging level.
New creates a WaterLog.
Panic is a styled Print followed by a call to panic("").
Panicf is a styled Printf followed by a call to panic("").
Panicln is a styled Println followed by a call to panic("").
Print is a mutex protect fmt.Fprint.
Printf is a mutex protect fmt.Fprintf.
Println is a mutex protect fmt.Fprintln.
SetFlags replaces the output flags.
SetFormat changes the printing format.
SetLevel changes the logging level.
SetOutput replaces the internal io.Writer.
Warn is a styled Print.
Warnf is a styled Printf.
Warnln is a styled Println.

# Structs

WaterLog is a styled log.Logger.