htmllog: Index | Files

package htmllog

import ""

Package htmllog, a simple logger that produces an append-only, reloading HTML file


usable by multiple go-routines
protection against printing recursive data structures in message
configureable log event function
configureable Html style
configureable limit on message


h, err := htmllog.New("myapp.log")
h.Infof("just now is %v", time.Now())


Package Files

bottom.go bounded.go doc.go logger.go style.go


const (
    Debug = "debug"
    Info  = "info"
    Warn  = "warn"
    Error = "error"
    Fatal = "fatal"


var DefaultMaxMessageSize = 200

DefaultMaxMessageSize specifies the maxium length that a message can be.

var DefaultScrollToBottom = "" /* 254 byte string literal not displayed */
var DefaultStyle = "" /* 600 byte string literal not displayed */

func LimitedSprintf Uses

func LimitedSprintf(limit int, format string, args ...interface{}) string

LimitedSprintf returns the result of fmt.Sprintf limited to a number of bytes. Use this function to protect against printing recursive structures.

func LogEvent Uses

func LogEvent(hyper *Logger, logLevel, htmlEscapedMessage string)

LogEvent is the default implementation for an EventFunc and will write a timestamp, the log level, the (limited) message and a Html linebreak. This function is called in a protected region.

type EventFunc Uses

type EventFunc func(hyper *Logger, logLevel, htmlEscapedMessage string)

EventFunc is the signature for a custom definition how to write a log event.

type Logger Uses

type Logger struct {
    // contains filtered or unexported fields

Logger provides a thread-safe access to the Html file for writing log events.

func New Uses

func New(name string) (*Logger, error)

New creates a new logger and opens a new (or existing) file.

func NewOn Uses

func NewOn(w io.Writer) (*Logger, error)

NewOn creates a new logger that uses a writer.

func (*Logger) Br Uses

func (l *Logger) Br()

Br writes a Html linebreak. Must be called in a protected region.

func (*Logger) Configure Uses

func (l *Logger) Configure(scroll string, style string, newLimit int, logFunc EventFunc)

Configure is to override default behavior of the logger.

func (*Logger) Debugf Uses

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

Debugf writes a message with Debug level

func (*Logger) Div Uses

func (l *Logger) Div(cls string, block func())

Div writes the begin and end div tags around the block call. Must be called in a protected region.

func (*Logger) Errorf Uses

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

Errorf writes a message with Error level

func (*Logger) Event Uses

func (l *Logger) Event(level string, format string, args ...interface{})

Event is the generic function for writing a log event

func (*Logger) Fatalf Uses

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

Fatalf writes a message with Fatal level

func (*Logger) Infof Uses

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

Infof writes a message with Info level

func (*Logger) Level Uses

func (l *Logger) Level(level string)

Level writes the log level. Must be called in a protected region.

func (*Logger) Nbsp Uses

func (l *Logger) Nbsp(s string, size int) string

Nbsp returns a new string of a fixed size, padded with Html non-breaking spaces.

func (*Logger) Raw Uses

func (l *Logger) Raw(htmlEscapedMessage string)

Raw writes the message as is. Must be called in a protected region.

func (*Logger) Reset Uses

func (l *Logger) Reset() error

func (*Logger) Timestamp Uses

func (l *Logger) Timestamp()

Timestamp writes a formatted time (now). Must be called in a protected region.

func (*Logger) Warnf Uses

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

Warnf writes a message with Warn level

Package htmllog imports 7 packages (graph). Updated 2018-06-06. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).