upnpframework/inc/upnppanic.h
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Panic facility for UPnP framework
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // ***************************************************
       
    20 // * How to use UPnP framework panic facility
       
    21 // * 1. define KModuleName and KComponentLogfile (at least in _DEBUG)
       
    22 // *     _LIT( KModuleName, "upnpplaybacksession");
       
    23 // *     _LIT( KComponentLogfile, "AVControlServer.txt");
       
    24 // * 2. if you like, define __UPNP_DEBUG_PANIC__
       
    25 // *     by default this is only active in debug builds
       
    26 // * 3. use the panic interface
       
    27 // *     __ASSERTD(check, line) to assert id debug builds, panic if fail
       
    28 // *     __ASSERT(check, line) to assert and panic if fail
       
    29 // *     __PANICD(line) to panic instantly in debug builds
       
    30 // *     __PANIC(line) to panic instantly
       
    31 // *     panics will use module name and line number (use __LINE__)
       
    32 // *     and create an entry to module logfile, if logging is enabled
       
    33 // ***************************************************
       
    34 
       
    35 
       
    36 #ifndef __UPNPPANIC_H__
       
    37 #define __UPNPPANIC_H__
       
    38 
       
    39 
       
    40 #include <e32std.h>
       
    41 #include "upnplogging.h"
       
    42 
       
    43 #ifdef _DEBUG
       
    44   // activate panic in debug builds
       
    45   #define __UPNP_DEBUG_PANIC__
       
    46 #endif //_DEBUG
       
    47 
       
    48 
       
    49 // define panics that work in all builds
       
    50 #define __ASSERT( check, line ) \
       
    51     if(!(check)) \
       
    52         { \
       
    53         __LOG2( "Assertion failed: %S %d", \
       
    54             &KModuleName, line ); \
       
    55         User::Panic( KModuleName, line ); \
       
    56         }
       
    57 
       
    58 #define __PANIC(line) \
       
    59     __LOG2( "Panic: %S %d", \
       
    60         &KModuleName, line ); \
       
    61     User::Panic( KModuleName, line )
       
    62 
       
    63 #ifdef __UPNP_DEBUG_PANIC__
       
    64 
       
    65     // panics that work only in debug  builds
       
    66     #define __ASSERTD( check, line ) \
       
    67         if(!(check)) \
       
    68             { \
       
    69             __LOG2( "Assertion failed: %S %d", \
       
    70                 &KModuleName, line ); \
       
    71             User::Panic( KModuleName, line ); \
       
    72             }
       
    73 
       
    74     #define __PANICD( line ) \
       
    75         __LOG2( "Panic: %S %d", \
       
    76             &KModuleName, line ); \
       
    77         User::Panic( KModuleName, line )
       
    78 
       
    79 #else // !__UPNP_DEBUG_PANIC__
       
    80 
       
    81     // these are optimized away
       
    82     #define __ASSERTD( check, line )
       
    83     #define __PANICD( line )
       
    84 
       
    85 #endif // __UPNP_DEBUG_PANIC__
       
    86 
       
    87 
       
    88 #endif // __UPNPPANIC_H__