nbdkit_timestamp(3)
β¨ nbdkit_timestamp β it's giving clock energy ππ
okay bestie so this is a page from the nbdkit manual, and it's about one tiny little function that hands you a timestamp you can slap into your log messages. it's so cute and so useful, you're gonna be obsessed π
πΈ NAME πΈ
nbdkit_timestamp β generate a timestamp for log messages β¨
π SYNOPSIS π
#include <nbdkit-plugin.h>
const char *nbdkit_timestamp (void);
like, that's it. one function, zero arguments, maximum slay π«Ά
π DESCRIPTION π
so nbdkit_timestamp generates a timestamp as a printable string, and you can add it to your debug or error messages (peep nbdkit_debug(3) and nbdkit_error(3) for that, iykyk).
you can use it like this:
nbdkit_debug ("%s: this is a debug message", nbdkit_timestamp ());
which would produce a debug message like this:
debug: 2026-01-01 12:00:00.000333: this is a debug message
okay so the timestamps show the wallclock time in approximately ISO 8601 format, but less ugly. we love that for us. they are always shown in UTC, in 24 hour notation, to the nearest microsecond. (on Windows, timestamps use the same format but are rounded to the nearest millisecond β no cap, that's just how it is πͺ)
and bestie, you can also separate the nbdkit_timestamp() call from the place where it's used, which lets you accurately timestamp, for example, the exact point when a system call was invoked π
const char *ts = nbdkit_timestamp ();
int r = pwrite (fd, ...);
if (r == -1) {
/* The error message shows the time that pwrite started. */
nbdkit_error ("%s: pwrite: %m", ts);
return -1;
}
literally the main character energy of logging π
β RETURN VALUE β
the function returns a constant string allocated in thread-local storage. that string is valid until the next call to nbdkit_timestamp in the same thread. so don't go holding onto it forever, okay? π
it never returns NULL. in the (very unlikely) case that there was an error generating the timestamp, the string "!" is returned. dramatic but honest π
π¦ LANGUAGE BINDINGS π¦
in nbdkit-ocaml-plugin(3):
NBDKit.timestamp : unit -> string
in nbdkit-python-plugin(3):
import nbdkit
ts = nbdkit.timestamp()
in nbdkit-rust-plugin(3):
use nbdkit::*;
pub fn timestamp() -> String
all the languages ate, periodt π
π HISTORY π
nbdkit_timestamp was added in nbdkit 1.48. a legend was born β¨
π SEE ALSO π
go read them, they're all bangers fr fr π
π AUTHORS π
Richard W.M. Jones β icon behavior π
π COPYRIGHT π
Copyright Red Hat
π LICENSE π
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Red Hat nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
and that's the whole page bestie π₯° this came from nbdkit-1.48.1, dated 2026-08-29, and it's page nbdkit_timestamp(3) of the manual. go forth and timestamp everything πβ¨π
π¦ where this page comes from
- fedora 44: nbdkit-devel 1.48.1-1.fc44 Β· BSD-3-Clause
- fedora 44: nbdkit-devel 1.48.1-1.fc44 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms