Esempio n. 1
0
// NewPrefixedLogger creates new instance of pluggable logger using specified
// prefix.
func NewPrefixedLogger(prefix string) lorg.Logger {
	if prefix != "" {
		prefix += " "
	}

	format := lorg.NewFormat(logFormatting)
	format.SetPlaceholder("prefix", func(_ lorg.Level, _ string) string {
		return prefix
	})

	logger := lorg.NewLog()
	logger.SetFormat(format)

	return logger
}
Esempio n. 2
0
func setLoggerStyle(logger *lorg.Log, style lorg.Formatter) {
	testLogger := lorg.NewLog()

	testLogger.SetFormat(style)

	buffer := &bytes.Buffer{}
	testLogger.SetOutput(buffer)

	testLogger.Debug(``)

	loggerFormattingBasicLength = len(strings.TrimSuffix(
		loreley.TrimStyles(buffer.String()),
		"\n",
	))

	logger.SetFormat(style)
	logger.SetIndentLines(true)
}
Esempio n. 3
0
package main

import "github.com/kovetskiy/lorg"

const (
	logFormatString = `${level} %s`
)

var (
	logger = lorg.NewLog()
)

func init() {
	format := lorg.NewFormat(logFormatString)
	logger.SetFormat(format)
}