polychromatic

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: Apache-2.0 Imports: 6 Imported by: 5

README

Polychromatic

Go Report Card GoDoc

Polychromatic provides an opinionated wrapper around logrus including the prefixed formatter and colored terminal output. It also includes an EventualLogger which may be used when the desire to log a particular set of entries is not known immediately.

Contact: developer@tenta.io

Installation

go get github.com/tenta-browser/polychromatic

Usage

In general, just call GetLogger("prefix") wherever you want a prefixed logger. The function SetLogLevel(level) sets the global log level for all loggers which have been issued from polychromatic.

For eventual logging, call NewEventualLogger() to get an eventual logger which has Queue and Queuef (Printf style) methods to enqueue pending log entries. If you decide you want those log items, then call Flush(). If you don't want them, then drop it like it's hot.

Performance

The main log component just provides some convenience functions and setup wrappers around logrus, so performance wise it's identical. The EventualLogger does take locks to deal with threading issues, and is primarily designed for developemnt (which is a nice way of saying we haven't benchmarked it).

License

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.

For any questions, please contact developer@tenta.io

Contributing

We welcome contributions, feedback and plain old complaining. Feel free to open an issue or shoot us a message to developer@tenta.io. If you'd like to contribute, please open a pull request and send us an email to sign a contributor agreement.

About Tenta

This logging library is brought to you by Team Tenta. Tenta is your private, encrypted browser that protects your data instead of selling. We're building a next-generation browser that combines all the privacy tools you need, including built-in OpenVPN. Everything is encrypted by default. That means your bookmarks, saved tabs, web history, web traffic, downloaded files, IP address and DNS. A truly incognito browser that's fast and easy.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogger

func GetLogger(pkg string) *logrus.Entry

GetLogger sets up a new logger with the specified package name as the prefix.

func SetLogLevel

func SetLogLevel(lvl logrus.Level)

SetLogLevel globally sets the log level for all loggers obtained from this package

func SetOutput

func SetOutput(out io.Writer)

SetOutput globally sets the output buffer

func UseStderr

func UseStderr()

UseStderr forces the log to use StdErr instead of StdOut

Types

type EventualLogger

type EventualLogger struct {
	// contains filtered or unexported fields
}

EventualLogger provides a buffer for log entries whose usefulnes cannot be determined at creation time (but only eventually)

func NewEventualLogger

func NewEventualLogger() *EventualLogger

NewEventualLogger creates a new eventual logger

func (*EventualLogger) Flush

func (l *EventualLogger) Flush(target *logrus.Entry)

Flush writes out everything from the buffer

func (*EventualLogger) Queue

func (l *EventualLogger) Queue(level logrus.Level, message string)

Queue buffers the selected message to be written later

func (*EventualLogger) Queuef

func (l *EventualLogger) Queuef(level logrus.Level, format string, args ...interface{})

Queuef buffers the selected format string and args to be written later. It does not perform any kind of immediate evaluation on the arguments, so points which may be different later should probably be converted to a string when calling

Jump to

Keyboard shortcuts

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