root/experimental/NT-based/NTSpecific/AssertToNTLog.hpp

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /******************************************************************************
   2 ** $Header: svn+ssh://jmmcg@svn.code.sf.net/p/libjmmcg/code/trunk/libjmmcg/experimental/NT-based/NTSpecific/AssertToNTLog.hpp 2055 2017-05-13 19:35:47Z jmmcg $
   3 ** 
   4 ** Copyright (C) 2002 by J.M.McGuiness, coder@hussar.me.uk
   5 **
   6 ** This library is free software; you can redistribute it and/or
   7 ** modify it under the terms of the GNU Lesser General Public
   8 ** License as published by the Free Software Foundation; either
   9 ** version 2.1 of the License, or (at your option) any later version.
  10 **
  11 ** This library is distributed in the hope that it will be useful,
  12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14 ** Lesser General Public License for more details.
  15 **
  16 ** You should have received a copy of the GNU Lesser General Public
  17 ** License along with this library; if not, write to the Free Software
  18 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19 */
  20 
  21 #pragma once
  22 
  23 #include<cassert>
  24 
  25 /*
  26         NOTE: All of this functionality is enabled ONLY in debug mode, i.e. if
  27         "_DEBUG" is defined.
  28         Handy for using in NT Services that don't have a user interface - send the
  29         assertion to the NT Event Log.
  30         Automatically logs the file and line number. Also the calling thread handle.
  31         (Which is handy when multi-thread/process debugging!)
  32         Include this file instead of <cassert> or <assert.h> if you want to log all
  33         "assert(...)" expressions to the NT Event Log. (But only if you define the
  34         macro constant "ASSERTIONS_TO_NT_LOG".)
  35         Use "assert(...)" if you don't have an "EventLog" object in scope, otherwise
  36         you can use "AssertLog(...)" instead which will make use of your provided
  37         EventLog object.
  38 */
  39 
  40 #ifdef _DEBUG
  41 
  42         namespace jmmcg {
  43 
  44                 namespace NTUtils {
  45                         
  46                         inline AFX_EXT_CLASS void __fastcall assertlog(const char *exp, const char *file_name, const unsigned long line);
  47 
  48                 }
  49         }
  50 
  51 #       define AssertLog(exp) (void)( (exp) || (jmmcg::NTUtils::assertlog(#exp, __FILE__, __LINE__), 0) )
  52 #       ifdef JMMCG_ASSERTIONS_TO_NT_LOG
  53 #               ifdef assert
  54 #                       undef assert
  55 #               endif assert
  56 #               define assert(exp) AssertLog(exp)
  57 #       endif JMMCG_ASSERTIONS_TO_NT_LOG
  58 
  59 #else
  60 #       define AssertLog(assertion) ((void)0)
  61 #endif _DEBUG

/* [<][>][^][v][top][bottom][index][help] */