]> git.corax.cc Git - toolbox/log
toolbox
4 years agoinclude/json: Add functions for creating json objects and arrays
Matthias Kruk [Wed, 24 Mar 2021 22:20:36 +0000 (07:20 +0900)]
include/json: Add functions for creating json objects and arrays

Especially when interacting with REST-ful APIs via curl, it can be handy
to have functions to quickly generate JSON objects without having to
invoke jq. This commit adds functions for generating simple JSON objects
and arrays.

4 years agoinclude/log: Log messages to the logfile AND stderr
Matthias Kruk [Tue, 23 Mar 2021 23:56:27 +0000 (08:56 +0900)]
include/log: Log messages to the logfile AND stderr

The log module only writes messages to the log file, which is not
enough for scripts that are running in the foreground. This commit
changes the log_write() function to log messages to the logfile as
well as to stderr.

4 years agoinclude/iface: Add module for querying network interfaces
Matthias Kruk [Mon, 22 Mar 2021 00:48:39 +0000 (09:48 +0900)]
include/iface: Add module for querying network interfaces

This commit adds a module that allows the user to query the state of
wired and wireless network interfaces.

4 years agoinclude/acpi: Add modules for querying battery and PSU state
Matthias Kruk [Mon, 22 Mar 2021 00:46:46 +0000 (09:46 +0900)]
include/acpi: Add modules for querying battery and PSU state

This commit adds the acpi/battery and acpi/ac module which can be used
to query the state of batteries and power supply units in the system
through the kernel's sysfs ACPI interface.

4 years agoinclude/sem: Fix names of logging functions
Matthias Kruk [Mon, 22 Mar 2021 00:43:39 +0000 (09:43 +0900)]
include/sem: Fix names of logging functions

The functions that the sem module was using for logging do not exist in
the latest log module. This commit changes the sem module to use the
right functions.

4 years agoinclude/log: Add logging facilities
Matthias Kruk [Mon, 22 Mar 2021 00:36:25 +0000 (09:36 +0900)]
include/log: Add logging facilities

This commit adds the log module which can be adopted by scripts to log
messages to log files that are stored in TOOLBOX_HOME. The module also
provides convenience functions for highlighting output and printing
stack traces.

4 years agoinclude/sem: Add POSIX-like semaphore implementation
Matthias Kruk [Sat, 20 Mar 2021 23:55:16 +0000 (08:55 +0900)]
include/sem: Add POSIX-like semaphore implementation

In certain situations, mutex are not enough for synchronization. This
commit adds a POSIX-like semaphore implementation that can be used to
implement things like queues or singleton scripts.

4 years agoinclude/mutex: Add symlink-based mutex implementation
Matthias Kruk [Sat, 20 Mar 2021 23:49:59 +0000 (08:49 +0900)]
include/mutex: Add symlink-based mutex implementation

Scripts that access shared resources need a means to synchronize accesses
to those resources. This commit adds a symlink-based mutex implementation
that can be used for this purpose.

4 years agotoolbox: Implement toolbox initialization and module loading
Matthias Kruk [Sat, 20 Mar 2021 23:23:32 +0000 (08:23 +0900)]
toolbox: Implement toolbox initialization and module loading

When writing shell scripts, I often find myself copying or rewriting
functions because bash does not provide a mechanism to easily reuse
code. This commit adds a mechanism for loadable bash "modules".