📄 logtest.cpp
字号:
/* * logtest.cpp - part of jEditLauncher package * Copyright (C) 2001 John Gellene * jgellene@nyc.rr.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * Notwithstanding the terms of the General Public License, the author grants * permission to compile and link object code generated by the compilation of * this program with object code and libraries that are not subject to the * GNU General Public License, provided that the executable output of such * compilation shall be distributed with source code on substantially the * same basis as the jEditLauncher package of which this program is a part. * By way of example, a distribution would satisfy this condition if it * included a working makefile for any freely available make utility that * runs on the Windows family of operating systems. This condition does not * require a licensee of this software to distribute any proprietary software * (including header files and libraries) that is licensed under terms * prohibiting redistribution to third parties. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id: logtest.cpp,v 1.3 2001/12/28 16:54:47 jgellene Exp $ */// logtest.cpp : A test program for the logging dll// This version requires that a copy of ltslog.dll be in the same// directory as the test application's executable#include <stdio.h>#include <windows.h>#include "..\ltslog\ltslog.h"/* * The types are defined as typedef's in the ltslog.h header file * Code beginning here may be copied to another module to * provide activation routines. */LogOpenFunc openProc;LogCloseFunc closeProc;LogLevelFunc levelProc;LogFunc logProc;HMODULE hLogModule;bool LoadLogLibrary(){ hLogModule = LoadLibrary("ltslog.dll"); if(hLogModule != 0) { openProc = (LogOpenFunc)GetProcAddress(hLogModule, "OpenLog"); logProc = (LogFunc)GetProcAddress(hLogModule, "Log"); levelProc = (LogLevelFunc)GetProcAddress(hLogModule, "SetLogLevel"); closeProc = (LogCloseFunc)GetProcAddress(hLogModule, "CloseLog"); return openProc != 0 && logProc != 0 || levelProc != 0 && closeProc != 0; } return false;}void UnloadLogLibrary(){ FreeLibrary(hLogModule);}/* End of activation routine *//* * Main routine of test program */int main(int, char*){ if(!LoadLogLibrary()) return 1; const char* szLevelTest = "Testing logging dll with level set to '%s'.\n"; const int sleepLen = 100; CLtslog *pLog = (openProc)("test.log", Debug); (logProc)(pLog, true, Debug, szLevelTest, "Debug"); (logProc)(pLog, true, Error, "This is an error message.\n"); (logProc)(pLog, true, Warning, "This is a warning message.\n"); (logProc)(pLog, true, Notice, "This is a notice message.\n"); (logProc)(pLog, true, Message, "This is a 'message' message.\n"); (logProc)(pLog, true, Notice, "Sleeping for %d milliseconds.\n", sleepLen); Sleep(sleepLen); (logProc)(pLog, true, Message, "The logging object is located at 0x%08X\n", pLog); (logProc)(pLog, true, Message, "The next message has a message level of 'Debug'.\n"); (logProc)(pLog, true, Debug, szLevelTest, "Debug"); (logProc)(pLog, true, Message, "Changing message level to 'Message'.\n"); (levelProc)(pLog, Message); (logProc)(pLog, true, Message, "The next message has a message level of 'Debug' "); (logProc)(pLog, false, Message, "and should not be printed.\n"); (logProc)(pLog, true, Debug, szLevelTest, "Message"); (logProc)(pLog, true, Message, "The next message has a message level of 'Message'.\n"); (logProc)(pLog, true, Message, szLevelTest, "Message"); for(int i = 0; i < 1500; ++i) (logProc)(pLog, true, Message, szLevelTest, "Message"); (closeProc)(pLog); UnloadLogLibrary(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -