func Fine(format string, args ...interface{}) {
	mod, loc := callingModule()
	if fineLogEnabled(mod) {
		doLog(mod, loc, format, args...)
	}
}
Fine logs a formatted message if fine logging is enabled for the
calling module. Enable fine logging using the commandline flag,
`--finelog=$module1,$module2`. [Requires debug logging].
package logging  
import (
	"fmt"
	"io"
	"log"
	"os"
	"path/filepath"
	"runtime"
	"strings"
	"sync"
	"sync/atomic"
)
func trimSuffix(s, suffix string) (result string, trimmed bool) {
	return strings.TrimSuffix(s, suffix), strings.HasSuffix(s, suffix)
}
func trimPrefix(s, prefix string) (result string, trimmed bool) {
	return strings.TrimPrefix(s, prefix), strings.HasPrefix(s, prefix)
}
func construct() {
	pc, file, _, ok := runtime.Caller(0)
	if !ok {
		return
	}
	fnName := runtime.FuncForPC(pc).Name()
	if pkg, ok := trimSuffix(fnName, "/logging.construct"); ok {
		baristaPkg = pkg
		goSrcRoot, _ = trimSuffix(file, pkg+"/logging/logging.go")
	}
	logger = log.New(os.Stderr, "", 0)
	SetFlags(log.LstdFlags | log.Lshortfile)
	for _, arg := range os.Args {
		if mods, ok := trimPrefix(arg, "--finelog="); ok {
			fineLogModules = append(fineLogModules, strings.Split(mods, ",")...)
		}
		if mods, ok := trimPrefix(arg, "-finelog="); ok {
			fineLogModules = append(fineLogModules, strings.Split(mods, ",")...)
		}
	}
}
func init() {
	construct()
}
var baristaPkg = "#unknown#"
var goSrcRoot = os.Getenv("GOPATH")
func shorten(path string) string {
	path = strings.Replace(path, "*", "", -1)
	path = strings.Replace(path, "(", "", -1)
	path = strings.Replace(path, ")", "", -1)
	if module, ok := trimPrefix(path, baristaPkg+"/modules/"); ok {
		return fmt.Sprintf("mod:%s", module)
	}
	if core, ok := trimPrefix(path, baristaPkg+"/core."); ok {
		return fmt.Sprintf("core:%s", core)
	}
	if bar, ok := trimPrefix(path, baristaPkg+"/"); ok {
		return fmt.Sprintf("bar:%s", bar)
	}
	if main, ok := trimPrefix(path, baristaPkg+"."); ok {
		return fmt.Sprintf("barista:%s", main)
	}
	return path
}
var fineLogModules = []string{}
var fineLogModulesCache sync.Map
func fineLogEnabled(mod string) bool {
	cache, ok := fineLogModulesCache.Load(mod)
	if ok {
		return cache.(bool)
	}
	for _, fineMod := range fineLogModules {
		if strings.HasPrefix(mod, fineMod) {
			fineLogModulesCache.Store(mod, true)
			return true
		}
	}
	fineLogModulesCache.Store(mod, false)
	return false
}
func callingModule() (mod string, loc string) {
	pc, file, line, ok := runtime.Caller(2)
	fFlags := int(atomic.LoadInt64(&fileFlags))
	if fFlags != 0 {
		file, _ = trimPrefix(file, goSrcRoot)
		if fFlags&log.Lshortfile != 0 {
			file = filepath.Base(file)
		}
		loc = fmt.Sprintf("%s:%d", file, line)
	}
	if !ok {
		return "unknown", loc
	}
	fnName := runtime.FuncForPC(pc).Name()
	return shorten(fnName), loc
}
var fileFlags int64
var logger *log.Logger
func doLog(mod, loc string, format string, args ...interface{}) {
	out := fmt.Sprintf(format, args...)
	fFlags := int(atomic.LoadInt64(&fileFlags))
	if fFlags != 0 {
		out = fmt.Sprintf("%s (%s) %s", loc, mod, out)
	}
	logger.Output(3, out)
}
func SetOutput(output io.Writer) {
	logger.SetOutput(output)
}
func SetFlags(flags int) {
	fFlags := flags & (log.Llongfile | log.Lshortfile)
	atomic.StoreInt64(&fileFlags, int64(fFlags))
	logger.SetFlags(flags &^ fFlags)
}
func Log(format string, args ...interface{}) {
	mod, loc := callingModule()
	doLog(mod, loc, format, args...)
}