Created
August 15, 2025 12:39
-
-
Save ichux/361b20813c98052d46aa76bcb2d119e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sqlite3 ~/terminaLogs.db <<EOF | |
CREATE TABLE IF NOT EXISTS logs ( | |
id INTEGER PRIMARY KEY AUTOINCREMENT, | |
timestamp TEXT NOT NULL, | |
message TEXT NOT NULL | |
); | |
EOF | |
echo .schema | sqlite3 ~/terminaLogs.db | |
log() { | |
# sqlite3 ~/terminaLogs.db "SELECT * FROM logs ORDER BY id DESC;" | |
local ts | |
ts=$(date '+%Y-%m-%d %H:%M:%S.%6N') | |
echo "$ts - $1" | |
sqlite3 ~/terminaLogs.db <<EOF >/dev/null | |
PRAGMA journal_mode = WAL; | |
INSERT INTO logs (timestamp, message) VALUES ('$ts', '$1'); | |
EOF | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment