1 | /******************************Module*Header*******************************\
|
---|
2 | *
|
---|
3 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
4 | *
|
---|
5 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
6 | * available from http://www.virtualbox.org. This file is free software;
|
---|
7 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
8 | * General Public License (GPL) as published by the Free Software
|
---|
9 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
10 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
11 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
12 | *
|
---|
13 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
14 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
15 | * additional information or have any questions.
|
---|
16 | *
|
---|
17 | * Based in part on Microsoft DDK sample code
|
---|
18 | *
|
---|
19 | * *******************
|
---|
20 | * * GDI SAMPLE CODE *
|
---|
21 | * *******************
|
---|
22 | *
|
---|
23 | * Module Name: debug.c
|
---|
24 | *
|
---|
25 | * debug helpers routine
|
---|
26 | *
|
---|
27 | * Copyright (c) 1992-1998 Microsoft Corporation
|
---|
28 | *
|
---|
29 | \**************************************************************************/
|
---|
30 |
|
---|
31 | #include "driver.h"
|
---|
32 |
|
---|
33 | #ifdef LOG_ENABLED
|
---|
34 |
|
---|
35 | #ifdef VBOX
|
---|
36 | #include <VBox/log.h>
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | ULONG DebugLevel = 0;
|
---|
40 |
|
---|
41 | /*****************************************************************************
|
---|
42 | *
|
---|
43 | * Routine Description:
|
---|
44 | *
|
---|
45 | * This function is variable-argument, level-sensitive debug print
|
---|
46 | * routine.
|
---|
47 | * If the specified debug level for the print statement is lower or equal
|
---|
48 | * to the current debug level, the message will be printed.
|
---|
49 | *
|
---|
50 | * Arguments:
|
---|
51 | *
|
---|
52 | * DebugPrintLevel - Specifies at which debugging level the string should
|
---|
53 | * be printed
|
---|
54 | *
|
---|
55 | * DebugMessage - Variable argument ascii c string
|
---|
56 | *
|
---|
57 | * Return Value:
|
---|
58 | *
|
---|
59 | * None.
|
---|
60 | *
|
---|
61 | ***************************************************************************/
|
---|
62 |
|
---|
63 | VOID
|
---|
64 | DebugPrint(
|
---|
65 | ULONG DebugPrintLevel,
|
---|
66 | PCHAR DebugMessage,
|
---|
67 | ...
|
---|
68 | )
|
---|
69 |
|
---|
70 | {
|
---|
71 |
|
---|
72 | va_list ap;
|
---|
73 |
|
---|
74 | va_start(ap, DebugMessage);
|
---|
75 |
|
---|
76 | #ifdef VBOX
|
---|
77 | RTLogBackdoorPrintfV(DebugMessage, ap);
|
---|
78 | #else
|
---|
79 | if (DebugPrintLevel <= DebugLevel)
|
---|
80 | {
|
---|
81 | EngDebugPrint(STANDARD_DEBUG_PREFIX, DebugMessage, ap);
|
---|
82 | }
|
---|
83 | #endif
|
---|
84 |
|
---|
85 | va_end(ap);
|
---|
86 |
|
---|
87 | }
|
---|
88 |
|
---|
89 | #endif
|
---|
90 |
|
---|
91 | ULONG __cdecl DbgPrint(PCH pszFormat, ...)
|
---|
92 | {
|
---|
93 | #ifdef LOG_ENABLED
|
---|
94 | va_list args;
|
---|
95 | va_start(args, pszFormat);
|
---|
96 | # ifdef VBOX
|
---|
97 | RTLogBackdoorPrintfV(pszFormat, args);
|
---|
98 | # else
|
---|
99 | EngDebugPrint(STANDARD_DEBUG_PREFIX, pszFormat, args);
|
---|
100 | # endif
|
---|
101 | va_end(args);
|
---|
102 | #endif
|
---|
103 | return 0;
|
---|
104 | }
|
---|
105 |
|
---|