microsoft / microsoft/typespec

stdout and stderr usage consistency for typespec

Open
#6,662 2 comments 0 reactions 0 assignees View on GitHub
compiler:core design:proposed triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

From issue https://github.com/microsoft/typespec/issues/6574 there seems to be some inconsistencies on what we emit to stderr.

First thing to state is that only the process status code should be used to decide if the typespec compile(or other command) fails. Assuming stderr means an error occur is an invalid behavior.

## Option 1: stdout for output and stderr for system diagnostics

The general idea is that `stdout` should be for the output of the program and `stderr` for system diagnostics(not errors).
The idea with using this separation that is widely used is that you can have command like `--json` while still emitting logs to stderror.

Types of output we currently have

| Type | Currently using | Using system above |
| ------------------------- | --------------- | ------------------ |
| TypeSpec diagnostics | stdout | stdout |
| Compiler or library crash | stderr | stdout |
| Tracing | stdout | stderr |
| Progress spinner | stderr | stderr |

Diagnostics are part of the typespec output (they are basically the only output that is produced on a regular basis so it does make sense they belong to stdout.

## Option 2:

Don't use stderr at all, because we can't trust Microsoft tools built on the asusmption that stderr always means an error is built

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.