News for hackers. Stuff that matters.
Re:Discussion: structured, leveled logging by thechao on Sunday September 11, 2022 @08:20PM (#32804509)
All the sqlite love, here, recently... but none on logging? Using a `:memory:` SQLite DB, combined with the backup API is perfect for one-shot application (non-server processes). The formatting I do is cleverly composed SQL queries.
Re:Discussion: structured, leveled logging by srcreigh on Sunday September 11, 2022 @09:18PM (#32804829)
Are you still talking about logging?

Anyways, would love to hear more about your clever queries, even if it's OT.

Re:Discussion: structured, leveled logging by thechao on Monday September 12, 2022 @08:38AM (#32809227)
Yep. The "style" of logger is in C, and looks (roughly) like this:

Logger* OpenLog(char*);

Table* MakeLog(Logger*, unsigned level, unsigned N, char* colNames, ColType *colTypes);

LOG(Table, Level, ...);

The branch to select log-level is trivial compared to the append cost. There's a few "backends" built in to the API: (1) a text-streaming version that just writes a text log; (2) a "bucketing" version that boils the calls to `MakeLog` down to accumulating buckets (with optional stack tracing); and, (3) journaling to a SQLite DB (with optional stack tracing).

Re:Discussion: structured, leveled logging by srcreigh on Monday September 12, 2022 @04:47PM (#32816712)
Do you use glibc backtraces for stack tracing? I don't use C much, i guess that may be standard. or something else?

Also, can you describe the queries you run against this SQLite? Is it interactive use or do you have any jobs or charts that are powered by it?

So very interested in this whole approach - if you have any posts or links to read more happy to see em!

Re:Discussion: structured, leveled logging by wsargent on Sunday September 11, 2022 @10:50PM (#32805515)