package logger

import "github.com/evanw/esbuild/internal/logger"

Index

Constants

const SupportsColorEscapes = true

Functions

func PlatformIndependentPathDirBaseExt

func PlatformIndependentPathDirBaseExt(path string) (dir string, base string, ext string)

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 PrintErrorToStderr(osArgs []string, text string)

func PrintMessageToStderr

func PrintMessageToStderr(osArgs []string, msg Msg)

func PrintSummary

func PrintSummary(osArgs []string, table SummaryTable, start time.Time)

func PrintText

func PrintText(file *os.File, level LogLevel, osArgs []string, callback func(Colors) string)

Types

type Colors

type Colors struct {
	Default string
	Bold    string
	Dim     string

	Red   string
	Green string
	Blue  string

	Cyan    string
	Magenta string
	Yellow  string

	Underline string
}

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 {
	AddMsg    func(Msg)
	HasErrors func() bool
	Done      func() []Msg
}

func NewDeferLog

func NewDeferLog() Log

func NewStderrLog

func NewStderrLog(options OutputOptions) Log

func (Log) AddError

func (log Log) AddError(source *Source, loc Loc, text string)

func (Log) AddErrorWithNotes

func (log Log) AddErrorWithNotes(source *Source, loc Loc, text string, notes []MsgData)

func (Log) AddRangeError

func (log Log) AddRangeError(source *Source, r Range, text string)

func (Log) AddRangeErrorWithNotes

func (log Log) AddRangeErrorWithNotes(source *Source, r Range, text string, notes []MsgData)

func (Log) AddRangeWarning

func (log Log) AddRangeWarning(source *Source, r Range, text string)

func (Log) AddRangeWarningWithNotes

func (log Log) AddRangeWarningWithNotes(source *Source, r Range, text string, notes []MsgData)

func (Log) AddWarning

func (log Log) AddWarning(source *Source, loc Loc, text string)

type LogLevel

type LogLevel int8
const (
	LevelNone LogLevel = iota
	LevelInfo
	LevelWarning
	LevelError
	LevelSilent
)

type Msg

type Msg struct {
	Kind  MsgKind
	Data  MsgData
	Notes []MsgData
}

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{}
}

func RangeData

func RangeData(source *Source, r Range, text string) MsgData

type MsgDetail

type MsgDetail struct {
	Path    string
	Line    int
	Column  int
	Message string

	SourceBefore string
	SourceMarked string
	SourceAfter  string

	Indent string
	Marker string

	ContentAfter string
}

type MsgKind

type MsgKind uint8
const (
	Error MsgKind = iota
	Warning
	Note
)

func (MsgKind) String

func (kind MsgKind) String() 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
}

func LocationOrNil

func LocationOrNil(source *Source, r Range) *MsgLocation

type OutputOptions

type OutputOptions struct {
	IncludeSource bool
	ErrorLimit    int
	Color         UseColor
	LogLevel      LogLevel

	// This is used with watch mode
	NewlineBeforeFirstMessage bool
}

func OutputOptionsForArgs

func OutputOptionsForArgs(osArgs []string) OutputOptions

func (*OutputOptions) MaybeWriteFirstNewline

func (opts *OutputOptions) MaybeWriteFirstNewline(file *os.File)

type Path

type Path struct {
	Text      string
	Namespace string
}

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 (a Path) ComesBeforeInSortedOrder(b Path) bool

type Range

type Range struct {
	Loc Loc
	Len int32
}

func (Range) End

func (r Range) End() int32

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) RangeOfNumber

func (s *Source) RangeOfNumber(loc Loc) (r Range)

func (*Source) RangeOfOperatorAfter

func (s *Source) RangeOfOperatorAfter(loc Loc, op string) Range

func (*Source) RangeOfOperatorBefore

func (s *Source) RangeOfOperatorBefore(loc Loc, op string) Range

func (*Source) RangeOfString

func (s *Source) RangeOfString(loc Loc) Range

func (*Source) TextForRange

func (s *Source) TextForRange(r Range) string

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 SummaryTableEntry struct {
	Dir         string
	Base        string
	Size        string
	Bytes       int
	IsSourceMap bool
}

type TerminalInfo

type TerminalInfo struct {
	IsTTY           bool
	UseColorEscapes bool
	Width           int
}

func GetTerminalInfo

func GetTerminalInfo(file *os.File) TerminalInfo

type UseColor

type UseColor uint8
const (
	ColorIfTerminal UseColor = iota
	ColorNever
	ColorAlways
)

Source Files

logger.go logger_windows.go

Version
v0.8.40
Published
Feb 4, 2021
Platform
windows/amd64
Imports
9 packages
Last checked
42 minutes ago

Tools for package owners.