func stringMatchesPattern(patternparts []string, testString string) bool {
	if len(patternparts) == 0 {
		return len(testString) == 0
	}
	part := patternparts[0]
	if part != "*" {
		index := strings.Index(testString, part)
		if index == 0 {
			return stringMatchesPattern(patternparts[1:], testString[len(part):])
		}
	} else {
		if len(patternparts) == 1 {
			return true
		}
		newTestString := testString
		part = patternparts[1]
		for {
			index := strings.Index(newTestString, part)
			if index == -1 {
				break
			}
			newTestString = newTestString[index+len(part):]
			result := stringMatchesPattern(patternparts[2:], newTestString)
			if result {
				return true
			}
		}
	}
	return false
}
stringMatchesPattern check whether testString matches pattern with asterisks.
Standard regexp functionality is not used here because of performance issues.
package seelog
import (
	"errors"
	"fmt"
	"regexp"
	"strings"
)
var (
	fileFormatValidator = regexp.MustCompile(`[a-zA-Z0-9\\/ _\*\.]*`)
	funcFormatValidator = regexp.MustCompile(`[a-zA-Z0-9_\*\.]*`)
)
type logLevelException struct {
	funcPatternParts []string
	filePatternParts []string
	funcPattern string
	filePattern string
	constraints logLevelConstraints
}
func newLogLevelException(funcPattern string, filePattern string, constraints logLevelConstraints) (*logLevelException, error) {
	if constraints == nil {
		return nil, errors.New("Constraints can not be nil")
	}
	exception := new(logLevelException)
	err := exception.initFuncPatternParts(funcPattern)
	if err != nil {
		return nil, err
	}
	exception.funcPattern = strings.Join(exception.funcPatternParts, "")
	err = exception.initFilePatternParts(filePattern)
	if err != nil {
		return nil, err
	}
	exception.filePattern = strings.Join(exception.filePatternParts, "")
	exception.constraints = constraints
	return exception, nil
}
func (logLevelEx *logLevelException) MatchesContext(context LogContextInterface) bool {
	return logLevelEx.match(context.Func(), context.FullPath())
}
func (logLevelEx *logLevelException) IsAllowed(level LogLevel) bool {
	return logLevelEx.constraints.IsAllowed(level)
}
func (logLevelEx *logLevelException) FuncPattern() string {
	return logLevelEx.funcPattern
}
func (logLevelEx *logLevelException) FilePattern() string {
	return logLevelEx.filePattern
}
func (logLevelEx *logLevelException) initFuncPatternParts(funcPattern string) (err error) {
	if funcFormatValidator.FindString(funcPattern) != funcPattern {
		return errors.New("Func path \"" + funcPattern + "\" contains incorrect symbols. Only a-z A-Z 0-9 _ * . allowed)")
	}
	logLevelEx.funcPatternParts = splitPattern(funcPattern)
	return nil
}
func (logLevelEx *logLevelException) initFilePatternParts(filePattern string) (err error) {
	if fileFormatValidator.FindString(filePattern) != filePattern {
		return errors.New("File path \"" + filePattern + "\" contains incorrect symbols. Only a-z A-Z 0-9 \\ / _ * . allowed)")
	}
	logLevelEx.filePatternParts = splitPattern(filePattern)
	return err
}
func (logLevelEx *logLevelException) match(funcPath string, filePath string) bool {
	if !stringMatchesPattern(logLevelEx.funcPatternParts, funcPath) {
		return false
	}
	return stringMatchesPattern(logLevelEx.filePatternParts, filePath)
}
func (logLevelEx *logLevelException) String() string {
	str := fmt.Sprintf("Func: %s File: %s ", logLevelEx.funcPattern, logLevelEx.filePattern)
	if logLevelEx.constraints != nil {
		str += fmt.Sprintf("Constr: %s", logLevelEx.constraints)
	} else {
		str += "nil"
	}
	return str
}
func splitPattern(pattern string) []string {
	patternParts := make([]string, 0)
	var lastChar rune
	for _, char := range pattern {
		if char == '*' {
			if lastChar != '*' {
				patternParts = append(patternParts, "*")
			}
		} else {
			if len(patternParts) != 0 && lastChar != '*' {
				patternParts[len(patternParts)-1] += string(char)
			} else {
				patternParts = append(patternParts, string(char))
			}
		}
		lastChar = char
	}
	return patternParts
}