📄 ms_log.3
字号:
.TH MS_LOG 3 2006/11/21.SH NAMEms_log and friends \- Central logging facility for libmseed.SH SYNOPSIS.nf.B #include <libmseed.h>.sp.BI "int \fBms_log\fP (int " level ", const char *" format ", ...);.sp.BI "int \fBms_log_l\fP (MSLogParam *" logp ", int " level ", const char *" format ", ...);.sp.BI "void \fBms_loginit\fP (void (*" log_print ")(const char*), const char *" logprefix ",.BI " void (*" diag_print ")(const char*), const char *" errprefix ");.sp.BI "MSLogParam * \fBms_loginit_l\fP (MSLogParam *" logp ",.BI " void (*" log_print ")(const char*), const char *" logprefix ",.BI " void (*" diag_print ")(const char*), const char *" errprefix ");.fi.SH DESCRIPTIONThe \fBms_log\fP functions are the central logging facility forall output from libmseed functions. They are also intended to be usedby libmseed based programs if desired.Three message levels are recognized: 0 : Normal log messgaes, printed using log_print with logprefix 1 : Diagnostic messages, printed using diag_print with logprefix 2+ : Error messages, printed using diag_print with errprefixIt is the task of the \fBms_log\fP functions to format a message using\fBprintf\fP conventions and pass the formatted string to theappropriate printing function (\fIlog_print\fP or \fIdiag_print\fP)\fBms_log\fP will process messages using the global loggingparameters.\fBms_log_l\fP is a reentrant version of \fBms_log\fP. It will usethe logging parameters specified in the supplied MSLogParam struct.If \fBlogp\fP is NULL global parameters will be used, this would beequivalent to a call to ms_log(). This is intended for use only whencomplicated logging schemes are desired, e.g. in a threadedapplication. Note that it is not possible to set thread specificlogging parameters for the internal library functions because globalparameters are used.The \fBms_loginit\fP functions are used to set the log and errorprinting functions and the log and error message prefixes used by the\fBms_log\fP functions.\fBms_loginit\fP will operate on the global logging parameters.\fBms_loginit_l\fP is a reentrant version of \fBms_loginit\fP. Itwill initialize or change the logging parameters specified in theMSLogParam struct. If \fIlogp\fP is NULL a new MSLogParam struct willbe allocated. A pointer to the created or re-initialized MSLogParamstruct will be returned. The returned pointer is suitable for use with\fBms_log_l\fP.Use NULL for the print function pointers or the prefixes if theyshould 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 ofthe output from these logging routines. This is useful when thelibmseed based software is embedded in a system with it's own loggingfacilities.Most of the libmseed internal messages are logged at either thediagnostic or error level..SH RETURN VALUES\fBms_log\fP and \fBms_log_l\fP return the number of charactersformatted on success, and a negative value on error.\fBms_loginit_l\fP returns a pointer to the MSLogParam struct that itoperated on. If the input MSLogParam struct is NULL a new struct willbe allocated with \fBmalloc()\bP..SH EXAMPLEUnless a complicated logging scheme is needed most uses of thislogging facility will be limited to the ms_loginit and ms_logfunctions.An example of setting the printing functions:.nf#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 %s\n", argv[0]); /* Diognostic message, "LOG: " will be prefixed */ ms_log (1, "Diagnositc message for %s\n", argv[0]); /* Error message, "ERR: " will be prefixed */ ms_log (2, "Error message for %s\n", 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);}.fi.SH AUTHOR.nfChad TrabantIRIS Data Management Center.fi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -