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

1. Add an alias to your CLI profile

Add the dashcamlog alias to your ~/.bashrcor equivalent.

dlog() {
  2>&1 | tee -a "${1:-dashcam.log}"

You may need to open a new terminal window for commands to work.

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:

  "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 both stdout and stderr.

  • 2>&1 routes both stdout and stderr into a single stream

  • The | command feeds the output into tee.

  • The tee command will route the output /tmp/dashcam.log as well as in the terminal output

Last updated