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 | /*
|
---|
18 | * Based in part on Microsoft DDK sample code
|
---|
19 | *
|
---|
20 | * *******************
|
---|
21 | * * GDI SAMPLE CODE *
|
---|
22 | * *******************
|
---|
23 | *
|
---|
24 | * Module Name: debug.c
|
---|
25 | *
|
---|
26 | * debug helpers routine
|
---|
27 | *
|
---|
28 | * Copyright (c) 1992-1998 Microsoft Corporation
|
---|
29 | *
|
---|
30 | \**************************************************************************/
|
---|
31 |
|
---|
32 | #include "driver.h"
|
---|
33 |
|
---|
34 | #ifdef LOG_ENABLED
|
---|
35 |
|
---|
36 | #ifdef VBOX
|
---|
37 | #include <VBox/log.h>
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | ULONG DebugLevel = 0;
|
---|
41 |
|
---|
42 | /*****************************************************************************
|
---|
43 | *
|
---|
44 | * Routine Description:
|
---|
45 | *
|
---|
46 | * This function is variable-argument, level-sensitive debug print
|
---|
47 | * routine.
|
---|
48 | * If the specified debug level for the print statement is lower or equal
|
---|
49 | * to the current debug level, the message will be printed.
|
---|
50 | *
|
---|
51 | * Arguments:
|
---|
52 | *
|
---|
53 | * DebugPrintLevel - Specifies at which debugging level the string should
|
---|
54 | * be printed
|
---|
55 | *
|
---|
56 | * DebugMessage - Variable argument ascii c string
|
---|
57 | *
|
---|
58 | * Return Value:
|
---|
59 | *
|
---|
60 | * None.
|
---|
61 | *
|
---|
62 | ***************************************************************************/
|
---|
63 |
|
---|
64 | VOID
|
---|
65 | DebugPrint(
|
---|
66 | ULONG DebugPrintLevel,
|
---|
67 | PCHAR DebugMessage,
|
---|
68 | ...
|
---|
69 | )
|
---|
70 |
|
---|
71 | {
|
---|
72 |
|
---|
73 | va_list ap;
|
---|
74 |
|
---|
75 | va_start(ap, DebugMessage);
|
---|
76 |
|
---|
77 | #ifdef VBOX
|
---|
78 | RTLogBackdoorPrintfV(DebugMessage, ap);
|
---|
79 | #else
|
---|
80 | if (DebugPrintLevel <= DebugLevel)
|
---|
81 | {
|
---|
82 | EngDebugPrint(STANDARD_DEBUG_PREFIX, DebugMessage, ap);
|
---|
83 | }
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | va_end(ap);
|
---|
87 |
|
---|
88 | }
|
---|
89 |
|
---|
90 | #endif
|
---|
91 |
|
---|
92 | ULONG __cdecl DbgPrint(PCH pszFormat, ...)
|
---|
93 | {
|
---|
94 | #ifdef LOG_ENABLED
|
---|
95 | va_list args;
|
---|
96 | va_start(args, pszFormat);
|
---|
97 | # ifdef VBOX
|
---|
98 | RTLogBackdoorPrintfV(pszFormat, args);
|
---|
99 | # else
|
---|
100 | EngDebugPrint(STANDARD_DEBUG_PREFIX, pszFormat, args);
|
---|
101 | # endif
|
---|
102 | va_end(args);
|
---|
103 | #endif
|
---|
104 | return 0;
|
---|
105 | }
|
---|
106 |
|
---|