Piping to Files Directly
If you're a developer, it can be handy to capture terminal output and a screen recording when you encounter a bug.
This guide will show you how to capture server logs, terminal output, or anything else in its raw format.
We'll be working in a *nix system with the tee command.
Dashcam works by tailing log files for changes. Therefore, any newlines in a log file that Dashcam is configured to watch will appear in a Dashcam recording.
1. Add an alias to your CLI profile
Add the dashcamlog alias to your ~/.bashrcor equivalent.
dlog() {
2>&1 | tee -a "${1:-dashcam.log}"
}2. Log your process
Now, append dashcamlog whenever you run a process from the terminal.
node app.js | dash /tmp/dashcam.logYou can add this to your start script to ensure logs are always fed to Dashcam:
```json
{
"dev": "node app.js | dash /tmp/dashcam.log"
}
```3. Configure Dashcam
Then, configure Dashcam to monitor /tmp/dashcam.log and those log files will appear in the next Dashcam clip you make!

How it works
If your script outputs to stdout and/or stderr the best way to attach that output to Dashcam clips is with a command like the following:
node log-tester.js 2>&1 | tee -a /tmp/dashcam.logLet's break down how this works. Stackoverflow post here.
node log-tester.jsis an example script that outputs to bothstdoutandstderr.2>&1 routes both stdoutandstderrinto a single streamThe
|command feeds the output intotee.The
teecommand will route the output/tmp/dashcam.logas well as in the terminal output
Last updated
Was this helpful?