func SetLogLevel(fullDomain string, level int64) error {
	return domains.setLevel(fullDomain, level)
}
SetLogLevel sets the log level for a particular log domain and its children.  Pass LvlWarning for
example to output everything at warning and above. pass LvlPassthrough to set it to use the
settings of the parent level.  If a child of the specified level has its own level set, that
domain's log level will not be changed by this
package lgr
import (
	"errors"
	"fmt"
	"strings"
	"sync"
	"sync/atomic"
)
type domainInfo struct {
	parent        *domainInfo
	level         int64
	canonicalName string
}
func (dI *domainInfo) getEffectiveLevel() int64 {
	lgrLevel := atomic.LoadInt64(&dI.level)
	if lgrLevel == LvlPassthrough {
		if dI.parent != nil {
			lgrLevel = dI.parent.getEffectiveLevel()
		} else {
			lgrLevel = DefaultRootLevel
		}
	}
	return lgrLevel
}
type logDomains struct {
	sync.Mutex
	domainMap map[string]*domainInfo
}
func (doms *logDomains) setLevel(fullDomain string, level int64) error {
	domains.Lock()
	defer domains.Unlock()
	if level != LvlPassthrough && (level < 0 || level >= LvlCount) {
		return fmt.Errorf("setLevel %s: bad level %d", fullDomain, level)
	}
	if fullDomain[0] != '/' {
		return fmt.Errorf("setLevel %s: domain must start with '/'", fullDomain)
	}
	key := strings.ToLower(fullDomain)
	if domInfo, exists := doms.domainMap[key]; !exists {
		domInfo := doms.getOrCreateDomainLocked(fullDomain)
		atomic.StoreInt64(&domInfo.level, level)
	} else {
		atomic.StoreInt64(&domInfo.level, level)
	}
	return nil
}
func (doms *logDomains) getOrCreateDomain(domainName string) *domainInfo {
	doms.Lock()
	defer doms.Unlock()
	return doms.getOrCreateDomainLocked(domainName)
}
func (doms *logDomains) getOrCreateDomainLocked(domainName string) *domainInfo {
	key := strings.ToLower(domainName)
	domainI, exists := doms.domainMap[key]
	if !exists {
		last := strings.LastIndex(domainName, "/")
		var parentDomain *domainInfo
		if last > 0 {  
			parentDomain = doms.getOrCreateDomainLocked(domainName[0:last])
		} else {
			parentDomain = doms.domainMap["/"]  
		}
		domainI = &domainInfo{
			parent:        parentDomain,
			level:         LvlPassthrough,
			canonicalName: domainName,
		}
		doms.domainMap[key] = domainI
	}
	return domainI
}