//line /home/evie/packages/go/go-1.18-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"
	"sync/atomic"
	"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
	isDiscard int32      // atomic boolean: whether out == io.Discard
}

// 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;
	l := &Logger{out: out, prefix: prefix, flag: flag}
	if out == io.Discard {GoCover_0_383336666631383465376234.Count[2] = 1;
		l.isDiscard = 1
	}
	GoCover_0_383336666631383465376234.Count[1] = 1;return l
}

// SetOutput sets the output destination for the logger.
func (l *Logger) SetOutput(w io.Writer) {GoCover_0_383336666631383465376234.Count[3] = 1;
	l.mu.Lock()
	defer l.mu.Unlock()
	l.out = w
	isDiscard := int32(0)
	if w == io.Discard {GoCover_0_383336666631383465376234.Count[5] = 1;
		isDiscard = 1
	}
	GoCover_0_383336666631383465376234.Count[4] = 1;atomic.StoreInt32(&l.isDiscard, isDiscard)
}

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[6] = 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[7] = 1;
	// Assemble decimal in reverse order.
	var b [20]byte
	bp := len(b) - 1
	for i >= 10 || wid > 1 {GoCover_0_383336666631383465376234.Count[9] = 1;
		wid--
		q := i / 10
		b[bp] = byte('0' + i - q*10)
		bp--
		i = q
	}
	// i < 10
	GoCover_0_383336666631383465376234.Count[8] = 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[10] = 1;
	if l.flag&Lmsgprefix == 0 {GoCover_0_383336666631383465376234.Count[14] = 1;
		*buf = append(*buf, l.prefix...)
	}
	GoCover_0_383336666631383465376234.Count[11] = 1;if l.flag&(Ldate|Ltime|Lmicroseconds) != 0 {GoCover_0_383336666631383465376234.Count[15] = 1;
		if l.flag&LUTC != 0 {GoCover_0_383336666631383465376234.Count[18] = 1;
			t = t.UTC()
		}
		GoCover_0_383336666631383465376234.Count[16] = 1;if l.flag&Ldate != 0 {GoCover_0_383336666631383465376234.Count[19] = 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[17] = 1;if l.flag&(Ltime|Lmicroseconds) != 0 {GoCover_0_383336666631383465376234.Count[20] = 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[22] = 1;
				*buf = append(*buf, '.')
				itoa(buf, t.Nanosecond()/1e3, 6)
			}
			GoCover_0_383336666631383465376234.Count[21] = 1;*buf = append(*buf, ' ')
		}
	}
	GoCover_0_383336666631383465376234.Count[12] = 1;if l.flag&(Lshortfile|Llongfile) != 0 {GoCover_0_383336666631383465376234.Count[23] = 1;
		if l.flag&Lshortfile != 0 {GoCover_0_383336666631383465376234.Count[25] = 1;
			short := file
			for i := len(file) - 1; i > 0; i-- {GoCover_0_383336666631383465376234.Count[27] = 1;
				if file[i] == '/' {GoCover_0_383336666631383465376234.Count[28] = 1;
					short = file[i+1:]
					break
				}
			}
			GoCover_0_383336666631383465376234.Count[26] = 1;file = short
		}
		GoCover_0_383336666631383465376234.Count[24] = 1;*buf = append(*buf, file...)
		*buf = append(*buf, ':')
		itoa(buf, line, -1)
		*buf = append(*buf, ": "...)
	}
	GoCover_0_383336666631383465376234.Count[13] = 1;if l.flag&Lmsgprefix != 0 {GoCover_0_383336666631383465376234.Count[29] = 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[30] = 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[33] = 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[35] = 1;
			file = "???"
			line = 0
		}
		GoCover_0_383336666631383465376234.Count[34] = 1;l.mu.Lock()
	}
	GoCover_0_383336666631383465376234.Count[31] = 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[36] = 1;
		l.buf = append(l.buf, '\n')
	}
	GoCover_0_383336666631383465376234.Count[32] = 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 ...any) {GoCover_0_383336666631383465376234.Count[37] = 1;
	if atomic.LoadInt32(&l.isDiscard) != 0 {GoCover_0_383336666631383465376234.Count[39] = 1;
		return
	}
	GoCover_0_383336666631383465376234.Count[38] = 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 ...any) {GoCover_0_383336666631383465376234.Count[40] = 1;
	if atomic.LoadInt32(&l.isDiscard) != 0 {GoCover_0_383336666631383465376234.Count[42] = 1;
		return
	}
	GoCover_0_383336666631383465376234.Count[41] = 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 ...any) {GoCover_0_383336666631383465376234.Count[43] = 1;
	if atomic.LoadInt32(&l.isDiscard) != 0 {GoCover_0_383336666631383465376234.Count[45] = 1;
		return
	}
	GoCover_0_383336666631383465376234.Count[44] = 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 ...any) {GoCover_0_383336666631383465376234.Count[46] = 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 ...any) {GoCover_0_383336666631383465376234.Count[47] = 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 ...any) {GoCover_0_383336666631383465376234.Count[48] = 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 ...any) {GoCover_0_383336666631383465376234.Count[49] = 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 ...any) {GoCover_0_383336666631383465376234.Count[50] = 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 ...any) {GoCover_0_383336666631383465376234.Count[51] = 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[52] = 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[53] = 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[54] = 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[55] = 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[56] = 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[57] = 1;
	std.SetOutput(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[58] = 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[59] = 1;
	std.SetFlags(flag)
}

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

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

// Writer returns the output destination for the standard logger.
func Writer() io.Writer {GoCover_0_383336666631383465376234.Count[62] = 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 ...any) {GoCover_0_383336666631383465376234.Count[63] = 1;
	if atomic.LoadInt32(&std.isDiscard) != 0 {GoCover_0_383336666631383465376234.Count[65] = 1;
		return
	}
	GoCover_0_383336666631383465376234.Count[64] = 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 ...any) {GoCover_0_383336666631383465376234.Count[66] = 1;
	if atomic.LoadInt32(&std.isDiscard) != 0 {GoCover_0_383336666631383465376234.Count[68] = 1;
		return
	}
	GoCover_0_383336666631383465376234.Count[67] = 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 ...any) {GoCover_0_383336666631383465376234.Count[69] = 1;
	if atomic.LoadInt32(&std.isDiscard) != 0 {GoCover_0_383336666631383465376234.Count[71] = 1;
		return
	}
	GoCover_0_383336666631383465376234.Count[70] = 1;std.Output(2, fmt.Sprintln(v...))
}

// Fatal is equivalent to Print() followed by a call to os.Exit(1).
func Fatal(v ...any) {GoCover_0_383336666631383465376234.Count[72] = 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 ...any) {GoCover_0_383336666631383465376234.Count[73] = 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 ...any) {GoCover_0_383336666631383465376234.Count[74] = 1;
	std.Output(2, fmt.Sprintln(v...))
	os.Exit(1)
}

// Panic is equivalent to Print() followed by a call to panic().
func Panic(v ...any) {GoCover_0_383336666631383465376234.Count[75] = 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 ...any) {GoCover_0_383336666631383465376234.Count[76] = 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 ...any) {GoCover_0_383336666631383465376234.Count[77] = 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[78] = 1;
	return std.Output(calldepth+1, s) // +1 for this frame.
}

var GoCover_0_383336666631383465376234 = struct {
	Count     [79]uint32
	Pos       [3 * 79]uint32
	NumStmt   [79]uint16
} {
	Pos: [3 * 79]uint32{
		67, 69, 0x17003a, // [0]
		72, 72, 0xa0002, // [1]
		69, 71, 0x30017, // [2]
		76, 81, 0x150029, // [3]
		84, 84, 0x2c0002, // [4]
		81, 83, 0x30015, // [5]
		90, 90, 0x260018, // [6]
		93, 97, 0x190028, // [7]
		105, 106, 0x200002, // [8]
		97, 103, 0x30019, // [9]
		114, 115, 0x1c0050, // [10]
		118, 118, 0x2d0002, // [11]
		145, 145, 0x280002, // [12]
		161, 161, 0x1c0002, // [13]
		115, 117, 0x3001c, // [14]
		118, 119, 0x17002d, // [15]
		122, 122, 0x180003, // [16]
		131, 131, 0x280003, // [17]
		119, 121, 0x40017, // [18]
		122, 130, 0x40018, // [19]
		131, 138, 0x210028, // [20]
		142, 142, 0x1c0004, // [21]
		138, 141, 0x50021, // [22]
		145, 146, 0x1d0028, // [23]
		156, 159, 0x1f0003, // [24]
		146, 148, 0x27001d, // [25]
		154, 154, 0x100004, // [26]
		148, 149, 0x170027, // [27]
		149, 151, 0xb0017, // [28]
		161, 163, 0x3001c, // [29]
		172, 178, 0x280038, // [30]
		189, 192, 0x280002, // [31]
		195, 196, 0xc0002, // [32]
		178, 183, 0xa0028, // [33]
		187, 187, 0xe0003, // [34]
		183, 186, 0x4000a, // [35]
		192, 194, 0x30028, // [36]
		201, 202, 0x290032, // [37]
		205, 205, 0x280002, // [38]
		202, 204, 0x30029, // [39]
		210, 211, 0x290022, // [40]
		214, 214, 0x1f0002, // [41]
		211, 213, 0x30029, // [42]
		219, 220, 0x290024, // [43]
		223, 223, 0x210002, // [44]
		220, 222, 0x30029, // [45]
		227, 230, 0x20022, // [46]
		233, 236, 0x20032, // [47]
		239, 242, 0x20024, // [48]
		245, 248, 0xa0022, // [49]
		252, 255, 0xa0032, // [50]
		259, 262, 0xa0024, // [51]
		267, 271, 0x2001e, // [52]
		275, 279, 0x20025, // [53]
		282, 286, 0x20022, // [54]
		289, 293, 0x2002b, // [55]
		296, 300, 0x20025, // [56]
		303, 305, 0x2001d, // [57]
		309, 311, 0x20012, // [58]
		315, 317, 0x20019, // [59]
		320, 322, 0x20016, // [60]
		325, 327, 0x2001f, // [61]
		330, 332, 0x20019, // [62]
		338, 339, 0x2b0016, // [63]
		342, 342, 0x210002, // [64]
		339, 341, 0x3002b, // [65]
		347, 348, 0x2b0026, // [66]
		351, 351, 0x2a0002, // [67]
		348, 350, 0x3002b, // [68]
		356, 357, 0x2b0018, // [69]
		360, 360, 0x230002, // [70]
		357, 359, 0x3002b, // [71]
		364, 367, 0x20016, // [72]
		370, 373, 0x20026, // [73]
		376, 379, 0x20018, // [74]
		382, 385, 0xa0016, // [75]
		389, 392, 0xa0026, // [76]
		396, 399, 0xa0018, // [77]
		409, 411, 0x2002c, // [78]
	},
	NumStmt: [79]uint16{
		2, // 0
		1, // 1
		1, // 2
		5, // 3
		1, // 4
		1, // 5
		1, // 6
		3, // 7
		2, // 8
		5, // 9
		1, // 10
		1, // 11
		1, // 12
		1, // 13
		1, // 14
		1, // 15
		1, // 16
		1, // 17
		1, // 18
		7, // 19
		7, // 20
		1, // 21
		2, // 22
		1, // 23
		4, // 24
		2, // 25
		1, // 26
		1, // 27
		2, // 28
		1, // 29
		6, // 30
		4, // 31
		2, // 32
		4, // 33
		1, // 34
		2, // 35
		1, // 36
		1, // 37
		1, // 38
		1, // 39
		1, // 40
		1, // 41
		1, // 42
		1, // 43
		1, // 44
		1, // 45
		2, // 46
		2, // 47
		2, // 48
		3, // 49
		3, // 50
		3, // 51
		3, // 52
		3, // 53
		3, // 54
		3, // 55
		3, // 56
		1, // 57
		1, // 58
		1, // 59
		1, // 60
		1, // 61
		1, // 62
		1, // 63
		1, // 64
		1, // 65
		1, // 66
		1, // 67
		1, // 68
		1, // 69
		1, // 70
		1, // 71
		2, // 72
		2, // 73
		2, // 74
		3, // 75
		3, // 76
		3, // 77
		1, // 78
	},
}
