MS_LOG(3)
π MS_LOG(3) β the libmseed logging facility, bestie π
okay so hi, you found the page for ms_log, and honestly? it's giving central logging facility for libmseed. It lives in the Library Functions Manual section 3 (you know, the library functions girlies), so pull up a chair, grab a strawberry π, and let's get into it.
πΈ NAME πΈ
ms_log β Central logging facility for libmseed
β¨ SYNOPSIS β¨
#include <libmseed.h>
int ms_log (int level, const char *format, ...);
int ms_log_l (MSLogParam *logp, int level, const char *format, ...);
void ms_loginit (void (*log_print)(char*), const char *logprefix,
void (*diag_print)(char*), const char *errprefix);
MSLogParam * ms_loginit_l (MSLogParam *logp,
void (*log_print)(char*), const char *logprefix,
void (*diag_print)(char*), const char *errprefix);
π¦ DESCRIPTION π¦
So the ms_log functions are THE central logging facility for all output from libmseed functions. Periodt. They're also meant to be used by libmseed based programs if you want to, no pressure π
There are three message levels recognized, and yes you need to know them:
0β Normal log messages, printed usinglog_printwithlogprefix1β Diagnostic messages, printed usingdiag_printwithlogprefix2+β Error messages, printed usingdiag_printwitherrprefix
The whole job of the ms_log functions is to format a message using printf conventions and then pass that formatted string over to the appropriate printing function (log_print or diag_print). Simple, iconic, no notes.
ms_log will process messages using the global logging parameters.
ms_log_l is a reentrant version of ms_log. It uses the logging parameters specified in the supplied MSLogParam struct. If logp is NULL, global parameters will be used β which would be equivalent to a call to ms_log(). This one is intended for use only when complicated logging schemes are desired, e.g. in a threaded application. And bestie, heads up: it is not possible to set thread specific logging parameters for the internal library functions, because global parameters are used. iykyk π
The ms_loginit functions are how you set the log and error printing functions, plus the log and error message prefixes used by the ms_log functions.
ms_loginit will operate on the global logging parameters.
ms_loginit_l is a reentrant version of ms_loginit. It will initialize or change the logging parameters specified in the MSLogParam struct. If logp is NULL, a new MSLogParam struct will be allocated. A pointer to the created or re-initialized MSLogParam struct will be returned. That returned pointer is suitable for use with ms_log_l π«Ά
Use NULL for the print function pointers or the prefixes if they should not be changed from previously set or default values.
The default values for the logging parameters are:
log_print = fprintf (printing to standard out)
log_prefix = ""
diag_print = fprintf (printing to standard error)
err_prefix = "Error: "
By setting the printing functions, it is possible to re-direct all of the output from these logging routines. This is useful when the libmseed based software is embedded in a system with its own logging facilities. Chef's kiss, honestly π
Most of the libmseed internal messages are logged at either the diagnostic or error level.
π RETURN VALUES π
ms_logandms_log_lreturn the number of characters formatted on success, and a negative value on error πms_loginit_lreturns a pointer to theMSLogParamstruct that it operated on. If the inputMSLogParamstruct isNULL, a new struct will be allocated withmalloc().
π EXAMPLE π
Unless a complicated logging scheme is needed, most uses of this logging facility will be limited to the ms_loginit and ms_log functions. Very demure, very mindful.
An example of setting the printing functions:
#include <libmseed.h>
void log_print (const char *message);
void diag_print (const char *message);
main () {
ms_loginit (&log_print, "LOG: ", &diag_print, "ERR: ");
/* Normal log message, "LOG: " will be prefixed */
ms_log (0, "Normal log message for %s0, argv[0]);
/* Diagnostic message, "LOG: " will be prefixed */
ms_log (1, "Diagnostic message for %s0, argv[0]);
/* Error message, "ERR: " will be prefixed */
ms_log (2, "Error message for %s0, argv[0]);
}
void log_print (const char *message) {
/* Send message to external log message facility */
send_log(message);
}
void diag_print (const char *message) {
/* Send message to external error message facility */
send_error(message);
}
π AUTHOR π
- Chad Trabant
- IRIS Data Management Center
okay that's the whole page, you ate it, no crumbs π
and that's a wrap bestie β this page is from MS_LOG(3), dated 2014/07/16, and it's part of the Library Functions Manual. Go forth and log responsibly π¦β¨π
π¦ where this page comes from
- debian bookworm: libmseed-doc 2.19.8-1 Β· LGPL-3.0-or-later
- debian trixie: libmseed-doc 2.19.8-1 Β· LGPL-3.0-or-later
- ubuntu jammy: libmseed-doc 2.19.6-3 Β· LGPL-3.0-or-later
- ubuntu noble: libmseed-doc 2.19.8-1ubuntu2 Β· LGPL-3.0-or-later
- ubuntu questing: libmseed-doc 2.19.8-1ubuntu2
- ubuntu resolute: libmseed-doc 2.19.8-1ubuntu3 Β· LGPL-3.0-or-later
- ubuntu stonking: libmseed-doc 2.19.8-1ubuntu3 Β· LGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms