Skip to content

Commit

Permalink
rename "error limit" to "log limit"
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Mar 9, 2021
1 parent 48306f2 commit 7d30f83
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
console.log(metafile.outputs)
```
* Rename `--error-limit=` to `--log-limit=`
This parameter has been renamed because it now applies to both warnings and errors, not just to errors. Previously setting the error limit did not apply any limits to the number of warnings printed, which could sometimes result in a deluge of warnings that are problematic for Windows Command Prompt, which is very slow to print to and has very limited scrollback. Now the log limit applies to the total number of log messages including both errors and warnings, so no more than that number of messages will be printed. The log usually prints log messages immediately but it will now intentionally hold back warnings when approaching the limit to make room for possible future errors during a build. So if a build fails you should be guaranteed to see an error message (i.e. warnings can't use up the entire log limit and then prevent errors from being printed).

## 0.8.57

* Fix overlapping chunk names when code splitting is active ([#928](https://github.com/evanw/esbuild/issues/928))
Expand Down
2 changes: 1 addition & 1 deletion cmd/esbuild/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var helpText = func(colors logger.Colors) string {
where T is one of: css | js
--charset=utf8 Do not escape UTF-8 code points
--color=... Force use of color terminal escapes (true | false)
--error-limit=... Maximum error count or 0 to disable (default 10)
--log-limit=... Maximum message count or 0 to disable (default 10)
--footer:T=... Text to be appended to each output file of type T
where T is one of: css | js
--global-name=... The name of the global for the IIFE format
Expand Down
2 changes: 1 addition & 1 deletion internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func NewStderrLog(options OutputOptions) Log {

// Print out a summary
if options.MessageLimit > 0 && errors+warnings > options.MessageLimit {
writeStringWithColor(os.Stderr, fmt.Sprintf("%s shown (disable the message limit with --error-limit=0)\n",
writeStringWithColor(os.Stderr, fmt.Sprintf("%s shown (disable the message limit with --log-limit=0)\n",
errorAndWarningSummary(errors, warnings, shownErrors, shownWarnings)))
} else if options.LogLevel <= LevelInfo && (warnings != 0 || errors != 0) {
writeStringWithColor(os.Stderr, fmt.Sprintf("%s\n",
Expand Down
4 changes: 2 additions & 2 deletions lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ type CommonOptions = types.BuildOptions | types.TransformOptions;
function pushLogFlags(flags: string[], options: CommonOptions, keys: OptionKeys, isTTY: boolean, logLevelDefault: types.LogLevel): void {
let color = getFlag(options, keys, 'color', mustBeBoolean);
let logLevel = getFlag(options, keys, 'logLevel', mustBeString);
let errorLimit = getFlag(options, keys, 'errorLimit', mustBeInteger);
let logLimit = getFlag(options, keys, 'logLimit', mustBeInteger);

if (color) flags.push(`--color=${color}`);
else if (isTTY) flags.push(`--color=true`); // This is needed to fix "execFileSync" which buffers stderr
flags.push(`--log-level=${logLevel || logLevelDefault}`);
flags.push(`--error-limit=${errorLimit || 0}`);
flags.push(`--log-limit=${logLimit || 0}`);
}

function pushCommonFlags(flags: string[], options: CommonOptions, keys: OptionKeys): void {
Expand Down
2 changes: 1 addition & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface CommonOptions {

color?: boolean;
logLevel?: LogLevel;
errorLimit?: number;
logLimit?: number;
}

export interface BuildOptions extends CommonOptions {
Expand Down
12 changes: 6 additions & 6 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ const (
// Build API

type BuildOptions struct {
Color StderrColor
ErrorLimit int
LogLevel LogLevel
Color StderrColor
LogLimit int
LogLevel LogLevel

Sourcemap SourceMap
SourcesContent SourcesContent
Expand Down Expand Up @@ -312,9 +312,9 @@ func Build(options BuildOptions) BuildResult {
// Transform API

type TransformOptions struct {
Color StderrColor
ErrorLimit int
LogLevel LogLevel
Color StderrColor
LogLimit int
LogLevel LogLevel

Sourcemap SourceMap
SourcesContent SourcesContent
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/api_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ func buildImpl(buildOpts BuildOptions) internalBuildResult {
start := time.Now()
logOptions := logger.OutputOptions{
IncludeSource: true,
MessageLimit: buildOpts.ErrorLimit,
MessageLimit: buildOpts.LogLimit,
Color: validateColor(buildOpts.Color),
LogLevel: validateLogLevel(buildOpts.LogLevel),
}
Expand Down Expand Up @@ -1109,7 +1109,7 @@ func (w *watcher) tryToFindDirtyPath() string {
func transformImpl(input string, transformOpts TransformOptions) TransformResult {
log := logger.NewStderrLog(logger.OutputOptions{
IncludeSource: true,
MessageLimit: transformOpts.ErrorLimit,
MessageLimit: transformOpts.LogLimit,
Color: validateColor(transformOpts.Color),
LogLevel: validateLogLevel(transformOpts.LogLevel),
})
Expand Down
16 changes: 8 additions & 8 deletions pkg/cli/cli_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,16 @@ func parseOptionsImpl(
}
buildOpts.Footer[value[:equals]] = value[equals+1:]

case strings.HasPrefix(arg, "--error-limit="):
value := arg[len("--error-limit="):]
case strings.HasPrefix(arg, "--log-limit="):
value := arg[len("--log-limit="):]
limit, err := strconv.Atoi(value)
if err != nil || limit < 0 {
return fmt.Errorf("Invalid error limit: %q", value), nil
return fmt.Errorf("Invalid log limit: %q", value), nil
}
if buildOpts != nil {
buildOpts.ErrorLimit = limit
buildOpts.LogLimit = limit
} else {
transformOpts.ErrorLimit = limit
transformOpts.LogLimit = limit
}

// Make sure this stays in sync with "PrintErrorToStderr"
Expand Down Expand Up @@ -527,7 +527,7 @@ func parseOptionsForRun(osArgs []string) (*api.BuildOptions, *string, *api.Trans
options := newBuildOptions()

// Apply defaults appropriate for the CLI
options.ErrorLimit = 10
options.LogLimit = 10
options.LogLevel = api.LogLevelInfo
options.Write = true

Expand All @@ -543,7 +543,7 @@ func parseOptionsForRun(osArgs []string) (*api.BuildOptions, *string, *api.Trans
options := newTransformOptions()

// Apply defaults appropriate for the CLI
options.ErrorLimit = 10
options.LogLimit = 10
options.LogLevel = api.LogLevelInfo

err, _ := parseOptionsImpl(osArgs, nil, &options, kindInternal)
Expand Down Expand Up @@ -753,7 +753,7 @@ func serveImpl(osArgs []string) error {
options := newBuildOptions()

// Apply defaults appropriate for the CLI
options.ErrorLimit = 5
options.LogLimit = 5
options.LogLevel = api.LogLevelInfo

if err, _ := parseOptionsImpl(filteredArgs, &options, nil, kindInternal); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions scripts/ts-type-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const tests = {
pure: ['x'],
color: true,
logLevel: 'info',
errorLimit: 0,
logLimit: 0,
tsconfigRaw: {
compilerOptions: {
jsxFactory: '',
Expand Down Expand Up @@ -152,7 +152,7 @@ const tests = {
pure: ['x'],
color: true,
logLevel: 'info',
errorLimit: 0,
logLimit: 0,
bundle: true,
splitting: true,
outfile: '',
Expand Down

0 comments on commit 7d30f83

Please sign in to comment.