Logtext - Dokumentation
Heimseite - Download - Dokumentation - Forum - Fehler melden - Impressum - Lizenzvereinbarung - Externe Verweise
 
 
Beispielprogramm zur Verwendung der DLL logtext.dll - logtextexample
 
Dieses Beispiel zeigt, wie die Bibliothek in eigene Applikationen implementiert und aufgerufen wird.
 
 
 
 

logtext.h

gehe zur Dokumentation dieser Datei
00001 /*
00002  * C/C++ header file for logtext.dll
00003  * ---------------------------------
00004  *
00005  * For versions 1.6.16 and higher only.
00006  *
00007  * Do not use this file for lower versions. Aquire the header file that
00008  * belongs to the used version instead.
00009  *
00010  *
00011  */
00012 
00013 #include <io.h>
00014 #include <windows.h>
00015 
00016 #ifndef _logtext_h__now_included
00017 #define _logtext_h__now_included
00018 
00019 #define DllImport   __declspec( dllimport )
00020 #define DllExport   __declspec( dllexport )
00021 
00022 extern DllExport char *chCurrentDateTimeText;
00023 extern DllExport char *chCurrentDateWeekText;
00024 extern DllExport char *chCurrentLogFileName;
00025 extern DllExport char *chCurrentDateNoBlanks;
00026 extern DllExport char *chCurrentDateWeek;
00027 extern DllExport char *chCurrentDTMSText;
00028 
00029 #define MAX_DATE_TIME_TEXT              26              /* yyyy-mm-dd hh:mi:ss +01:00 */
00030 #define MAX_DATE_WEEK_TEXT              11              /* yyyy-Www-dd */
00031 #define MAX_DATE_NO_BLANKS               8              /* yyyymmdd */
00032 #define MAX_DATE_WEEK                    6              /* yyyy-W */
00033 #define MAX_DTMS_TEXT                   30              /* yyyy-mm-dd hh:mi:ss.mis +01:00 */
00034 
00035 typedef struct sCurrentDateTime
00036 {
00037         char    chCurrentDateTimeText[MAX_DATE_TIME_TEXT + 1];
00038         char    chCurrentDateWeekText[MAX_DATE_WEEK_TEXT + 1];
00039         char    chCurrentDateNoBlanks[MAX_DATE_NO_BLANKS + 1];
00040         char    chCurrentDateWeek[MAX_DATE_WEEK + 1];
00041         char    chCurrentDTMSText[MAX_DTMS_TEXT + 1];
00042 } SCURRENTDATETIME;
00043 
00044 // The structure for LogTextEx ().
00045 typedef struct sLogTextEx
00046 {
00047         DWORD                           dwOptions;                                                      // Simple options.
00048         DWORD                           dwExOptions;                                            // Extended options.
00049         unsigned long           ul_LO_QUICK_Counter;                            // Counter for LO_QUICK.
00050         unsigned long           ul_LO_QUICK_local_Counter;                      // Counter for LO_QUICK.
00051         unsigned long           ulMaxLogs;                                                      // Maximum amount of log files to keep.
00052         unsigned long           ulMaxZips;                                                      // Maximum amount of zip files to keep.
00053         unsigned long           ulTimeOut;                                                      // Timeout value.
00054         SCURRENTDATETIME        *scdt;                                                          // Formatted date/time structure.
00055         char                            *chLogFileName;                                         // Log file name.
00056         char                            *chMaskLogFile;                                         // Default: *.log (not yet used)
00057         char                            *chExteLogFile;                                         // Default: .log  (not yet used)
00058         char                            *chMaskZipFile;                                         // Default: *.zip (not yet used)
00059         char                            *chExteZipFile;                                         // Default: .zip  (not yet used)
00060         char                            *chExteBakFile;                                         // Default: .bak  (not yet used)
00061         char                            *chConfigFile;                                          // Configuration file name.
00062         char                            *chExtExecutionString;                          // External packer (executable).
00063         char                            *chExtParameterString;                          // External packer (parameters).
00064         DWORD                           dwExtCreationFlags;                                     // External packer (creation flags).
00065 
00066                                                                                                                         // New in version 1.5.6.
00067         DWORD                           dwLogBufferLength;                                      // Length (in octets) of buffer to log.
00068         DWORD                           dwLogWidth;                                                     // Width for binary logging (default is 16) in octets.
00069         size_t                          stSLOGTEXTINILength;                            // sizeof (SLOGTEXTINI)
00070 } SLOGTEXTINI;
00071 
00072 // One section of a configuration file in memory.
00073 typedef struct sIni
00074 {
00075         struct sIni                     *_nextEntry;
00076         char                            *chSection;
00077         SLOGTEXTINI                     *slogtextini;
00078         unsigned long           ulLines;
00079 } SINISECTION;
00080 
00081 // One queue element for LogTextExQ ().
00082 typedef struct sLogTextExQ
00083 {
00084         struct sLogTextExQ      *_nextEntry;
00085         char                            *chApplication;
00086         char                            *chLogText;
00087         SLOGTEXTINI                     *slogtextini;
00088         unsigned long           ulLostMessages;
00089 } SLOGTEXTINIQ;
00090 
00091 // Logging options.
00092 #define LO_ECHO                                 0x00000001
00093 #define LO_ECHO_ONLY                    0x00000002
00094 #define LO_QUICK                                0x00000004
00095 #define LO_LOGNAME_ONLY                 0x00000008
00096 #define LO_INCLUDE_APP                  0x00000010
00097 #define LO_NO_DATE                              0x00000020
00098 #define LO_DAILY                                0x00000040              /* Default. Create a new log file daily. */
00099 #define LO_WEEKLY                               0x00000080              /* Create a new log file weekly. */
00100 #define LO_MONTHLY                              0x00000100
00101 #define LO_YEARLY                               0x00000200
00102 #define LO_LINES                                0x00000400
00103 #define LO_SIZE                                 0x00000800
00104 #define LO_DELETE_ZIPS                  0x00001000
00105 #define LO_DELETE_LOGS                  0x00002000
00106 #define LO_LOG_DELETION                 0                               /* Not required: default setting. */
00107 #define LO_DONT_LOG_DELETION    0x00004000
00108 #define LO_DONT_ZIP                             0x00008000
00109 #define LO_LOG_ZIPPING                  0                               /* Not required: default setting. */
00110 #define LO_DONT_LOG_ZIPPING             0x00010000
00111 //#define LO_SET_QUICK                  0x00020000
00112 #define LO_NO_BANNER                    0x00020000              /* Don't log the startup message */
00113 #define LO_TIME_T                               0x00040000              /* Use 'T' to seperate date/time and event text */
00114 #define LO_STDERR                               0x00080000
00115 #define LO_USER_ISO_DATE                0x00100000
00116 #define LO_REG_ISO_DATE                 0x00200000
00117 #define LO_KEEP_CRLF                    0x00400000
00118 #define LO_LOG_REGISTRY                 0                               /* Not required: default setting. */
00119 #define LO_DONT_LOG_REGISTRY    0x00800000              /* Don't log changes to the registry. */
00120 #define LO_LOGNAME                              0x01000000              /* Leave the log file's name for the caller */
00121 #define LO_LOG_ALL                              0
00122 #define LO_DONT_LOG_ACTIONS             (LO_DONT_LOG_DELETION | LO_DONT_LOG_ZIPPING | LO_DONT_LOG_REGISTRY)
00123 
00124 // Additional logging options (for LogTextEx and LogTextExQ, dwExOptions).
00125 #define LE_NO_CONFIG                    0x00000001              /* Don't read the config (ini) file.    */
00126 #define LE_LOG_CONFIG                   0                               /* Always used now, hence no value.     */
00127 #define LE_DONT_LOG_CONFIG              0x00000002
00128 #define LE_DONT_LOG                             0x00000004              /* Only zip, but don't log anything     */
00129 #define LE_SET_DATE_TIME                0x00000008              /* Use date and time provided within
00130                                                                                                  *      SCURRENTDATETIME of SLOGTEXTINI
00131                                                                                                  *      structure.
00132                                                                                                  */
00133 //#define LE_START_PROCESS              0x00000010              // Start a new process for LogTextExQ ()
00134                                                                                                 //      instead of just a thread.
00135 #define LE_FORCE_BINARY                 0x00000020              /* Always log in binary mode. */
00136 #define LE_LOG_BINARY                   LE_FORCE_BINARY
00137 
00138 // Sort the directory listing for FAT or FAT32.
00139 #define LE_SORT_DIR                             0x00000040              /* Force the directory listing to be
00140                                                                                                  *  sorted. Only required for FAT and
00141                                                                                                  *  FAT32. This option bit does not
00142                                                                                                  *  need to be set by the caller.
00143                                                                                                  */
00144 #define LE_PAUSE_BEFORE_LOG             0x00000080              /* Pause the logging thread for
00145                                                                                                  * ulTimeOut milliseconds.
00146                                                                                                  */
00147 #define LE_DONT_LOG_MS                  0x00000100              /* Don't append milliseconds to time.   */
00148 #define LE_NO_MS                                LE_DONT_LOG_MS
00149 #define LE_LOGTEXTEXQ                   0x00000200              /* Internal identifier. Don't use.      */
00150 #define LE_PAUSE_AFTER_LOG              0x00000400              /* Pause the logging thread for
00151                                                                                                  * ulTimeOut milliseconds.
00152                                                                                                  */
00153 #define LE_SUSPEND_LOG                  0x00001000              /* LogTextExQ: Suspend logging thread.  */
00154 #define LE_RESUME_LOG                   0x00002000              /* LogTextExQ: Resume logging thread.   */
00155 #define LE_IGNORE_EVENT                 0x00004000              /* LogTextExQ: Ignore the whole event.  */
00156 
00157 #define LE_THREE_BLANKS                 0x00008000              /* Leave 3 blanks between the date/time
00158                                                                                                  * stamp and the text to log instead of
00159                                                                                                  * just one. Together with LE_DONT_LOG_SEC
00160                                                                                                  * this is compatible with
00161                                                                                                  * Inno Setup's (http://www.innosetup.org)
00162                                                                                                  * log files.
00163                                                                                                  */
00164 #define LE_DONT_LOG_SEC                 0x00010000              /* Don't append seconds, milliseconds,
00165                                                                                                  * and offset to time.
00166                                                                                                  * Only output yyyy-mm-dd hh:mm.
00167                                                                                                  */
00168 #define LE_DONT_LOG_SECS                LE_DONT_LOG_SEC
00169 #define LE_NO_SEC                               LE_DONT_LOG_SEC
00170 #define LE_NO_SECS                              LE_DONT_LOG_SEC
00171 #define LE_DONT_LOG_SECMS               LE_DONT_LOG_SEC
00172 #define LE_NO_BANNER                    0x00020000              /* Don't log the startup message */
00173 #define LE_ADD_DOT                              0x00040000              /* Adds a dot ('.') to the logging data
00174                                                                                                  * when ASCII.
00175                                                                                                  */
00176 #define LE_ADD_FULL_STOP                LE_ADD_DOT
00177 
00178 // Used filename extensions.
00179 #define _MASK_LOGFILE   "*.log"
00180 #define _EXTE_LOGFILE   ".log"
00181 #define _MASK_ZIPFILE   "*.gz"
00182 #define _EXTE_ZIPFILE   ".gz"
00183 #define _EXTE_BAKFILE   ".~tmp.bak"
00184 
00185 #ifdef __cplusplus
00186         extern "C" {
00187 #endif
00188 
00189 #define CALLCONV __cdecl
00190 #define STDCCONV __stdcall
00191 
00192 // Standard logging function, single threaded.
00193 extern DllExport int CALLCONV LogText           (const char *chApplication, const char *chLogText, DWORD dwOptions,
00194                                                                                          unsigned long ulMaxLogs, unsigned long ulMaxZips);
00195 // Extended logging function, multi-threaded.
00196 extern DllExport int CALLCONV LogTextEx         (const char *chApplication, const char *chLogText, SLOGTEXTINI *sltIni);
00197 
00198 // Extended logging function, multi-threaded and queued.
00199 extern DllExport int CALLCONV LogTextExQ        (const char *chApplication, const char *chLogText, SLOGTEXTINI *sltIni);
00200 
00201 // The logging functions as stdcall for other programming languages.
00202 extern DllExport int STDCCONV sLogText          (const char *chApplication, const char *chLogText, DWORD dwOptions,
00203                                                                                          unsigned long ulMaxLogs, unsigned long ulMaxZips);
00204 extern DllExport int STDCCONV sLogTextEx        (const char *chApplication, const char *chLogText, SLOGTEXTINI *sltIni);
00205 extern DllExport int STDCCONV sLogTextExQ       (const char *chApplication, const char *chLogText, SLOGTEXTINI *sltIni);
00206 
00207 // Empty the queue for LogTextExQ before detaching the DLL.
00208 extern DllExport BOOL bDequeueOnExit;
00209 extern DllExport BOOL bAboutToExit;
00210 
00211 typedef int (CALLCONV *LPLOGTEXT)                       (const char *chApplication, const char *chLogText, DWORD dwOptions,
00212                                                                                          unsigned long ulMaxLogs, unsigned long ulMaxZips);
00213 typedef int (CALLCONV *LPLOGTEXTEX)                     (const char *chApplication, const char *chLogText, SLOGTEXTINI *sltIni);
00214 typedef int (CALLCONV *LPLOGTEXTEXQ)            (const char *chApplication, const char *chLogText, SLOGTEXTINI *sltIni);
00215 
00216 typedef int (STDCCONV *LPSLOGTEXT)                      (const char *chApplication, const char *chLogText, DWORD dwOptions,
00217                                                                                          unsigned long ulMaxLogs, unsigned long ulMaxZips);
00218 typedef int (STDCCONV *LPSLOGTEXTEX)            (const char *chApplication, const char *chLogText, SLOGTEXTINI *sltIni);
00219 typedef int (STDCCONV *LPSLOGTEXTEXQ)           (const char *chApplication, const char *chLogText, SLOGTEXTINI *sltIni);
00220 
00221 extern  LPLOGTEXT               lpLogText;
00222 extern  LPLOGTEXTEX             lpLogTextEx;
00223 extern  LPLOGTEXTEXQ    lpLogTextExQ;
00224 extern  LPSLOGTEXT              lpsLogText;
00225 extern  LPSLOGTEXTEX    lpsLogTextEx;
00226 extern  LPSLOGTEXTEXQ   lpsLogTextExQ;
00227 extern  HMODULE                 hLogTextDLL;
00228 
00229 /*
00230   LoadAndInitializeLogText
00231   
00232   Loads the library logtext.dll and initializes the function pointers. If chLogTextPath
00233   is NULL the function searches the standard paths for the DLL. Otherwise chLogTextPath
00234   must be the full path including the file name, for instance
00235   "C:\program files\MyApp\logtext.dll".
00236 
00237   Returns 0 if an error occured.
00238   Returns 1 if successful.
00239 */
00240 int     LoadAndInitializeLogText (char *chLogTextPath);
00241 
00242 #ifdef __cplusplus
00243         }
00244 #endif
00245 
00246 #endif
 
 
 
 
 
 
 
 

Heimseite - Download - Dokumentation - Forum - Fehler melden - Impressum - Lizenzvereinbarung - Externe Verweise