lage/packages/reporters
Ken Chau cfcba67315 applying package updates 2023-02-14 19:13:59 +00:00
..
src Verbose reporter - fixes it so it uses the old reporter when verbose or grouped are specified (#561) 2023-01-31 18:18:18 +00:00
tests Add task error summary to ADO reporter (#553) 2023-01-30 09:19:04 -08:00
CHANGELOG.json applying package updates 2023-02-14 19:13:59 +00:00
CHANGELOG.md applying package updates 2023-01-31 18:24:39 +00:00
README.md @lage-run/reporter - Adds Reporter (#322) 2022-08-11 16:48:46 -07:00
jest.config.js @lage-run/reporter - Adds Reporter (#322) 2022-08-11 16:48:46 -07:00
package.json Update devDependency @types/react to v18.0.28 (#578) 2023-02-14 11:10:57 -08:00
tsconfig.json Fancy reporter (#514) 2022-12-05 16:41:41 -08:00

README.md

@lage-run/reporters

This package provides some default built-in reporters to be used inside @lage-run/cli (and lage, the main entry point to the tool). The Reporter interface comes from @lage-run/logger.

NpmLogReporter

This reporter uses the npmlog package that is the same logger used by npm. It is considered stable, and is chosen because of its ability to log in a "standard" way with a clear distinction between "INFO", "WARN", "ERR!", "VERB", etc. npmlog by default writes to the stderr stream, so be aware that these logs are written to that.

To use it, look at how it is instantiated inside the unit tests. Here's an example of a basic usage:

const reporter = new NpmLogReporter({ grouped: false, logLevel: LogLevel.verbose });

reporter.log({
  data: {
    target: createTarget("a", "task"),
    status: "running",
    duration: [0, 0],
    startTime: [0, 0],
  } as TargetStatusEntry,
  level: LogLevel.verbose,
  msg: "test message",
  timestamp: 0,
});

It will produce a summary that looks something like this in case of errors, displaying any explicit errors in a summary section:

info ➔ start a test
info ✓ done a test - 10.00s
info ➔ start b build
info ✓ done b build - 30.00s
info ➔ start a build
info ✖ fail a build
info 🏗 Summary
info 
info Nothing has been run.
info ----------------------------------------------
ERR! [a build] ERROR DETECTED
ERR! 
ERR! test message for a#build
ERR! test message for a#build again, but look there is an error!
ERR! 
info ----------------------------------------------
info Took a total of 1m 40.00s to complete

JsonReporter

Every log entry being sent to this reporter will write out in a raw JSON format. When piped to another processor, be sure to handle the newline-delimited JSON objects. This is useful for making a tool on top of lage to post process the run in an automation step or as part of a larger pipeline of work.

AdoReporter

Azure DevOps contains a set of logging commands that can make the logged messages more easily parsed by humans. These formatting commands include the ability to collapse logs in a group. To support this, lage also provides a built-in Azure DevOps reporter. It outputs roughly into something like this:

##[group] a test success, took 10.00s
INFO:  ➔ start a test
VERB:  |  test message for a#test
VERB:  |  test message for a#test again
INFO:  ✓ done a test - 10.00s
##[endgroup]
##[group] b build success, took 30.00s
INFO:  ➔ start b build
VERB:  |  test message for b#build
VERB:  |  test message for b#build again
INFO:  ✓ done b build - 30.00s
##[endgroup]
##[group] a build failed, took 60.00s
INFO:  ➔ start a build
VERB:  |  test message for a#build
VERB:  |  test message for a#build again, but look there is an error!
INFO:  ✖ fail a build
##[endgroup]
##[section]Summary
INFO: a build failed, took 60.00s
INFO: a test success, took 60.00s
INFO: b build success, took 60.00s
[Tasks Count] success: 2, skipped: 0, pending: 0, aborted: 0
##[error] [a build] ERROR DETECTED
##[error] 
##[error] test message for a#build
##[error] test message for a#build again, but look there is an error!
##[error] 
INFO:  Took a total of 1m 40.00s to complete