// Returns the ceil'd log2 value of n
// See: http://stackoverflow.com/a/15327567
181319
func ceilLogBaseTwo(x uint64) uint64 {
	y := uint64(1)
	if (x & (x - 1)) == 0 {
		y = 0
	}
	j := uint64(32)
	i := uint64(0)

	for ; i < 6; i++ {
		k := j
		if (x & log2lookup[i]) == 0 {
			k = 0
		}
		y += k
		x >>= k
		j >>= 1
	}

	return y
}
7272
func (c *Console) Log(e log.Entry) {

	var b []byte
	var lvl string
	var i int

	if c.displayColor {
		color := c.colors[e.Level]

		b = append(b, e.Timestamp.Format(c.timestampFormat)...)
		b = append(b, space)
		b = append(b, color...)

		lvl = e.Level.String()

		for i = 0; i < 6-len(lvl); i++ {
			b = append(b, space)
		}
		b = append(b, lvl...)
		b = append(b, ansi.Reset...)
		b = append(b, space)
		b = append(b, e.Message...)

		for _, f := range e.Fields {
			b = append(b, space)
			b = append(b, color...)
			b = append(b, f.Key...)
			b = append(b, ansi.Reset...)
			b = append(b, equals)

			switch t := f.Value.(type) {
			case string:
				b = append(b, t...)
			case int:
				b = strconv.AppendInt(b, int64(t), base10)
			case int8:
				b = strconv.AppendInt(b, int64(t), base10)
			case int16:
				b = strconv.AppendInt(b, int64(t), base10)
			case int32:
				b = strconv.AppendInt(b, int64(t), base10)
			case int64:
				b = strconv.AppendInt(b, t, base10)
			case uint:
				b = strconv.AppendUint(b, uint64(t), base10)
			case uint8:
				b = strconv.AppendUint(b, uint64(t), base10)
			case uint16:
				b = strconv.AppendUint(b, uint64(t), base10)
			case uint32:
				b = strconv.AppendUint(b, uint64(t), base10)
			case uint64:
				b = strconv.AppendUint(b, t, base10)
			case float32:
				b = strconv.AppendFloat(b, float64(t), 'f', -1, 32)
			case float64:
				b = strconv.AppendFloat(b, t, 'f', -1, 64)
			case bool:
				b = strconv.AppendBool(b, t)
			default:
				b = append(b, fmt.Sprintf(v, f.Value)...)
			}
		}

		b = append(b, newLine)
	} else {
		b = append(b, e.Timestamp.Format(c.timestampFormat)...)
		b = append(b, space)

		lvl = e.Level.String()

		for i = 0; i < 6-len(lvl); i++ {
			b = append(b, space)
		}

		b = append(b, lvl...)
		b = append(b, space)
		b = append(b, e.Message...)

		for _, f := range e.Fields {
			b = append(b, space)
			b = append(b, f.Key...)
			b = append(b, equals)

			switch t := f.Value.(type) {
			case string:
				b = append(b, t...)
			case int:
				b = strconv.AppendInt(b, int64(t), base10)
			case int8:
				b = strconv.AppendInt(b, int64(t), base10)
			case int16:
				b = strconv.AppendInt(b, int64(t), base10)
			case int32:
				b = strconv.AppendInt(b, int64(t), base10)
			case int64:
				b = strconv.AppendInt(b, t, base10)
			case uint:
				b = strconv.AppendUint(b, uint64(t), base10)
			case uint8:
				b = strconv.AppendUint(b, uint64(t), base10)
			case uint16:
				b = strconv.AppendUint(b, uint64(t), base10)
			case uint32:
				b = strconv.AppendUint(b, uint64(t), base10)
			case uint64:
				b = strconv.AppendUint(b, t, base10)
			case float32:
				b = strconv.AppendFloat(b, float64(t), 'f', -1, 32)
			case float64:
				b = strconv.AppendFloat(b, t, 'f', -1, 64)
			case bool:
				b = strconv.AppendBool(b, t)
			default:
				b = append(b, fmt.Sprintf(v, f.Value)...)
			}
		}

		b = append(b, newLine)
	}
	_, _ = c.writer.Write(b)
}
908043
func (log Logger) Logf(lvl level, format string, args ...interface{}) {
	log.intLogf(lvl, format, args...)
}
470200
func (c *C) Logf(format string, args ...interface{}) {
	c.logf(format, args...)
}
110886
func (l *LogAction) Log(level, format string, args ...interface{}) predicate.BoolPredicate {
	return func() bool {
		ilevel, err := log.ParseLevel(level)
		if err != nil {
			ilevel = log.DebugLevel
		}
		var writer io.Writer
		if l.writer != nil {
			writer = l.writer
		} else {
			writer = log.StandardLogger().WriterLevel(ilevel)
		}
		writer.Write([]byte(fmt.Sprintf(format, args...)))
		return true
	}
}
289134
func getLogLevel() (loglevel string) {
	loglevel = os.Getenv(LogLevelEnvVarName)
	if len(loglevel) == 0 {
		// If no env is set, return the default
		loglevel = LogLevelDefault
	}
	return
}
801142
func log2(i uintptr) uintptr {
	var n, p uintptr
	for p = 1; p < i; p += p {
		n++
	}
	return n
}
489132
func (c C) Ceil() Input {
	return C(float32(math.Ceil(float64(c))))
}
903520
func (logger *Logger) Log(level log.Level, args ...interface{}) {
	logger.output(level, args...)
}
836986
func (d DefaultLogger) Logf(level LogLevel, format string, a ...interface{}) (n int, err error) {
	if level >= logThreshhold {
		return fmt.Fprintf(os.Stderr, prefix(level)+" "+format+"\n", a...)
	}

	return 0, nil
}
1112253
func Log(formatSpecifier string, args ...interface{}) {
	if mg.Verbose() {
		if len(args) != 0 {
			log.Printf(formatSpecifier, args...)
		} else {
			log.Print(formatSpecifier)
		}
	}
}
948550
func log2Floor(v uint32) uint {
	v |= v >> 1
	v |= v >> 2
	v |= v >> 4
	v |= v >> 8
	v |= v >> 16
	return multiplyDeBruijnBitPosition[uint32(v*0x07C4ACDD)>>27]
}
1278691
func (f *LogFile) SeriesN() (n uint64) {
	f.mu.RLock()
	defer f.mu.RUnlock()

	for _, mm := range f.mms {
		n += uint64(mm.cardinality())
	}
	return n
}
1109193
func (t *Tree) Ceil(q Interface) (o Interface, err error) {
	if t.Root == nil {
		return
	}
	n := t.Root.ceil(q.Start(), q.ID())
	if n == nil {
		return
	}
	return n.Elem, nil
}
1218892
func (log Logger) Logc(lvl level, closure func() string) {
	log.intLogc(lvl, closure)
}
1147062
func (s *Session) log(msgL int, format string, a ...interface{}) {

	if msgL > s.LogLevel {
		return
	}

	msglog(msgL, 2, format, a...)
}
770894
func (u *Ugen) Log() Input {
	return unaryOpLog(u.Rate, u, u.NumOutputs)
}