Comment on page
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.
If your script already outputs logs to a file, configure Dashcam to monitor that file instead. See Log Files
Add the
dashcamlog
alias to your ~/.bashrc
or equivalent. dlog() {
2>&1 | tee -a "${1:-dashcam.log}"
}
You may need to open a new terminal window for commands to work.
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"
}
```
Then, configure Dashcam to monitor
/tmp/dashcam.log
and those log files will appear in the next Dashcam clip you make!
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
node log-tester.js
is an example script that outputs to bothstdout
andstderr.
2>&1 routes both stdout
andstderr
into a single stream- The
|
command feeds the output intotee
. - The
tee
command will route the output/tmp/dashcam.log
as well as in the terminal output
Last modified 2mo ago