template.go
func NewTemplateWithFuncMap(tpl string, funcMap template.FuncMap) (*Template, error) {
	var levels = []LogLevel{LevelNone, LevelDebug, LevelInfo, LevelWarning, LevelError, LevelFatal}
	tpls := make(map[LogLevel]*template.Template, 0)
	for _, level := range levels {
		// If color is overridden, we need to ensure that {{reset}} resets for all levels.
		_, forceReset := funcMap["color"]
		fMap := getFuncMap(level, forceReset)
		for name, f := range funcMap {
			fMap[name] = f
		}

		parsedTpl, err := template.New(getLevelName(level)).
			Funcs(fMap).
			Parse(tpl)
		if err != nil {
			return nil, err
		}
		tpls[level] = parsedTpl
	}

	newTpl := &Template{
		tpls: tpls,
	}

	return newTpl, nil
}
func NewTemplateWithFuncMap(tpl string, funcMap template.FuncMap) (*Template, error) {
	var levels = []LogLevel{LevelNone, LevelDebug, LevelInfo, LevelWarning, LevelError, LevelFatal}
	tpls := make(map[LogLevel]*template.Template, 0)
	for _, level := range levels {
		// If color is overridden, we need to ensure that {{reset}} resets for all levels.
		_, forceReset := funcMap["color"]
		fMap := getFuncMap(level, forceReset)
		for name, f := range funcMap {
			fMap[name] = f
		}

		parsedTpl, err := template.New(getLevelName(level)).
			Funcs(fMap).
			Parse(tpl)
		if err != nil {
			return nil, err
		}
		tpls[level] = parsedTpl
	}

	newTpl := &Template{
		tpls: tpls,
	}

	return newTpl, nil
}
// NewTemplateWithFuncMap creates a new Template from the given string and a template FuncMap. The FuncMap available
// to the template during evaluation will also include the default values, if not overridden. An error is returned
// if the template fails to compile.