svn rev #22101: tools/gssmonger/trunk/gssmaster/
raeburn@MIT.EDU
raeburn at MIT.EDU
Mon Mar 16 15:39:38 EDT 2009
http://src.mit.edu/fisheye/changelog/krb5/?cs=22101
Commit By: raeburn
Log Message:
native eol-style
Changed Files:
UU tools/gssmonger/trunk/gssmaster/ezlog_log4cpp.cpp
Modified: tools/gssmonger/trunk/gssmaster/ezlog_log4cpp.cpp
===================================================================
--- tools/gssmonger/trunk/gssmaster/ezlog_log4cpp.cpp 2009-03-16 18:00:06 UTC (rev 22100)
+++ tools/gssmonger/trunk/gssmaster/ezlog_log4cpp.cpp 2009-03-16 19:39:37 UTC (rev 22101)
@@ -1,291 +1,291 @@
-/*++
-
- EZLOG_LOG4CPP.CPP
-
- Microsoft Permissive License (Ms-PL)
-
- This license governs use of the accompanying software. If you use the
- software, you accept this license. If you do not accept the license,
- do not use the software.
-
- 1. Definitions
- The terms "reproduce," "reproduction" and "distribution" have the same
- meaning here as under U.S. copyright law. "You" means the licensee of the
- software. "Licensed patents" means any Microsoft patent claims which read
- directly on the software as distributed by Microsoft under this license.
-
- 2. Grant of Rights
- (A) Copyright Grant- Subject to the terms of this license, including the
- license conditions and limitations in section 3, Microsoft grants you a
- non-exclusive, worldwide, royalty-free copyright license to reproduce the
- software, prepare derivative works of the software and distribute the
- software or any derivative works that you create.
-
- (B) Patent Grant- Subject to the terms of this license, including the license
- conditions and limitations in section 3, Microsoft grants you a non-
- exclusive, worldwide, royalty-free patent license under licensed patents to
- make, have made, use, practice, sell, and offer for sale, and/or otherwise
- dispose of the software or derivative works of the software.
-
- 3. Conditions and Limitations
- (A) No Trademark License- This license does not grant you any rights to use
- Microsoft's name, logo, or trademarks.
-
- (B) If you begin patent litigation against Microsoft over patents that you
- think may apply to the software (including a cross-claim or counterclaim in
- a lawsuit), your license to the software ends automatically.
-
- (C) If you distribute copies of the software or derivative works, you must
- retain all copyright, patent, trademark, and attribution notices that are
- present in the software.
-
- (D) If you distribute the software or derivative works in source code form
- you may do so only under this license (i.e., you must include a complete
- copy of this license with your distribution), and if you distribute the
- software or derivative works in compiled or object code form you may only do
- so under a license that complies with this license.
-
- (E) The software is licensed "as-is." You bear the risk of using it.
- Microsoft gives no express warranties, guarantees or conditions. You may
- have additional consumer rights under your local laws which this license
- cannot change. To the extent permitted under your local laws, Microsoft
- excludes the implied warranties of merchantability, fitness for a particular
- purpose and non-infringement.
-
- DESCRIPTION: reimplementation of ezLog API functions as wrappers around the log4c library
-
- As a warning to future users: This is a very ugly hack to shoehorn log4cpp onto the ezlog API in a way that doens't break too many things. I make no guarantees about sanity. It should work reasonably well, though.
-
- Created, July 9, 2007 by Adam Seering.
-
---*/
-
-#include <stdarg.h>
-#include <stdio.h>
-#include "unix.h"
-#include "ezlog.h"
-#include "protocol.h"
-#define LPEZSTR LPSTR
-
-#include <log4cpp/Category.hh>
-#include <log4cpp/FileAppender.hh>
-#include <log4cpp/OstreamAppender.hh>
-#include <log4cpp/BasicLayout.hh>
-
-#include <iostream>
-
-using namespace log4cpp;
-
-#ifndef WINNT
-#define __stdcall
-#define __cdecl
-#endif // WINNT
-
-
-// Convert EZLog priority ID's to Log4CPP priority ID's
-int etol_priority(int EZLogPriority) {
- // Note that these mappings are pretty arbitrary.
- // There may well be reason to tweak them in the future.
-
- int Log4cPriority;
-
- switch(EZLogPriority) {
- case EZLOG_ABORT:
- Log4cPriority = Priority::FATAL;
- break;
-
- case EZLOG_BLOCK:
- Log4cPriority = Priority::NOTICE;
- break;
-
- case EZLOG_KNOWNBUG:
- Log4cPriority = Priority::WARN;
- break;
-
- case EZLOG_SEV1:
- Log4cPriority = Priority::ERROR;
- break;
-
- case EZLOG_SEV2:
- Log4cPriority = Priority::ERROR;
- break;
-
- case EZLOG_SEV3:
- Log4cPriority = Priority::ERROR;
- break;
-
- case EZLOG_WARN:
- Log4cPriority = Priority::WARN;
- break;
-
- case EZLOG_PASS:
- Log4cPriority = Priority::DEBUG;
- break;
-
- case EZLOG_SKIPPED:
- Log4cPriority = Priority::DEBUG;
- break;
-
- case EZLOG_INFO:
- Log4cPriority = Priority::INFO;
- break;
-
- case EZLOG_DEBUG:
- Log4cPriority = Priority::DEBUG;
- break;
-
- case EZLOG_DBGPRINT:
- Log4cPriority = Priority::DEBUG;
- break;
-
- default:
- Log4cPriority = Priority::NOTSET;
- }
-
- return Log4cPriority;
-}
-
-struct CatStack {
- Category *cat;
- CatStack *parent;
- CatStack(Category *c, CatStack *p = NULL) : cat(c), parent(p) { }
-};
-//Category *cat = NULL;
-static CatStack *cats = NULL;
-
-// Start a new log4cpp log
-EZLOGAPI ezStartBlock(IN OPTIONAL HANDLE OldLevel,
- OUT OPTIONAL PHANDLE NewLevel,
- IN OPTIONAL ULONG Flags, // currently ignored
- IN OPTIONAL ULONG LogLevel,
- IN LPEZSTR LogString,
- ...) {
-
- Appender* app = new FileAppender("FileAppender", "gssmaster.log");
- Appender* appConsole = new OstreamAppender("OstreamAppender", &(std::cout));
-
- Layout* layout = new BasicLayout();
- app->setLayout(layout);
-
- static ULONG BlockCounter = 0;
-
- char ProcessedLogString[4096];
- va_list args;
-
- va_start(args, LogString);
- vsnprintf(ProcessedLogString, 4096, LogString, args);
- va_end(args);
-
- char LogName[24];
- snprintf(LogName, 24, "gssMonger.%ld", BlockCounter);
-
- Category *cat = &Category::getInstance(LogName);
- cat->setAdditivity(true);
- cat->setAppender(app);
- cat->setAppender(appConsole);
- cats = new CatStack(cat, cats);
-
- ezLogMsg(EZLOG_BLOCK, EZ_DEFAULT, "StartBlock %p from %p(%s): %s",
- (void *)cat,
- OldLevel,
- (OldLevel
- ? ((CatStack *)OldLevel)->cat->getName().data()
- : "?"),
- ProcessedLogString);
-
- cat->log(etol_priority(LogLevel),
- ProcessedLogString);
-
- BlockCounter++;
-
- if (NewLevel)
- *NewLevel = (void*)cats;
-
- return TRUE;
-}
-
-// Log a message to the current log4cpp log
-EZLOGAPI ServerLogMessage( PPROTOCOL_CALLBACK_ARGS pArgs,
- IN PCHAR File,
- IN int Line,
- IN PCHAR LogString,
- ... ) {
- va_list args;
- va_start(args, LogString);
-
- ezStartBlock( NULL, NULL, 0, 0, LogString, args);
-}
-
-// Log a message to the current log4cpp log
-EZLOGAPI vezLogMsg( IN ULONG LogLevel,
- IN OPTIONAL HANDLE Log4cCategory,
- IN LPEZSTR File,
- IN ULONG Line,
- IN LPEZSTR LogString,
- IN va_list * ExtraArgs) {
-
- if (cats == NULL) {
- void* temp;
- ezStartBlock( NULL, &temp, 0, LogLevel, "Autoinitializing log..." );
- }
-
- char ProcessedLogString[4096];
- va_list * args = ExtraArgs;
-
- if (File) {
- const char *basename;
- basename = strrchr(File, '/');
- if (basename == NULL)
- basename = File;
- else
- basename++;
- snprintf(ProcessedLogString, sizeof(ProcessedLogString),
- "%s:%lu ", basename, Line);
- } else
- ProcessedLogString[0] = 0;
-
- vsnprintf(ProcessedLogString + strlen(ProcessedLogString),
- sizeof(ProcessedLogString) - strlen(ProcessedLogString),
- LogString, *args);
- va_end(*args);
-
- cats->cat->log(etol_priority(LogLevel), ProcessedLogString);
-
- return TRUE;
-}
-
-// Log a message to the current log4cpp log
-EZLOGAPI ezLogMsg(IN ULONG LogLevel,
- IN OPTIONAL HANDLE Log4cCategory,
- IN LPEZSTR File,
- IN ULONG Line,
- IN LPEZSTR LogString, ...) {
- va_list args;
-
- va_start(args, LogString);
- vezLogMsg( LogLevel, Log4cCategory, File, Line, LogString, &args );
-}
-
-// Close the specified log4cpp log
-EZLOGAPI ezFinishBlock( IN OPTIONAL HANDLE handle ) {
- ezLogMsg(EZLOG_BLOCK, EZ_DEFAULT, "FinishBlock %p(%s)", handle,
- (handle ? ((CatStack *)handle)->cat->getName().data() : "NULL"));
- CatStack *c2 = cats;
- cats = c2->parent;
- delete c2;
-}
-
-// Close the log4cpp log
-EZLOGAPI ezCloseLog( IN OPTIONAL ULONG flags, ... ) {
- Category::shutdown();
-}
-
-// Open the log4cpp log
-EZLOGAPI ezOpenLogEx( IN OUT PEZLOG_OPENLOG_DATA pData ) {
- // pass
-}
-
-#ifndef WINNT
-#undef __stdcall
-#undef __cdecl
-#endif // WINNT
+/*++
+
+ EZLOG_LOG4CPP.CPP
+
+ Microsoft Permissive License (Ms-PL)
+
+ This license governs use of the accompanying software. If you use the
+ software, you accept this license. If you do not accept the license,
+ do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction" and "distribution" have the same
+ meaning here as under U.S. copyright law. "You" means the licensee of the
+ software. "Licensed patents" means any Microsoft patent claims which read
+ directly on the software as distributed by Microsoft under this license.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the
+ license conditions and limitations in section 3, Microsoft grants you a
+ non-exclusive, worldwide, royalty-free copyright license to reproduce the
+ software, prepare derivative works of the software and distribute the
+ software or any derivative works that you create.
+
+ (B) Patent Grant- Subject to the terms of this license, including the license
+ conditions and limitations in section 3, Microsoft grants you a non-
+ exclusive, worldwide, royalty-free patent license under licensed patents to
+ make, have made, use, practice, sell, and offer for sale, and/or otherwise
+ dispose of the software or derivative works of the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you any rights to use
+ Microsoft's name, logo, or trademarks.
+
+ (B) If you begin patent litigation against Microsoft over patents that you
+ think may apply to the software (including a cross-claim or counterclaim in
+ a lawsuit), your license to the software ends automatically.
+
+ (C) If you distribute copies of the software or derivative works, you must
+ retain all copyright, patent, trademark, and attribution notices that are
+ present in the software.
+
+ (D) If you distribute the software or derivative works in source code form
+ you may do so only under this license (i.e., you must include a complete
+ copy of this license with your distribution), and if you distribute the
+ software or derivative works in compiled or object code form you may only do
+ so under a license that complies with this license.
+
+ (E) The software is licensed "as-is." You bear the risk of using it.
+ Microsoft gives no express warranties, guarantees or conditions. You may
+ have additional consumer rights under your local laws which this license
+ cannot change. To the extent permitted under your local laws, Microsoft
+ excludes the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+
+ DESCRIPTION: reimplementation of ezLog API functions as wrappers around the log4c library
+
+ As a warning to future users: This is a very ugly hack to shoehorn log4cpp onto the ezlog API in a way that doens't break too many things. I make no guarantees about sanity. It should work reasonably well, though.
+
+ Created, July 9, 2007 by Adam Seering.
+
+--*/
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "unix.h"
+#include "ezlog.h"
+#include "protocol.h"
+#define LPEZSTR LPSTR
+
+#include <log4cpp/Category.hh>
+#include <log4cpp/FileAppender.hh>
+#include <log4cpp/OstreamAppender.hh>
+#include <log4cpp/BasicLayout.hh>
+
+#include <iostream>
+
+using namespace log4cpp;
+
+#ifndef WINNT
+#define __stdcall
+#define __cdecl
+#endif // WINNT
+
+
+// Convert EZLog priority ID's to Log4CPP priority ID's
+int etol_priority(int EZLogPriority) {
+ // Note that these mappings are pretty arbitrary.
+ // There may well be reason to tweak them in the future.
+
+ int Log4cPriority;
+
+ switch(EZLogPriority) {
+ case EZLOG_ABORT:
+ Log4cPriority = Priority::FATAL;
+ break;
+
+ case EZLOG_BLOCK:
+ Log4cPriority = Priority::NOTICE;
+ break;
+
+ case EZLOG_KNOWNBUG:
+ Log4cPriority = Priority::WARN;
+ break;
+
+ case EZLOG_SEV1:
+ Log4cPriority = Priority::ERROR;
+ break;
+
+ case EZLOG_SEV2:
+ Log4cPriority = Priority::ERROR;
+ break;
+
+ case EZLOG_SEV3:
+ Log4cPriority = Priority::ERROR;
+ break;
+
+ case EZLOG_WARN:
+ Log4cPriority = Priority::WARN;
+ break;
+
+ case EZLOG_PASS:
+ Log4cPriority = Priority::DEBUG;
+ break;
+
+ case EZLOG_SKIPPED:
+ Log4cPriority = Priority::DEBUG;
+ break;
+
+ case EZLOG_INFO:
+ Log4cPriority = Priority::INFO;
+ break;
+
+ case EZLOG_DEBUG:
+ Log4cPriority = Priority::DEBUG;
+ break;
+
+ case EZLOG_DBGPRINT:
+ Log4cPriority = Priority::DEBUG;
+ break;
+
+ default:
+ Log4cPriority = Priority::NOTSET;
+ }
+
+ return Log4cPriority;
+}
+
+struct CatStack {
+ Category *cat;
+ CatStack *parent;
+ CatStack(Category *c, CatStack *p = NULL) : cat(c), parent(p) { }
+};
+//Category *cat = NULL;
+static CatStack *cats = NULL;
+
+// Start a new log4cpp log
+EZLOGAPI ezStartBlock(IN OPTIONAL HANDLE OldLevel,
+ OUT OPTIONAL PHANDLE NewLevel,
+ IN OPTIONAL ULONG Flags, // currently ignored
+ IN OPTIONAL ULONG LogLevel,
+ IN LPEZSTR LogString,
+ ...) {
+
+ Appender* app = new FileAppender("FileAppender", "gssmaster.log");
+ Appender* appConsole = new OstreamAppender("OstreamAppender", &(std::cout));
+
+ Layout* layout = new BasicLayout();
+ app->setLayout(layout);
+
+ static ULONG BlockCounter = 0;
+
+ char ProcessedLogString[4096];
+ va_list args;
+
+ va_start(args, LogString);
+ vsnprintf(ProcessedLogString, 4096, LogString, args);
+ va_end(args);
+
+ char LogName[24];
+ snprintf(LogName, 24, "gssMonger.%ld", BlockCounter);
+
+ Category *cat = &Category::getInstance(LogName);
+ cat->setAdditivity(true);
+ cat->setAppender(app);
+ cat->setAppender(appConsole);
+ cats = new CatStack(cat, cats);
+
+ ezLogMsg(EZLOG_BLOCK, EZ_DEFAULT, "StartBlock %p from %p(%s): %s",
+ (void *)cat,
+ OldLevel,
+ (OldLevel
+ ? ((CatStack *)OldLevel)->cat->getName().data()
+ : "?"),
+ ProcessedLogString);
+
+ cat->log(etol_priority(LogLevel),
+ ProcessedLogString);
+
+ BlockCounter++;
+
+ if (NewLevel)
+ *NewLevel = (void*)cats;
+
+ return TRUE;
+}
+
+// Log a message to the current log4cpp log
+EZLOGAPI ServerLogMessage( PPROTOCOL_CALLBACK_ARGS pArgs,
+ IN PCHAR File,
+ IN int Line,
+ IN PCHAR LogString,
+ ... ) {
+ va_list args;
+ va_start(args, LogString);
+
+ ezStartBlock( NULL, NULL, 0, 0, LogString, args);
+}
+
+// Log a message to the current log4cpp log
+EZLOGAPI vezLogMsg( IN ULONG LogLevel,
+ IN OPTIONAL HANDLE Log4cCategory,
+ IN LPEZSTR File,
+ IN ULONG Line,
+ IN LPEZSTR LogString,
+ IN va_list * ExtraArgs) {
+
+ if (cats == NULL) {
+ void* temp;
+ ezStartBlock( NULL, &temp, 0, LogLevel, "Autoinitializing log..." );
+ }
+
+ char ProcessedLogString[4096];
+ va_list * args = ExtraArgs;
+
+ if (File) {
+ const char *basename;
+ basename = strrchr(File, '/');
+ if (basename == NULL)
+ basename = File;
+ else
+ basename++;
+ snprintf(ProcessedLogString, sizeof(ProcessedLogString),
+ "%s:%lu ", basename, Line);
+ } else
+ ProcessedLogString[0] = 0;
+
+ vsnprintf(ProcessedLogString + strlen(ProcessedLogString),
+ sizeof(ProcessedLogString) - strlen(ProcessedLogString),
+ LogString, *args);
+ va_end(*args);
+
+ cats->cat->log(etol_priority(LogLevel), ProcessedLogString);
+
+ return TRUE;
+}
+
+// Log a message to the current log4cpp log
+EZLOGAPI ezLogMsg(IN ULONG LogLevel,
+ IN OPTIONAL HANDLE Log4cCategory,
+ IN LPEZSTR File,
+ IN ULONG Line,
+ IN LPEZSTR LogString, ...) {
+ va_list args;
+
+ va_start(args, LogString);
+ vezLogMsg( LogLevel, Log4cCategory, File, Line, LogString, &args );
+}
+
+// Close the specified log4cpp log
+EZLOGAPI ezFinishBlock( IN OPTIONAL HANDLE handle ) {
+ ezLogMsg(EZLOG_BLOCK, EZ_DEFAULT, "FinishBlock %p(%s)", handle,
+ (handle ? ((CatStack *)handle)->cat->getName().data() : "NULL"));
+ CatStack *c2 = cats;
+ cats = c2->parent;
+ delete c2;
+}
+
+// Close the log4cpp log
+EZLOGAPI ezCloseLog( IN OPTIONAL ULONG flags, ... ) {
+ Category::shutdown();
+}
+
+// Open the log4cpp log
+EZLOGAPI ezOpenLogEx( IN OUT PEZLOG_OPENLOG_DATA pData ) {
+ // pass
+}
+
+#ifndef WINNT
+#undef __stdcall
+#undef __cdecl
+#endif // WINNT
Property changes on: tools/gssmonger/trunk/gssmaster/ezlog_log4cpp.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the cvs-krb5
mailing list