more-rx-updates-20060504
[openafs.git] / src / WINNT / afsadmsvr / TaAfsAdmSvrDebug.cpp
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #include <winsock2.h>
11 #include <ws2tcpip.h>
12
13 extern "C" {
14 #include <afs/param.h>
15 #include <afs/stds.h>
16 }
17
18 #include "TaAfsAdmSvrInternal.h"
19
20
21 /*
22  * VARIABLES __________________________________________________________________
23  *
24  */
25
26 static DWORD PrintDetailLevel = dlDEFAULT;
27
28
29 /*
30  * ROUTINES ___________________________________________________________________
31  *
32  */
33
34 void cdecl vPrint (DWORD level, LPTSTR pszLine, va_list arg)
35 {
36    static LPCRITICAL_SECTION pcs = NULL;
37    if (!pcs)
38       {
39       pcs = New (CRITICAL_SECTION);
40       InitializeCriticalSection (pcs);
41       }
42
43    EnterCriticalSection (pcs);
44
45    if ((!level) || (PrintDetailLevel & level))
46       {
47       TCHAR szOut[ 1024 ];
48       wvsprintf (szOut, pszLine, arg);
49       printf ("AdmSvr: ");
50       if (!level)
51          printf (" * ");
52       if (level & dlINDENT1)
53          printf ("   ");
54       if (level & dlINDENT2)
55          printf ("      ");
56       printf ("%s\n", szOut);
57       }
58
59    LeaveCriticalSection (pcs);
60 }
61
62
63 void cdecl Print (LPTSTR pszLine, ...)
64 {
65    va_list arg;
66    va_start (arg, pszLine);
67    vPrint (dlSTANDARD, pszLine, arg);
68 }
69
70
71 void cdecl Print (DWORD level, LPTSTR pszLine, ...)
72 {
73    va_list arg;
74    va_start (arg, pszLine);
75    vPrint (level, pszLine, arg);
76 }
77
78
79 DWORD GetPrintDetailLevel (void)
80 {
81    return PrintDetailLevel;
82 }
83
84
85 void SetPrintDetailLevel (DWORD level)
86 {
87    PrintDetailLevel = level;
88 }
89