home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / WEBSERVE / PI3 / PI3WEB.EXE / DEVEL / INCLUDE / PILog.h < prev    next >
C/C++ Source or Header  |  1997-10-19  |  6KB  |  181 lines

  1. /*____________________________________________________________________________*\
  2.  *
  3.  
  4.  Copyright (c) 1997 John Roy. All rights reserved.
  5.  
  6.  These sources, libraries and applications are
  7.  FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
  8.  as long as the following conditions are adhered to.
  9.  
  10.  Redistribution and use in source and binary forms, with or without
  11.  modification, are permitted provided that the following conditions
  12.  are met:
  13.  
  14.  1. Redistributions of source code must retain the above copyright
  15.     notice, this list of conditions and the following disclaimer. 
  16.  
  17.  2. Redistributions in binary form must reproduce the above copyright
  18.     notice, this list of conditions and the following disclaimer in
  19.     the documentation and/or other materials provided with the
  20.     distribution.
  21.  
  22.  3. Redistributions of any form whatsoever and all advertising materials 
  23.     mentioning features must contain the following
  24.     acknowledgment:
  25.     "This product includes software developed by John Roy
  26.     (http://www.johnroy.com/pi3/)."
  27.  
  28.  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  29.  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30.  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  31.  IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  32.  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33.  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34.  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35.  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  36.  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  37.  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  38.  OF THE POSSIBILITY OF SUCH DAMAGE.
  39.  
  40.  *____________________________________________________________________________*|
  41.  *
  42.  * $Source: PILog.h$
  43.  * $Date: Sun Aug 10 06:42:18 1997$
  44.  *
  45.  Description:
  46. \*____________________________________________________________________________*/
  47. /* $HeaderTop:$ */
  48.  
  49. #ifndef PILOG_H_
  50. #define PILOG_H_
  51.  
  52. #include "Pi2API.h"
  53.  
  54. /*____________________________________________________________________________*\
  55.  *
  56.  Description:
  57. \*____________________________________________________________________________*/
  58. /* --- error types --- */
  59. #define    PILOG_ERROR        1    
  60. #define    PILOG_WARNING    2
  61. #define PILOG_ALL        3
  62.  
  63. /* --- sink types --- */
  64. #define PILOG_DB        0
  65. #define PILOG_FILE        1
  66. #define PILOG_STDOUT    2
  67. #define PILOG_STDERR    3
  68.  
  69. /*____________________________________________________________________________*\
  70.  *
  71.  Name:
  72.     PILog_addMessage
  73.  
  74.  Synopsis:
  75.     int PILog_addMessage( PIDB *pDB, PIConfig *pConfig, int iType,
  76.         const char *pFormat, ... );
  77.     
  78.  Description:
  79.     Log a message concerning initialization from a configuration file. 
  80.     PILog_addMessage() will automatically include information from
  81.     parsed configuration DB pConfig.
  82.  
  83.     pFormat is a printf() compatible format string. PILog_addMessage()
  84.     takes a variable number of arguments. The number and type of
  85.     arguments should be compatible with printf() directives.
  86.  
  87.     The flag iType indicates whether the item should be logged as an
  88.     error or a warning, it may contain one of the following values:-
  89.         PILOG_ERROR    
  90.         PILOG_WARNING
  91.         PILOG_ALL
  92.  
  93.  Notes:
  94.     PILog_addMessage() looks under the root DB for a DB with a key of 
  95.     PIDBKEY_DIAGNOSTICS.
  96.  
  97.  Return Values:
  98.     On success PILog_addMessage() returns zero (PIAPI_COMPLETED).
  99.  
  100.  Errors:
  101.     PIAPI_EINVAL    if pDB or pFormat is NULL.
  102.     PIAPI_ERROR        if another error occurred.
  103.  
  104.  See Also:
  105. \*____________________________________________________________________________*/
  106. PUBLIC_PIAPI int PILog_addMessage( PIDB *pDB, PIConfig *pConfig, int iType,
  107.     const char *pFormat, ... );
  108.  
  109. /*____________________________________________________________________________*\
  110.  *
  111.  Name:
  112.     PILog_writeDiagnostics
  113.  
  114.  Synopsis:
  115.     int PILog_writeDiagnostics( PIDB *pDB, int iFlags, const char *pFileName )
  116.     
  117.  Description:
  118.     Write the contents of the diagnostics DB to the file pFileName. The
  119.     value iFlags is the inclusive-or of diagnostic types to write,  the
  120.     macro PILOG_ALL can be used to specify all message types.
  121.  
  122.     If pFileName is NULL the output will be written to the standard output.
  123.  
  124.  Notes:
  125.     PILog_writeDiagnostics() looks under the root DB for a DB with a key of 
  126.     PIDBKEY_DIAGNOSTICS.
  127.  
  128.  Return Values:
  129.     On success PILog_writeDiagnostics() returns zero (PIAPI_COMPLETED).
  130.  
  131.  Errors:
  132.     PIAPI_EINVAL    if pDB is NULL.
  133.     PIAPI_ERROR        if another error occurred.
  134.  
  135.  See Also:
  136. \*____________________________________________________________________________*/
  137. PUBLIC_PIAPI int PILog_writeDiagnostics( PIDB *pDB, int iFlags, 
  138.     const char *pFileName );
  139.  
  140. /*____________________________________________________________________________*\
  141.  *
  142.  Name:
  143.     PILog_newSink
  144.  
  145.  Synopsis:
  146.     int PILog_newSink( int iType, const char *pParam )
  147.     
  148.  Description:
  149.     Sets a new sink for logged messages. Messages can be sent to the
  150.     main program DB (default), to a file (path to file is given by parameter
  151.     pParam), or to a standard stream.
  152.  
  153.     The following flags for iType dictate the new sink.
  154.  
  155. <UL>
  156. <ITEM><B>PILOG_DB</B>     - main program DB, under subtree 'Diagnostics'.
  157. <ITEM><B>PILOG_FILE</B>     - a file, path is specified by parameter pParam.
  158. <ITEM><B>PILOG_STDOUT</B> - the stdout stream.
  159. <ITEM><B>PILOG_STDERR</B> - the stderr stream.
  160. </UL>
  161.  
  162.  Notes:
  163.     Current logging to a file via this mechanism is not implemented,    
  164.     attempting to set the log sink to a file will result in an error
  165.     code of PIAPI_NOTSUPPORTED.
  166.  
  167.  Return Values:
  168.     On success PILog_newSink() returns zero (PIAPI_COMPLETED).
  169.  
  170.  Errors:
  171.     PIAPI_EINVAL    if iType is PILOG_FILE and pParam is NULL.
  172.     PIAPI_ERROR        if another error occurred.
  173.     PIAPI_NOTSUPPRTED as described under notes.
  174.  
  175.  See Also:
  176. \*____________________________________________________________________________*/
  177. PUBLIC_PIAPI int PILog_newSink( int iType, const char *pParam );
  178.  
  179. #endif    /* PILOG_H_ */
  180.  
  181.