17 Commits

Author SHA1 Message Date
George Kiagiadakis
eb2d6efcd4 state: add save_after_timeout() method to replace all custom timeout code
This was a common pattern that we had in many places, so it makes sense
to consolidate it.
2024-01-04 16:38:33 +02:00
George Kiagiadakis
4736d56557 log: implement a log topics system, like pipewire
The intention is to make checks for enabled log topics faster.

Every topic has its own structure that is statically defined in the file
where the logs are printed from. The structure is initialized transparently
when it is first used and it contains all the log level flags for the levels
that this topic should print messages. It is then checked on the wp_log()
macro before printing the message.

Topics from SPA/PipeWire are also handled natively, so messages are printed
directly without checking if the topic is enabled, since the PipeWire and SPA
macros do the checking themselves.

Messages coming from GLib are checked inside the handler.

An internal WpLogFields object is used to manage the state of each log
message, populating all the fields appropriately from the place they
are coming from (wp_log, spa_log, glib log), formatting the message and
then printing it. For printing to the journald, we still use the glib
message handler, converting all the needed fields to GLogField on demand.
That message handler does not do any checks for the topic or the level, so
we can just call it to send the message.
2023-05-16 20:42:28 +03:00
George Kiagiadakis
3cd9384805 wp: make wp_get_xdg_state_dir() private
It's not used elsewhere, so there is no good reason yet to expose it.
Besides, I expect that GLib will likely add a method in the future
to return the XDG_STATE_HOME (which is relatively new in the xdg spec)
2021-08-19 10:06:37 +03:00
Julian Bouzas
2792cecbcf properties: use a boxed WpPropertiesItem type when iterating
Needed for JavaScript bindings
2021-07-15 08:55:00 -04:00
Peter Hutterer
be1a077eaf state: store our WpState files in $XDG_STATE_HOME/wireplumber 2021-07-14 14:44:11 +10:00
Julian Bouzas
ee190411f4 state: escape invalid key file characters 2021-06-30 08:48:57 -04:00
George Kiagiadakis
1075d23fab lib: fix some issues found by coverity 2021-06-15 17:43:22 +03:00
George Kiagiadakis
38f7483793 state: remove support for groups and propagate save errors
There is no real use for groups in our API. Just use the name of
the file as the default group and be done with it...
Storing multiple groups with this API is problematic because it
forces flushing the file to disk multiple times, one for each group,
and it's just more performant if we use a prefix in the keys
to implement some form of logical separation.

This commit also makes the GKeyFile a temporary object. As we
always load the file from the file system in _load()
and we always replace its contents with a new dictionary in _save(),
there is no point in keeping the keyfile's internal data structures
stored in memory.

Save errors are now also propagated to adhere to the programming
practices of GObject
2021-06-04 18:36:19 +03:00
George Kiagiadakis
4948f6f2f6 state: don't stat() before creating the dir or removing the state file
there is no point
2021-06-04 18:36:19 +03:00
Jason Francis
ed8346e77d docs: Add brief descriptions to all functions
This ensures all of these functions are picked up by g-ir-scanner.
2021-06-02 17:38:34 +00:00
George Kiagiadakis
b812e912d2 docs: fix C API documentation to work nicely with doxygen & sphinx 2021-05-25 14:19:53 +03:00
Raghavendra
d692f06f0d docs: api: Replace hotdoc specific commands with Doxygen specific commands 2021-05-25 14:19:53 +03:00
George Kiagiadakis
257d5cba47 wp: rename debug.{h,c} to log.{h,c}
Also rename the intermediate lua api table WpDebug -> WpLog

Keeps things more consistent with the function names (wp_log*),
with the lua api (Log.*) and with pipewire using log.{h,c} as well.
After all, these functions are for logging...
2021-05-06 15:50:07 +03:00
George Kiagiadakis
7eed2acd76 lib: documentation fixes 2021-03-04 19:10:10 +02:00
Julian Bouzas
dc2ad1f25d rename all foo_iterate APIs to foo_new_iterator
Avoids confusion with LUA iterate API
2021-02-05 11:33:23 -05:00
Julian Bouzas
bef0b178ed state: use GKeyFile API to keep state in disk 2021-01-08 14:34:13 -05:00
Julian Bouzas
af423398c4 lib: add new WpState API to save and load data from files 2020-11-13 14:20:54 -05:00