local sfeed config: use ts and bc for timings per feed - randomcrap - random crap programs of varying quality
(HTM) git clone git://git.codemadness.org/randomcrap
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 060a24b2ff394635468c107250cef60c45322f17
(DIR) parent e0518aedd32819efdfcf681a12e36573018b9974
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 2 Jan 2024 14:13:24 +0100
local sfeed config: use ts and bc for timings per feed
Diffstat:
M config/sfeed/global | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/config/sfeed/global b/config/sfeed/global
@@ -1,6 +1,8 @@
#!/bin/sh
# increase max parallel jobs allowed.
-maxjobs=16
+#maxjobs=16
+
+starttime=$(echo | ts -m '%.s')
# custom connectors.
#. ~/.sfeed/connectors/vimeo
@@ -8,6 +10,26 @@ maxjobs=16
. ~/.sfeed/connectors/youtube-videos-with-duration
. ~/.sfeed/connectors/repology_history_atom.sh
+# log(name, s)
+log() {
+ # NOTE: uses "ts" and bc for timings.
+ endtime=$(echo | ts -m '%.s')
+ duration=$(echo "$endtime - $starttime" | bc)
+
+ printf '[%s] %-50.50s %s (%s)\n' "$(date +'%H:%M:%S')" "$1" "$2" "$duration"
+}
+
+# log_error(name, s)
+log_error() {
+ # NOTE: uses "ts" and bc for timings.
+ endtime=$(echo | ts -m '%.s')
+ duration=$(echo "$endtime - $starttime" | bc)
+
+ printf '[%s] %-50.50s %s (%s)\n' "$(date +'%H:%M:%S')" "$1" "$2" "$duration" >&2
+ # set error exit status indicator for parallel jobs.
+ rm -f "${sfeedtmpdir}/ok"
+}
+
# parse(name, feedurl, basesiteurl)
parse() {
case "$2" in
@@ -34,7 +56,7 @@ merge() {
# order by timestamp (descending).
# order(name)
order() {
- LC_ALL=C sort -t ' ' -k1rn,1
+ LC_ALL=C sort -t ' ' -k1rn,1 2>/dev/null
}
# fetch a feed via HTTP/HTTPS etc.