Allow user configurable log level option for some services
After some services were recently quieted down by adjusting the log level for e.g ffmpeg. It would be nice if the user can easily adjust the log level again so that that they can investigate or debug a issue since output is not generated by default, so now the Livestream, Spectrogream and Birdnet Recording have a adjustable log levels to help with this.
This commit is contained in:
+128
-1
@@ -245,6 +245,55 @@ if(isset($_GET['submit'])) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET["LogLevel_BirdnetRecordingService"])) {
|
||||
$birdnet_recording_service_log_level = trim($_GET["LogLevel_BirdnetRecordingService"]);
|
||||
|
||||
//Setting exists already, see if the value changed
|
||||
if (strcmp($birdnet_recording_service_log_level, $config['LogLevel_BirdnetRecordingService']) !== 0) {
|
||||
$contents = preg_replace("/LogLevel_BirdnetRecordingService=.*/", "LogLevel_BirdnetRecordingService=\"$birdnet_recording_service_log_level\"", $contents);
|
||||
$contents2 = preg_replace("/LogLevel_BirdnetRecordingService=.*/", "LogLevel_BirdnetRecordingService=\"$birdnet_recording_service_log_level\"", $contents2);
|
||||
$fh = fopen("/etc/birdnet/birdnet.conf", "w");
|
||||
$fh2 = fopen("./scripts/thisrun.txt", "w");
|
||||
fwrite($fh, $contents);
|
||||
fwrite($fh2, $contents2);
|
||||
sleep(1);
|
||||
exec("sudo systemctl restart birdnet_recording.service");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET["LogLevel_SpectrogramViewerService"])) {
|
||||
$spectrogram_viewer_service_log_level = trim($_GET["LogLevel_SpectrogramViewerService"]);
|
||||
|
||||
//Setting exists already, see if the value changed
|
||||
if (strcmp($spectrogram_viewer_service_log_level, $config['LogLevel_SpectrogramViewerService']) !== 0) {
|
||||
$contents = preg_replace("/LogLevel_SpectrogramViewerService=.*/", "LogLevel_SpectrogramViewerService=\"$spectrogram_viewer_service_log_level\"", $contents);
|
||||
$contents2 = preg_replace("/LogLevel_SpectrogramViewerService=.*/", "LogLevel_SpectrogramViewerService=\"$spectrogram_viewer_service_log_level\"", $contents2);
|
||||
$fh = fopen("/etc/birdnet/birdnet.conf", "w");
|
||||
$fh2 = fopen("./scripts/thisrun.txt", "w");
|
||||
fwrite($fh, $contents);
|
||||
fwrite($fh2, $contents2);
|
||||
sleep(1);
|
||||
exec("sudo systemctl restart spectrogram_viewer.service");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET["LogLevel_LiveAudioStreamService"])) {
|
||||
$livestream_audio_service_log_level = trim($_GET["LogLevel_LiveAudioStreamService"]);
|
||||
|
||||
//Setting exists already, see if the value changed
|
||||
if (strcmp($livestream_audio_service_log_level, $config['LogLevel_LiveAudioStreamService']) !== 0) {
|
||||
$contents = preg_replace("/LogLevel_LiveAudioStreamService=.*/", "LogLevel_LiveAudioStreamService=\"$livestream_audio_service_log_level\"", $contents);
|
||||
$contents2 = preg_replace("/LogLevel_LiveAudioStreamService=.*/", "LogLevel_LiveAudioStreamService=\"$livestream_audio_service_log_level\"", $contents2);
|
||||
$fh = fopen("/etc/birdnet/birdnet.conf", "w");
|
||||
$fh2 = fopen("./scripts/thisrun.txt", "w");
|
||||
fwrite($fh, $contents);
|
||||
fwrite($fh2, $contents2);
|
||||
sleep(1);
|
||||
exec("sudo systemctl restart livestream.service && sudo systemctl restart icecast2.service");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$fh = fopen('/etc/birdnet/birdnet.conf', "w");
|
||||
$fh2 = fopen("./scripts/thisrun.txt", "w");
|
||||
fwrite($fh, $contents);
|
||||
@@ -505,7 +554,85 @@ foreach($formats as $format){
|
||||
<input name="freqshift_pitch" type="number" min="-4000" max="4000" step="1" value="<?php print($newconfig['FREQSHIFT_PITCH']);?>" required/><br>
|
||||
</p>
|
||||
</td></tr></table><br>
|
||||
</p>
|
||||
|
||||
<table class="settingstable">
|
||||
<tr>
|
||||
<td>
|
||||
<h2>Logging</h2>
|
||||
<div class="callout callout-warning">
|
||||
<h4>Note:</h4>
|
||||
It is recommended that the Log Level be set to <b>Error</b> on production systems to keep output
|
||||
manageable by only reporting errors.
|
||||
<br>
|
||||
Not all components support the log level option at this time.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Birdnet Recording:
|
||||
<select id="LogLevel_BirdnetRecordingService" name="LogLevel_BirdnetRecordingService">
|
||||
<option value="error" <?php echo $newconfig['LogLevel_BirdnetRecordingService'] == "error" ? "selected=''" : "" ?>>
|
||||
Errors Only
|
||||
</option>
|
||||
<option value="warning" <?php echo $newconfig['LogLevel_BirdnetRecordingService'] == "warning" ? "selected=''" : "" ?>>
|
||||
Warning
|
||||
</option>
|
||||
<option value="info" <?php echo $newconfig['LogLevel_BirdnetRecordingService'] == "info" ? "selected=''" : "" ?>>
|
||||
Info
|
||||
</option>
|
||||
<option value="debug" <?php echo $newconfig['LogLevel_BirdnetRecordingService'] == "debug" ? "selected=''" : "" ?>>
|
||||
Debug
|
||||
</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Live Audio Stream:
|
||||
<select id="LogLevel_LiveAudioStreamService" name="LogLevel_LiveAudioStreamService">
|
||||
<option value="error" <?php echo $newconfig['LogLevel_LiveAudioStreamService'] == "error" ? "selected=''" : "" ?>>
|
||||
Errors Only
|
||||
</option>
|
||||
<option value="warning" <?php echo $newconfig['LogLevel_LiveAudioStreamService'] == "warning" ? "selected=''" : "" ?>>
|
||||
Warning
|
||||
</option>
|
||||
<option value="info" <?php echo $newconfig['LogLevel_LiveAudioStreamService'] == "info" ? "selected=''" : "" ?>>
|
||||
Info
|
||||
</option>
|
||||
<option value="debug" <?php echo $newconfig['LogLevel_LiveAudioStreamService'] == "debug" ? "selected=''" : "" ?>>
|
||||
Debug
|
||||
</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Spectrogram Service:
|
||||
<select id="LogLevel_SpectrogramViewerService" name="LogLevel_SpectrogramViewerService">
|
||||
<option value="error" <?php echo $newconfig['LogLevel_SpectrogramViewerService'] == "error" ? "selected=''" : "" ?>>
|
||||
Errors Only
|
||||
</option>
|
||||
<option value="warning" <?php echo $newconfig['LogLevel_SpectrogramViewerService'] == "warning" ? "selected=''" : "" ?>>
|
||||
Warning
|
||||
</option>
|
||||
<option value="info" <?php echo $newconfig['LogLevel_SpectrogramViewerService'] == "info" ? "selected=''" : "" ?>>
|
||||
Info
|
||||
</option>
|
||||
<option value="debug" <?php echo $newconfig['LogLevel_SpectrogramViewerService'] == "debug" ? "selected=''" : "" ?>>
|
||||
Debug
|
||||
</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<small>
|
||||
<b>'error'</b> - Show all errors, including ones which can be recovered from. This is the default value.<br>
|
||||
<b>'warning'</b> - Show all warnings and errors. Any message related to possibly incorrect or unexpected events will be shown.<br>
|
||||
<b>'info'</b> - Show informative messages and output during processing. This is in addition to warnings and errors. <br>
|
||||
<b>'debug'</b> - Show everything, including debugging information.<br>
|
||||
</small>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br><br>
|
||||
<input type="hidden" name="view" value="Advanced">
|
||||
<button onclick="if(<?php print($newconfig['PRIVACY_THRESHOLD']);?> != document.getElementById('privacy_threshold').value){return confirm('This will take about 90 seconds.')} collectrtspUrls();" type="submit" name="submit" value="advanced">
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# Performs the recording from the specified RTSP stream or soundcard
|
||||
#set -x
|
||||
source /etc/birdnet/birdnet.conf
|
||||
|
||||
# Set the logging level
|
||||
LOGGING_LEVEL='error'
|
||||
# Read the logging level from the configuration option
|
||||
LOGGING_LEVEL="${LogLevel_BirdnetRecordingService}"
|
||||
# If empty for some reason default to log level of error
|
||||
[ -z $LOGGING_LEVEL ] && LOGGING_LEVEL='error'
|
||||
# Additionally if we're at debug or info level then allow printing of script commands and variables
|
||||
if [ "$LOGGING_LEVEL" == "info" ] || [ "$LOGGING_LEVEL" == "debug" ];then
|
||||
# Enable printing of commands/variables etc to terminal for debugging
|
||||
set -x
|
||||
fi
|
||||
|
||||
[ -z $RECORDING_LENGTH ] && RECORDING_LENGTH=15
|
||||
|
||||
@@ -26,15 +32,16 @@ if [ ! -z $RTSP_STREAM ];then
|
||||
# Loop over the streams
|
||||
for i in "${RTSP_STREAMS_EXPLODED_ARRAY[@]}"
|
||||
do
|
||||
# Map id used to map input to output, this is 0 based in ffmpeg decrement
|
||||
# Map id used to map input to output (first stream being 0), this is 0 based in ffmpeg so decrement our counter (which is more human readable) by 1
|
||||
MAP_ID=$((RTSP_STREAMS_STARTED_COUNT-1))
|
||||
# Build up the parameters to process the RSTP stream, including mapping for the output
|
||||
# Build up the parameters to process the RSTP stream, including mapping for the output, because some streams may have more than one audio stream within it, get the first stream
|
||||
#ffmpeg does this by default when there is only 1 steam, but if there are more than 1 then it doesn't know which one we want
|
||||
FFMPEG_PARAMS+="-vn -thread_queue_size 512 -i ${i} -map ${MAP_ID} -t ${RECORDING_LENGTH} -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/StreamData/$(date "+%F")-birdnet-RTSP_${RTSP_STREAMS_STARTED_COUNT}-$(date "+%H:%M:%S").wav "
|
||||
# Increment counter
|
||||
# Increment counter for the next round
|
||||
((RTSP_STREAMS_STARTED_COUNT += 1))
|
||||
done
|
||||
|
||||
# Make sure were passing something valid to ffmpeg, ffmpeg will run interactive and control our look by waiting ${RECORDING_LENGTH} between loops
|
||||
# Make sure were passing something valid to ffmpeg, ffmpeg will run interactive and control our loop by waiting ${RECORDING_LENGTH} between loops because it will stop once that much has been recorded
|
||||
if [ -n "$FFMPEG_PARAMS" ];then
|
||||
ffmpeg -hide_banner -loglevel $LOGGING_LEVEL -nostdin $FFMPEG_PARAMS
|
||||
fi
|
||||
|
||||
@@ -2,8 +2,15 @@
|
||||
# Live Audio Stream Service Script
|
||||
source /etc/birdnet/birdnet.conf
|
||||
|
||||
# Set logging level
|
||||
LOGGING_LEVEL='error'
|
||||
# Read the logging level from the configuration option
|
||||
LOGGING_LEVEL="${LogLevel_LiveAudioStreamService}"
|
||||
# If empty for some reason default to log level of error
|
||||
[ -z $LOGGING_LEVEL ] && LOGGING_LEVEL='error'
|
||||
# Additionally if we're at debug or info level then allow printing of script commands and variables
|
||||
if [ "$LOGGING_LEVEL" == "info" ] || [ "$LOGGING_LEVEL" == "debug" ];then
|
||||
# Enable printing of commands/variables etc to terminal for debugging
|
||||
set -x
|
||||
fi
|
||||
|
||||
if [ -z ${REC_CARD} ];then
|
||||
echo "Stream not supported"
|
||||
|
||||
+10
-1
@@ -1,8 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# set -x
|
||||
# Make sox spectrogram
|
||||
source /etc/birdnet/birdnet.conf
|
||||
|
||||
# Read the logging level from the configuration option
|
||||
LOGGING_LEVEL="${LogLevel_SpectrogramViewerService}"
|
||||
# If empty for some reason default to log level of error
|
||||
[ -z $LOGGING_LEVEL ] && LOGGING_LEVEL='error'
|
||||
# Additionally if we're at debug or info level then allow printing of script commands and variables
|
||||
if [ "$LOGGING_LEVEL" == "info" ] || [ "$LOGGING_LEVEL" == "debug" ];then
|
||||
# Enable printing of commands/variables etc to terminal for debugging
|
||||
set -x
|
||||
fi
|
||||
|
||||
# Time to sleep between generating spectrogram's, default set the recording length
|
||||
# To try catch the spectrogram as soon as possible run at a smaller intervals
|
||||
SLEEP_DELAY=$((RECORDING_LENGTH / 4))
|
||||
|
||||
Reference in New Issue
Block a user