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 ~/.bashrc
or 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.log
You 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.log
Let's break down how this works. Stackoverflow post here.
node log-tester.js
is an example script that outputs to bothstdout
andstderr.
2>&1 routes both stdout
andstderr
into a single streamThe
|
command feeds the output intotee
.The
tee
command will route the output/tmp/dashcam.log
as well as in the terminal output
Last updated
Was this helpful?