@seamless-cicd/execa-logged-process
v0.0.7
Published
Create execa processes that emit logs for stdout and stderr
Downloads
4
Readme
Execa Logged Processes
This package provides:
- A
LogEmitter
class which makes a POST request containing a timestamped log, to a log receiver URL of your choice. - A
createLoggedProcess
which wrapsexeca
. It uses the log emitter to POST allstdout
andstderr
to the log receiver. It returns a child process for you to work with.
Using the log emitter
import { LogEmitter } from 'execa-logged-process';
const LOG_RECEIVER_URL = 'https://abc123.m.pipedream.net';
const logger = new LogEmitter(LOG_RECEIVER_URL);
logger.emit('Hello world', 'stdout', { key1: 'value1', key2: 123 });
Creating logged execa child processes
import {
createLoggedProcess,
handleProcessError,
} from './create-logged-process.js';
import type { ExecaError } from 'execa';
const LOG_RECEIVER_URL = 'https://abc123.m.pipedream.net';
(async function () {
try {
const loggedProcess = await createLoggedProcess(
'ls',
['-la'],
{},
LOG_RECEIVER_URL,
{ key1: 'value1', key2: 123 }
);
await loggedProcess;
} catch (error) {
handleProcessError(error as ExecaError, LOG_RECEIVER_URL);
}
})();