package logger
import "github.com/evanw/esbuild/internal/logger"
Index ¶
- Constants
- Variables
- func PlatformIndependentPathDirBaseExt(path string) (dir string, base string, ext string)
- func PrintErrorToStderr(osArgs []string, text string)
- func PrintMessageToStderr(osArgs []string, msg Msg)
- func PrintSummary(useColor UseColor, table SummaryTable, start *time.Time)
- func PrintText(file *os.File, level LogLevel, osArgs []string, callback func(Colors) string)
- func PrintTextWithColor(file *os.File, useColor UseColor, callback func(Colors) string)
- type APIKind
- type Colors
- type DeferLogKind
- type LineColumnTracker
- func MakeLineColumnTracker(source *Source) LineColumnTracker
- func (tracker *LineColumnTracker) MsgData(r Range, text string) MsgData
- func (tracker *LineColumnTracker) MsgLocationOrNil(r Range) *MsgLocation
- type Loc
- type Log
- func NewDeferLog(kind DeferLogKind) Log
- func NewStderrLog(options OutputOptions) Log
- func (log Log) Add(kind MsgKind, tracker *LineColumnTracker, r Range, text string)
- func (log Log) AddWithNotes(kind MsgKind, tracker *LineColumnTracker, r Range, text string, notes []MsgData)
- type LogLevel
- type Msg
- type MsgData
- type MsgDetail
- type MsgKind
- type MsgLocation
- type OutputOptions
- type Path
- type PathFlags
- type Range
- type SortableMsgs
- func (a SortableMsgs) Len() int
- func (a SortableMsgs) Less(i int, j int) bool
- func (a SortableMsgs) Swap(i int, j int)
- type Source
- func (s *Source) LocBeforeWhitespace(loc Loc) Loc
- func (s *Source) RangeOfLegacyOctalEscape(loc Loc) (r Range)
- func (s *Source) RangeOfNumber(loc Loc) (r Range)
- func (s *Source) RangeOfOperatorAfter(loc Loc, op string) Range
- func (s *Source) RangeOfOperatorBefore(loc Loc, op string) Range
- func (s *Source) RangeOfString(loc Loc) Range
- func (s *Source) TextForRange(r Range) string
- type Span
- type SummaryTable
- func (t SummaryTable) Len() int
- func (t SummaryTable) Less(i int, j int) bool
- func (t SummaryTable) Swap(i int, j int)
- type SummaryTableEntry
- type TerminalInfo
- type UseColor
Constants ¶
const ( FOREGROUND_BLUE uint8 = 1 << iota FOREGROUND_GREEN FOREGROUND_RED FOREGROUND_INTENSITY BACKGROUND_BLUE BACKGROUND_GREEN BACKGROUND_RED BACKGROUND_INTENSITY )
const SupportsColorEscapes = true
Variables ¶
var TerminalColors = Colors{ Reset: "\033[0m", Bold: "\033[1m", Dim: "\033[37m", Underline: "\033[4m", Red: "\033[31m", Green: "\033[32m", Blue: "\033[34m", Cyan: "\033[36m", Magenta: "\033[35m", Yellow: "\033[33m", RedBgRed: "\033[41;31m", RedBgWhite: "\033[41;97m", GreenBgGreen: "\033[42;32m", GreenBgWhite: "\033[42;97m", BlueBgBlue: "\033[44;34m", BlueBgWhite: "\033[44;97m", CyanBgCyan: "\033[46;36m", CyanBgBlack: "\033[46;30m", MagentaBgMagenta: "\033[45;35m", MagentaBgBlack: "\033[45;30m", YellowBgYellow: "\033[43;33m", YellowBgBlack: "\033[43;30m", }
Functions ¶
func PlatformIndependentPathDirBaseExt ¶
This has a custom implementation instead of using "filepath.Dir/Base/Ext" because it should work the same on Unix and Windows. These names end up in the generated output and the generated output should not depend on the OS.
func PrintErrorToStderr ¶
func PrintMessageToStderr ¶
func PrintSummary ¶
func PrintSummary(useColor UseColor, table SummaryTable, start *time.Time)
func PrintText ¶
func PrintTextWithColor ¶
Types ¶
type APIKind ¶
type APIKind uint8
var API APIKind
This can be used to customize error messages for the current API kind
type Colors ¶
type Colors struct { Reset string Bold string Dim string Underline string Red string Green string Blue string Cyan string Magenta string Yellow string RedBgRed string RedBgWhite string GreenBgGreen string GreenBgWhite string BlueBgBlue string BlueBgWhite string CyanBgCyan string CyanBgBlack string MagentaBgMagenta string MagentaBgBlack string YellowBgYellow string YellowBgBlack string }
type DeferLogKind ¶
type DeferLogKind uint8
const ( DeferLogAll DeferLogKind = iota DeferLogNoVerboseOrDebug )
type LineColumnTracker ¶
type LineColumnTracker struct {
// contains filtered or unexported fields
}
It's not common for large files to have many warnings. But when it happens, we want to make sure that it's not too slow. Source code locations are represented as byte offsets for compactness but transforming these to line/column locations for warning messages requires scanning through the file. A naive approach for this would cause O(n^2) scanning time for n warnings distributed throughout the file.
Warnings are typically generated sequentially as the file is scanned. So one way of optimizing this is to just start scanning from where we left off last time instead of always starting from the beginning of the file. That's what this object does.
Another option could be to eagerly populate an array of line/column offsets and then use binary search for each query. This might slow down the common case of a file with only at most a few warnings though, so think before optimizing too much. Performance in the zero or one warning case is by far the most important.
func MakeLineColumnTracker ¶
func MakeLineColumnTracker(source *Source) LineColumnTracker
func (*LineColumnTracker) MsgData ¶
func (tracker *LineColumnTracker) MsgData(r Range, text string) MsgData
func (*LineColumnTracker) MsgLocationOrNil ¶
func (tracker *LineColumnTracker) MsgLocationOrNil(r Range) *MsgLocation
type Loc ¶
type Loc struct { // This is the 0-based index of this location from the start of the file, in bytes Start int32 }
type Log ¶
type Log struct { Level LogLevel AddMsg func(Msg) HasErrors func() bool // This is called after the build has finished but before writing to stdout. // It exists to ensure that deferred warning messages end up in the terminal // before the data written to stdout. AlmostDone func() Done func() []Msg }
func NewDeferLog ¶
func NewDeferLog(kind DeferLogKind) Log
func NewStderrLog ¶
func NewStderrLog(options OutputOptions) Log
func (Log) Add ¶
func (log Log) Add(kind MsgKind, tracker *LineColumnTracker, r Range, text string)
func (Log) AddWithNotes ¶
func (log Log) AddWithNotes(kind MsgKind, tracker *LineColumnTracker, r Range, text string, notes []MsgData)
type LogLevel ¶
type LogLevel int8
const ( LevelNone LogLevel = iota LevelVerbose LevelDebug LevelInfo LevelWarning LevelError LevelSilent )
type Msg ¶
func (Msg) String ¶
func (msg Msg) String(options OutputOptions, terminalInfo TerminalInfo) string
type MsgData ¶
type MsgData struct { Text string Location *MsgLocation // Optional user-specified data that is passed through unmodified UserDetail interface{} }
type MsgDetail ¶
type MsgDetail struct { Path string Line int Column int SourceBefore string SourceMarked string SourceAfter string Indent string Marker string Suggestion string ContentAfter string }
type MsgKind ¶
type MsgKind uint8
func (MsgKind) Icon ¶
func (MsgKind) String ¶
type MsgLocation ¶
type MsgLocation struct { File string Namespace string Line int // 1-based Column int // 0-based, in bytes Length int // in bytes LineText string Suggestion string }
type OutputOptions ¶
func OutputOptionsForArgs ¶
func OutputOptionsForArgs(osArgs []string) OutputOptions
type Path ¶
type Path struct { Text string Namespace string // This feature was added to support ancient CSS libraries that append things // like "?#iefix" and "#icons" to some of their import paths as a hack for IE6. // The intent is for these suffix parts to be ignored but passed through to // the output. This is supported by other bundlers, so we also support this. IgnoredSuffix string Flags PathFlags }
This is used to represent both file system paths (Namespace == "file") and abstract module paths (Namespace != "file"). Abstract module paths represent "virtual modules" when used for an input file and "package paths" when used to represent an external module.
func (Path) ComesBeforeInSortedOrder ¶
func (Path) IsDisabled ¶
type PathFlags ¶
type PathFlags uint8
const ( // This corresponds to a value of "false' in the "browser" package.json field PathDisabled PathFlags = 1 << iota )
type Range ¶
func (Range) End ¶
type SortableMsgs ¶
type SortableMsgs []Msg
This type is just so we can use Go's native sort function
func (SortableMsgs) Len ¶
func (a SortableMsgs) Len() int
func (SortableMsgs) Less ¶
func (a SortableMsgs) Less(i int, j int) bool
func (SortableMsgs) Swap ¶
func (a SortableMsgs) Swap(i int, j int)
type Source ¶
type Source struct { Index uint32 // This is used as a unique key to identify this source file. It should never // be shown to the user (e.g. never print this to the terminal). // // If it's marked as an absolute path, it's a platform-dependent path that // includes environment-specific things such as Windows backslash path // separators and potentially the user's home directory. Only use this for // passing to syscalls for reading and writing to the file system. Do not // include this in any output data. // // If it's marked as not an absolute path, it's an opaque string that is used // to refer to an automatically-generated module. KeyPath Path // This is used for error messages and the metadata JSON file. // // This is a mostly platform-independent path. It's relative to the current // working directory and always uses standard path separators. Use this for // referencing a file in all output data. These paths still use the original // case of the path so they may still work differently on file systems that // are case-insensitive vs. case-sensitive. PrettyPath string // An identifier that is mixed in to automatically-generated symbol names to // improve readability. For example, if the identifier is "util" then the // symbol for an "export default" statement will be called "util_default". IdentifierName string Contents string }
func (*Source) LocBeforeWhitespace ¶
func (*Source) RangeOfLegacyOctalEscape ¶
func (*Source) RangeOfNumber ¶
func (*Source) RangeOfOperatorAfter ¶
func (*Source) RangeOfOperatorBefore ¶
func (*Source) RangeOfString ¶
func (*Source) TextForRange ¶
type Span ¶
type SummaryTable ¶
type SummaryTable []SummaryTableEntry
This type is just so we can use Go's native sort function
func (SummaryTable) Len ¶
func (t SummaryTable) Len() int
func (SummaryTable) Less ¶
func (t SummaryTable) Less(i int, j int) bool
func (SummaryTable) Swap ¶
func (t SummaryTable) Swap(i int, j int)
type SummaryTableEntry ¶
type TerminalInfo ¶
func GetTerminalInfo ¶
func GetTerminalInfo(file *os.File) TerminalInfo
type UseColor ¶
type UseColor uint8
Source Files ¶
- Version
- v0.14.5
- Published
- Dec 14, 2021
- Platform
- windows/amd64
- Imports
- 10 packages
- Last checked
- 4 hours ago –
Tools for package owners.