|
|
Log in / Subscribe / Register

That newfangled Journal thing

That newfangled Journal thing

Posted Dec 31, 2011 6:44 UTC (Sat) by technosaurus (guest, #82040)
Parent article: That newfangled Journal thing

you can have a flat file _AND_ be easily indexable

UUID=1234-dsa-fweqwe-rwqwer MSG="DEBUG: module xxx loaded" USELESSVAR="I need this for my init hack" BLOBSIZE=12345678 \n

bzcat $FILE | while read LINE ...
case "$LINE" in
*MSG=*)eval $LINE;;
#do more stuff here
*)#treat as binary data or non conformant message
esac
done |bzip -9c >$FILE~ && mv -f $FILE~ $FILE

replace bzip with your favorite compression (bz seems to work better than xz on these type of files though)

you can read the data stream from after the \n for BLOBSIZE bytes
tricky, but doable ... it really should be in a separate file so that the logfile is viewable in a standard text editor

The binary file log could work like this (but I think it is stupid unless you want to tack it on to an avi file as a type of poor man's steganography - use a directory with a unique file name that is identified in the message for crying out loud)
echo '
UUID=1234-dsa-fweqwe-rwqwer MSG="DEBUG: module xxx loaded" USELESSVAR="I need this for my init hack" BLOBSIZE='`stat -c %s myblob` >> /tmp/bloblog
cat myblob >>/tmp/bloblog
(or a similar C equivalent)

then to access the blobs you can use sed (for removing text lines with the messag) + head/tail (using -c $BLOBSIZE to get the blob) ... not the fastest way in the world
... but why not just use a damn directory and a unique file name .../sys/blobs/myblob (it even has a time stamp that could be cross referenced - imagine that)


to post comments

That newfangled Journal thing

Posted Dec 31, 2011 7:05 UTC (Sat) by technosaurus (guest, #82040) [Link]

forgot to mention that it lends itself to being easily capable of storing in any database format with a simple scripted daemon


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds