-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new "explain" logger #863
Open
rictic
wants to merge
15
commits into
main
Choose a base branch
from
explain-mode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
610c017
Add some more "why" info in events
rictic 9e21e1a
Better explain services stopping
rictic 4c3e3bb
Track reasons for fingerprint changes
rictic 75c8ddb
Log why a service was stopped in verbose loggers.
rictic 81e826f
Explain why a running script isn't fresh
rictic aafaf97
Explain dependency trees too
rictic 9cbed09
Use the type system to double check that we got all fingerprint fields
rictic 7bb036d
Update CHANGELOG and README
rictic 42b48c0
Lint
rictic fcba1f8
Improve clarity a bit more.
rictic cfd0391
Address some review comments
rictic 0a7a85a
Format
rictic 4b8a11d
Unify behavior of persistent services and the 'files' field.
rictic ea5bff9
Add a test of a caching consumer of an ephemeral service with files
rictic ba68974
Improved and clarified service caching test
rictic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ export interface Options { | |
logger: Logger; | ||
} | ||
|
||
export const getOptions = (): Result<Options> => { | ||
export const getOptions = async (): Promise<Result<Options>> => { | ||
// This environment variable is set by npm, yarn, and pnpm, and tells us which | ||
// script is running. | ||
const scriptName = process.env.npm_lifecycle_event; | ||
|
@@ -185,7 +185,7 @@ export const getOptions = (): Result<Options> => { | |
|
||
const agent = getNpmUserAgent(); | ||
|
||
const loggerResult = ((): Result<Logger> => { | ||
const loggerResult = await (async (): Promise<Result<Logger>> => { | ||
const packageRoot = packageDir ?? process.cwd(); | ||
const str = process.env['WIREIT_LOGGER']; | ||
if (!str) { | ||
|
@@ -197,6 +197,10 @@ export const getOptions = (): Result<Options> => { | |
if (str === 'quiet-ci') { | ||
return {ok: true, value: new QuietCiLogger(packageRoot)}; | ||
} | ||
if (str === 'explain') { | ||
const {ExplainLogger} = await import('./logging/explain-logger.js'); | ||
return {ok: true, value: new ExplainLogger(packageRoot)}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WDYT about dynamic importing the explain logger here? It should be a rare import. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1! |
||
} | ||
if (str === 'simple') { | ||
return {ok: true, value: new DefaultLogger(packageRoot)}; | ||
} | ||
|
@@ -209,7 +213,9 @@ export const getOptions = (): Result<Options> => { | |
reason: 'invalid-usage', | ||
message: | ||
`Expected the WIREIT_LOGGER env variable to be ` + | ||
`"quiet", "simple", or "metrics", got ${JSON.stringify(str)}`, | ||
`"quiet", "quiet-ci", "explain", "simple", or "metrics", got ${JSON.stringify( | ||
str, | ||
)}`, | ||
script, | ||
type: 'failure', | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like a little more information is also added to the default logger in this PR (and I think simple logger, since it delegates to default sometimes?). Mention that too in a separate line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done