Logs and errors

The service writes down what it does, so you can see why a camera did not open or which processor failed. There are three places to look, and each one has its own job.

WhereWhat it holdsUse it for
The journal of the serviceEverything from INFO up: leases, frame statistics, backend and processor changes, the camera opening, retries and failuresFollowing what happens now
The log of each runOnly what is worth keeping: warnings and errors, what happens at start, backend and processor changesFinding out afterwards what went wrong
The error channelErrors as messages, for your program and the UIShowing a problem to the user

The journal

journalctl -u raccoon-cam -f

The service logs through the standard logging module. The journal gets every record at INFO and above. Routine traffic, such as renew and the name of each command, is DEBUG and does not appear there.

WhatExample
Start of the serviceThe instance, the configured backend and the stream settings
A leaselease ... held, the camera stays closed (a program that loaded processors), acquired (1 active), released (0 left), expired
Opening the cameraThe backend and its options, the number of open attempts and the delay, the first frame
Backend and processorsbackend selected, processor X loaded, processor X is active now (was Y), processor X removed
Closingno program needs the camera (released): closing it, and why
StatisticsEvery 30 seconds while a camera is open: frames per second received, processed and dropped, the number of processors and leases
A stalled servicethe service was stalled for 4.2 s: leases extended by that time

When the last lease goes away, the service closes the camera at once and the journal says which reason applies: the program released it, or its lease ran out because the program vanished.

The log of each run

On a robot, the service also hands its records to the logger of raccoon-lib. That logger writes one JSON object per line to libstp.jsonl, the same format and the same tools as the log of your robot program. Every start of the service gets its own directory:

/var/log/raccoon-cam/20261119T101500Z/libstp.jsonl

The directory name is the start time in UTC. The newest 10 runs are kept and older ones are deleted when the service starts.

Not everything goes in there, so the file stays small and readable:

In the fileLeft out
Warnings and errors: retries, failures, a processor that failsLeases
What happens at start: the opening of the camera and the settings it gotFrame statistics
Changes of backend and processors, one short line eachRoutine commands

Warnings and errors also reach the journal, through the console of raccoon-lib. The service does not print them a second time.

The directory comes from systemd (LogsDirectory=raccoon-cam) or from RACCOON_CAM_LOG_DIR. For example, RACCOON_CAM_LOG_DIR=/dev/shm/raccoon-cam-logs keeps the logs in memory, so nothing is written to the SD card and nothing survives a reboot. A LIBSTP_LOG_DIR that is already set in the environment wins over both.

Without raccoon-lib, on a laptop or in tests, only logging is used.

Errors in your program and in the UI

The service publishes an error as a message when something goes wrong while a camera is in use. It sends it twice, on different channels (see Channels ).

ChannelReceiverContent
raccoon/cam/errorClientsJSON with message and context. Retained, so a client that connects later sees the last one. CamClient.last_error holds it
raccoon/errorsThe UIThe same message as text, prefixed with raccoon-cam:

What causes one:

Causecontext
The backend could not start (a missing dependency, a bad option)phase: start
The camera did not open after the allowed attemptsphase: open
A processor failed, or was disabled after five failures in a rowprocessor: <name>
The frame stream cannot encode JPEGs, so it is turned offphase: stream

A camera that is only slow to come back is not an error for the UI. A USB camera needs a few seconds to reopen right after it was closed, so a failed open is sent to the UI only once it has kept failing for 5 seconds, and then every tenth attempt. Before that the attempts are in the journal and in the status of the backend (open_attempts).

A start that fails for good also sets failed in the status. Your program sees it as a FailedCamera from start_camera(), see Retries and failure .

A processor that fails never stops the service. The failure is counted per processor (failures, last_error in the status), and after five in a row that processor is disabled. Another processor that you swap to with change_processor runs normally.

Written by Mario Scholze