logging

package
v0.6.33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const SupportsColorEscapes = true

Variables

This section is empty.

Functions

func PrintErrorToStderr added in v0.5.0

func PrintErrorToStderr(osArgs []string, text string)

Types

type Log

type Log struct {
	// contains filtered or unexported fields
}

func NewDeferLog

func NewDeferLog() Log

func NewStderrLog

func NewStderrLog(options StderrOptions) Log

func (Log) AddError

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

func (Log) AddRangeError

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

func (Log) AddRangeWarning

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

func (Log) AddWarning

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

func (Log) Done added in v0.5.5

func (log Log) Done() []Msg

func (Log) HasErrors added in v0.5.5

func (log Log) HasErrors() bool

type LogLevel added in v0.4.1

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

type Msg

type Msg struct {
	Kind     MsgKind
	Text     string
	Location *MsgLocation
}

func (Msg) String

func (msg Msg) String(options StderrOptions, terminalInfo TerminalInfo) string

type MsgDetail

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

	// Source == SourceBefore + SourceMarked + SourceAfter
	Source       string
	SourceBefore string
	SourceMarked string
	SourceAfter  string

	Indent string
	Marker string
}

type MsgKind

type MsgKind uint8
const (
	Error MsgKind = iota
	Warning
)

type MsgLocation added in v0.6.0

type MsgLocation struct {
	File     string
	Line     int // 1-based
	Column   int // 0-based, in bytes
	Length   int // in bytes
	LineText string
}

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 ast.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 added in v0.6.29

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

func (*Source) RangeOfString

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

func (*Source) TextForRange

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

type StderrColor

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

type StderrOptions

type StderrOptions struct {
	IncludeSource bool
	ErrorLimit    int
	Color         StderrColor
	LogLevel      LogLevel
}

type TerminalInfo

type TerminalInfo struct {
	IsTTY           bool
	UseColorEscapes bool
	Width           int
}

func GetTerminalInfo added in v0.3.0

func GetTerminalInfo(file *os.File) (info TerminalInfo)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL