//line /home/evie/packages/go/go-1.17.7-0/go/src/log/log.go:1
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package log implements a simple logging package. It defines a type, Logger,
// with methods for formatting output. It also has a predefined 'standard'
// Logger accessible through helper functions Print[f|ln], Fatal[f|ln], and
// Panic[f|ln], which are easier to use than creating a Logger manually.
// That logger writes to standard error and prints the date and time
// of each logged message.
// Every log message is output on a separate line: if the message being
// printed does not end in a newline, the logger will add one.
// The Fatal functions call os.Exit(1) after writing the log message.
// The Panic functions call panic after writing the log message.
package log

import (
	"fmt"
	"io"
	"os"
	"runtime"
	"sync"
	"time"
)

// These flags define which text to prefix to each log entry generated by the Logger.
// Bits are or'ed together to control what's printed.
// With the exception of the Lmsgprefix flag, there is no
// control over the order they appear (the order listed here)
// or the format they present (as described in the comments).
// The prefix is followed by a colon only when Llongfile or Lshortfile
// is specified.
// For example, flags Ldate | Ltime (or LstdFlags) produce,
//	2009/01/23 01:23:23 message
// while flags Ldate | Ltime | Lmicroseconds | Llongfile produce,
//	2009/01/23 01:23:23.123123 /a/b/c/d.go:23: message
const (
	Ldate         = 1 << iota     // the date in the local time zone: 2009/01/23
	Ltime                         // the time in the local time zone: 01:23:23
	Lmicroseconds                 // microsecond resolution: 01:23:23.123123.  assumes Ltime.
	Llongfile                     // full file name and line number: /a/b/c/d.go:23
	Lshortfile                    // final file name element and line number: d.go:23. overrides Llongfile
	LUTC                          // if Ldate or Ltime is set, use UTC rather than the local time zone
	Lmsgprefix                    // move the "prefix" from the beginning of the line to before the message
	LstdFlags     = Ldate | Ltime // initial values for the standard logger
)

// A Logger represents an active logging object that generates lines of
// output to an io.Writer. Each logging operation makes a single call to
// the Writer's Write method. A Logger can be used simultaneously from
// multiple goroutines; it guarantees to serialize access to the Writer.
type Logger struct {
	mu     sync.Mutex // ensures atomic writes; protects the following fields
	prefix string     // prefix on each line to identify the logger (but see Lmsgprefix)
	flag   int        // properties
	out    io.Writer  // destination for output
	buf    []byte     // for accumulating text to write
}

// New creates a new Logger. The out variable sets the
// destination to which log data will be written.
// The prefix appears at the beginning of each generated log line, or
// after the log header if the Lmsgprefix flag is provided.
// The flag argument defines the logging properties.
func New(out io.Writer, prefix string, flag int) *Logger {GoCover_0_383336666631383465376234.Count[0] = 1;
	return &Logger{out: out, prefix: prefix, flag: flag}
}

// SetOutput sets the output destination for the logger.
func (l *Logger) SetOutput(w io.Writer) {GoCover_0_383336666631383465376234.Count[1] = 1;
	l.mu.Lock()
	defer l.mu.Unlock()
	l.out = w
}

var std = New(os.Stderr, "", LstdFlags)

// Default returns the standard logger used by the package-level output functions.
func Default() *Logger {GoCover_0_383336666631383465376234.Count[2] = 1; return std }

// Cheap integer to fixed-width decimal ASCII. Give a negative width to avoid zero-padding.
func itoa(buf *[]byte, i int, wid int) {GoCover_0_383336666631383465376234.Count[3] = 1;
	// Assemble decimal in reverse order.
	var b [20]byte
	bp := len(b) - 1
	for i >= 10 || wid > 1 {GoCover_0_383336666631383465376234.Count[5] = 1;
		wid--
		q := i / 10
		b[bp] = byte('0' + i - q*10)
		bp--
		i = q
	}
	// i < 10
	GoCover_0_383336666631383465376234.Count[4] = 1;b[bp] = byte('0' + i)
	*buf = append(*buf, b[bp:]...)
}

// formatHeader writes log header to buf in following order:
//   * l.prefix (if it's not blank and Lmsgprefix is unset),
//   * date and/or time (if corresponding flags are provided),
//   * file and line number (if corresponding flags are provided),
//   * l.prefix (if it's not blank and Lmsgprefix is set).
func (l *Logger) formatHeader(buf *[]byte, t time.Time, file string, line int) {GoCover_0_383336666631383465376234.Count[6] = 1;
	if l.flag&Lmsgprefix == 0 {GoCover_0_383336666631383465376234.Count[10] = 1;
		*buf = append(*buf, l.prefix...)
	}
	GoCover_0_383336666631383465376234.Count[7] = 1;if l.flag&(Ldate|Ltime|Lmicroseconds) != 0 {GoCover_0_383336666631383465376234.Count[11] = 1;
		if l.flag&LUTC != 0 {GoCover_0_383336666631383465376234.Count[14] = 1;
			t = t.UTC()
		}
		GoCover_0_383336666631383465376234.Count[12] = 1;if l.flag&Ldate != 0 {GoCover_0_383336666631383465376234.Count[15] = 1;
			year, month, day := t.Date()
			itoa(buf, year, 4)
			*buf = append(*buf, '/')
			itoa(buf, int(month), 2)
			*buf = append(*buf, '/')
			itoa(buf, day, 2)
			*buf = append(*buf, ' ')
		}
		GoCover_0_383336666631383465376234.Count[13] = 1;if l.flag&(Ltime|Lmicroseconds) != 0 {GoCover_0_383336666631383465376234.Count[16] = 1;
			hour, min, sec := t.Clock()
			itoa(buf, hour, 2)
			*buf = append(*buf, ':')
			itoa(buf, min, 2)
			*buf = append(*buf, ':')
			itoa(buf, sec, 2)
			if l.flag&Lmicroseconds != 0 {GoCover_0_383336666631383465376234.Count[18] = 1;
				*buf = append(*buf, '.')
				itoa(buf, t.Nanosecond()/1e3, 6)
			}
			GoCover_0_383336666631383465376234.Count[17] = 1;*buf = append(*buf, ' ')
		}
	}
	GoCover_0_383336666631383465376234.Count[8] = 1;if l.flag&(Lshortfile|Llongfile) != 0 {GoCover_0_383336666631383465376234.Count[19] = 1;
		if l.flag&Lshortfile != 0 {GoCover_0_383336666631383465376234.Count[21] = 1;
			short := file
			for i := len(file) - 1; i > 0; i-- {GoCover_0_383336666631383465376234.Count[23] = 1;
				if file[i] == '/' {GoCover_0_383336666631383465376234.Count[24] = 1;
					short = file[i+1:]
					break
				}
			}
			GoCover_0_383336666631383465376234.Count[22] = 1;file = short
		}
		GoCover_0_383336666631383465376234.Count[20] = 1;*buf = append(*buf, file...)
		*buf = append(*buf, ':')
		itoa(buf, line, -1)
		*buf = append(*buf, ": "...)
	}
	GoCover_0_383336666631383465376234.Count[9] = 1;if l.flag&Lmsgprefix != 0 {GoCover_0_383336666631383465376234.Count[25] = 1;
		*buf = append(*buf, l.prefix...)
	}
}

// Output writes the output for a logging event. The string s contains
// the text to print after the prefix specified by the flags of the
// Logger. A newline is appended if the last character of s is not
// already a newline. Calldepth is used to recover the PC and is
// provided for generality, although at the moment on all pre-defined
// paths it will be 2.
func (l *Logger) Output(calldepth int, s string) error {GoCover_0_383336666631383465376234.Count[26] = 1;
	now := time.Now() // get this early.
	var file string
	var line int
	l.mu.Lock()
	defer l.mu.Unlock()
	if l.flag&(Lshortfile|Llongfile) != 0 {GoCover_0_383336666631383465376234.Count[29] = 1;
		// Release lock while getting caller info - it's expensive.
		l.mu.Unlock()
		var ok bool
		_, file, line, ok = runtime.Caller(calldepth)
		if !ok {GoCover_0_383336666631383465376234.Count[31] = 1;
			file = "???"
			line = 0
		}
		GoCover_0_383336666631383465376234.Count[30] = 1;l.mu.Lock()
	}
	GoCover_0_383336666631383465376234.Count[27] = 1;l.buf = l.buf[:0]
	l.formatHeader(&l.buf, now, file, line)
	l.buf = append(l.buf, s...)
	if len(s) == 0 || s[len(s)-1] != '\n' {GoCover_0_383336666631383465376234.Count[32] = 1;
		l.buf = append(l.buf, '\n')
	}
	GoCover_0_383336666631383465376234.Count[28] = 1;_, err := l.out.Write(l.buf)
	return err
}

// Printf calls l.Output to print to the logger.
// Arguments are handled in the manner of fmt.Printf.
func (l *Logger) Printf(format string, v ...interface{}) {GoCover_0_383336666631383465376234.Count[33] = 1;
	l.Output(2, fmt.Sprintf(format, v...))
}

// Print calls l.Output to print to the logger.
// Arguments are handled in the manner of fmt.Print.
func (l *Logger) Print(v ...interface{}) {GoCover_0_383336666631383465376234.Count[34] = 1; l.Output(2, fmt.Sprint(v...)) }

// Println calls l.Output to print to the logger.
// Arguments are handled in the manner of fmt.Println.
func (l *Logger) Println(v ...interface{}) {GoCover_0_383336666631383465376234.Count[35] = 1; l.Output(2, fmt.Sprintln(v...)) }

// Fatal is equivalent to l.Print() followed by a call to os.Exit(1).
func (l *Logger) Fatal(v ...interface{}) {GoCover_0_383336666631383465376234.Count[36] = 1;
	l.Output(2, fmt.Sprint(v...))
	os.Exit(1)
}

// Fatalf is equivalent to l.Printf() followed by a call to os.Exit(1).
func (l *Logger) Fatalf(format string, v ...interface{}) {GoCover_0_383336666631383465376234.Count[37] = 1;
	l.Output(2, fmt.Sprintf(format, v...))
	os.Exit(1)
}

// Fatalln is equivalent to l.Println() followed by a call to os.Exit(1).
func (l *Logger) Fatalln(v ...interface{}) {GoCover_0_383336666631383465376234.Count[38] = 1;
	l.Output(2, fmt.Sprintln(v...))
	os.Exit(1)
}

// Panic is equivalent to l.Print() followed by a call to panic().
func (l *Logger) Panic(v ...interface{}) {GoCover_0_383336666631383465376234.Count[39] = 1;
	s := fmt.Sprint(v...)
	l.Output(2, s)
	panic(s)
}

// Panicf is equivalent to l.Printf() followed by a call to panic().
func (l *Logger) Panicf(format string, v ...interface{}) {GoCover_0_383336666631383465376234.Count[40] = 1;
	s := fmt.Sprintf(format, v...)
	l.Output(2, s)
	panic(s)
}

// Panicln is equivalent to l.Println() followed by a call to panic().
func (l *Logger) Panicln(v ...interface{}) {GoCover_0_383336666631383465376234.Count[41] = 1;
	s := fmt.Sprintln(v...)
	l.Output(2, s)
	panic(s)
}

// Flags returns the output flags for the logger.
// The flag bits are Ldate, Ltime, and so on.
func (l *Logger) Flags() int {GoCover_0_383336666631383465376234.Count[42] = 1;
	l.mu.Lock()
	defer l.mu.Unlock()
	return l.flag
}

// SetFlags sets the output flags for the logger.
// The flag bits are Ldate, Ltime, and so on.
func (l *Logger) SetFlags(flag int) {GoCover_0_383336666631383465376234.Count[43] = 1;
	l.mu.Lock()
	defer l.mu.Unlock()
	l.flag = flag
}

// Prefix returns the output prefix for the logger.
func (l *Logger) Prefix() string {GoCover_0_383336666631383465376234.Count[44] = 1;
	l.mu.Lock()
	defer l.mu.Unlock()
	return l.prefix
}

// SetPrefix sets the output prefix for the logger.
func (l *Logger) SetPrefix(prefix string) {GoCover_0_383336666631383465376234.Count[45] = 1;
	l.mu.Lock()
	defer l.mu.Unlock()
	l.prefix = prefix
}

// Writer returns the output destination for the logger.
func (l *Logger) Writer() io.Writer {GoCover_0_383336666631383465376234.Count[46] = 1;
	l.mu.Lock()
	defer l.mu.Unlock()
	return l.out
}

// SetOutput sets the output destination for the standard logger.
func SetOutput(w io.Writer) {GoCover_0_383336666631383465376234.Count[47] = 1;
	std.mu.Lock()
	defer std.mu.Unlock()
	std.out = w
}

// Flags returns the output flags for the standard logger.
// The flag bits are Ldate, Ltime, and so on.
func Flags() int {GoCover_0_383336666631383465376234.Count[48] = 1;
	return std.Flags()
}

// SetFlags sets the output flags for the standard logger.
// The flag bits are Ldate, Ltime, and so on.
func SetFlags(flag int) {GoCover_0_383336666631383465376234.Count[49] = 1;
	std.SetFlags(flag)
}

// Prefix returns the output prefix for the standard logger.
func Prefix() string {GoCover_0_383336666631383465376234.Count[50] = 1;
	return std.Prefix()
}

// SetPrefix sets the output prefix for the standard logger.
func SetPrefix(prefix string) {GoCover_0_383336666631383465376234.Count[51] = 1;
	std.SetPrefix(prefix)
}

// Writer returns the output destination for the standard logger.
func Writer() io.Writer {GoCover_0_383336666631383465376234.Count[52] = 1;
	return std.Writer()
}

// These functions write to the standard logger.

// Print calls Output to print to the standard logger.
// Arguments are handled in the manner of fmt.Print.
func Print(v ...interface{}) {GoCover_0_383336666631383465376234.Count[53] = 1;
	std.Output(2, fmt.Sprint(v...))
}

// Printf calls Output to print to the standard logger.
// Arguments are handled in the manner of fmt.Printf.
func Printf(format string, v ...interface{}) {GoCover_0_383336666631383465376234.Count[54] = 1;
	std.Output(2, fmt.Sprintf(format, v...))
}

// Println calls Output to print to the standard logger.
// Arguments are handled in the manner of fmt.Println.
func Println(v ...interface{}) {GoCover_0_383336666631383465376234.Count[55] = 1;
	std.Output(2, fmt.Sprintln(v...))
}

// Fatal is equivalent to Print() followed by a call to os.Exit(1).
func Fatal(v ...interface{}) {GoCover_0_383336666631383465376234.Count[56] = 1;
	std.Output(2, fmt.Sprint(v...))
	os.Exit(1)
}

// Fatalf is equivalent to Printf() followed by a call to os.Exit(1).
func Fatalf(format string, v ...interface{}) {GoCover_0_383336666631383465376234.Count[57] = 1;
	std.Output(2, fmt.Sprintf(format, v...))
	os.Exit(1)
}

// Fatalln is equivalent to Println() followed by a call to os.Exit(1).
func Fatalln(v ...interface{}) {GoCover_0_383336666631383465376234.Count[58] = 1;
	std.Output(2, fmt.Sprintln(v...))
	os.Exit(1)
}

// Panic is equivalent to Print() followed by a call to panic().
func Panic(v ...interface{}) {GoCover_0_383336666631383465376234.Count[59] = 1;
	s := fmt.Sprint(v...)
	std.Output(2, s)
	panic(s)
}

// Panicf is equivalent to Printf() followed by a call to panic().
func Panicf(format string, v ...interface{}) {GoCover_0_383336666631383465376234.Count[60] = 1;
	s := fmt.Sprintf(format, v...)
	std.Output(2, s)
	panic(s)
}

// Panicln is equivalent to Println() followed by a call to panic().
func Panicln(v ...interface{}) {GoCover_0_383336666631383465376234.Count[61] = 1;
	s := fmt.Sprintln(v...)
	std.Output(2, s)
	panic(s)
}

// Output writes the output for a logging event. The string s contains
// the text to print after the prefix specified by the flags of the
// Logger. A newline is appended if the last character of s is not
// already a newline. Calldepth is the count of the number of
// frames to skip when computing the file name and line number
// if Llongfile or Lshortfile is set; a value of 1 will print the details
// for the caller of Output.
func Output(calldepth int, s string) error {GoCover_0_383336666631383465376234.Count[62] = 1;
	return std.Output(calldepth+1, s) // +1 for this frame.
}

var GoCover_0_383336666631383465376234 = struct {
	Count     [63]uint32
	Pos       [3 * 63]uint32
	NumStmt   [63]uint16
} {
	Pos: [3 * 63]uint32{
		65, 67, 0x2003a, // [0]
		70, 74, 0x20029, // [1]
		79, 79, 0x260018, // [2]
		82, 86, 0x190028, // [3]
		94, 95, 0x200002, // [4]
		86, 92, 0x30019, // [5]
		103, 104, 0x1c0050, // [6]
		107, 107, 0x2d0002, // [7]
		134, 134, 0x280002, // [8]
		150, 150, 0x1c0002, // [9]
		104, 106, 0x3001c, // [10]
		107, 108, 0x17002d, // [11]
		111, 111, 0x180003, // [12]
		120, 120, 0x280003, // [13]
		108, 110, 0x40017, // [14]
		111, 119, 0x40018, // [15]
		120, 127, 0x210028, // [16]
		131, 131, 0x1c0004, // [17]
		127, 130, 0x50021, // [18]
		134, 135, 0x1d0028, // [19]
		145, 148, 0x1f0003, // [20]
		135, 137, 0x27001d, // [21]
		143, 143, 0x100004, // [22]
		137, 138, 0x170027, // [23]
		138, 140, 0xb0017, // [24]
		150, 152, 0x3001c, // [25]
		161, 167, 0x280038, // [26]
		178, 181, 0x280002, // [27]
		184, 185, 0xc0002, // [28]
		167, 172, 0xa0028, // [29]
		176, 176, 0xe0003, // [30]
		172, 175, 0x4000a, // [31]
		181, 183, 0x30028, // [32]
		190, 192, 0x2003a, // [33]
		196, 196, 0x4b002a, // [34]
		200, 200, 0x4f002c, // [35]
		203, 206, 0x2002a, // [36]
		209, 212, 0x2003a, // [37]
		215, 218, 0x2002c, // [38]
		221, 224, 0xa002a, // [39]
		228, 231, 0xa003a, // [40]
		235, 238, 0xa002c, // [41]
		243, 247, 0x2001e, // [42]
		251, 255, 0x20025, // [43]
		258, 262, 0x20022, // [44]
		265, 269, 0x2002b, // [45]
		272, 276, 0x20025, // [46]
		279, 283, 0x2001d, // [47]
		287, 289, 0x20012, // [48]
		293, 295, 0x20019, // [49]
		298, 300, 0x20016, // [50]
		303, 305, 0x2001f, // [51]
		308, 310, 0x20019, // [52]
		316, 318, 0x2001e, // [53]
		322, 324, 0x2002e, // [54]
		328, 330, 0x20020, // [55]
		333, 336, 0x2001e, // [56]
		339, 342, 0x2002e, // [57]
		345, 348, 0x20020, // [58]
		351, 354, 0xa001e, // [59]
		358, 361, 0xa002e, // [60]
		365, 368, 0xa0020, // [61]
		378, 380, 0x2002c, // [62]
	},
	NumStmt: [63]uint16{
		1, // 0
		3, // 1
		1, // 2
		3, // 3
		2, // 4
		5, // 5
		1, // 6
		1, // 7
		1, // 8
		1, // 9
		1, // 10
		1, // 11
		1, // 12
		1, // 13
		1, // 14
		7, // 15
		7, // 16
		1, // 17
		2, // 18
		1, // 19
		4, // 20
		2, // 21
		1, // 22
		1, // 23
		2, // 24
		1, // 25
		6, // 26
		4, // 27
		2, // 28
		4, // 29
		1, // 30
		2, // 31
		1, // 32
		1, // 33
		1, // 34
		1, // 35
		2, // 36
		2, // 37
		2, // 38
		3, // 39
		3, // 40
		3, // 41
		3, // 42
		3, // 43
		3, // 44
		3, // 45
		3, // 46
		3, // 47
		1, // 48
		1, // 49
		1, // 50
		1, // 51
		1, // 52
		1, // 53
		1, // 54
		1, // 55
		2, // 56
		2, // 57
		2, // 58
		3, // 59
		3, // 60
		3, // 61
		1, // 62
	},
}
