1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5//
6// Logging Facility
7//
8
9
10// Logging Subsystems
11
12
13#ifndef __LOG_H__
14#define __LOG_H__
15
16
17#define DEFINE_LOG_FACILITY(logname, value) logname = value,
18
19enum {
20#include "loglf.h"
21 LF_ALWAYS = 0x80000000, // Log message irrepespective of LogFacility (if the level matches)
22 LF_ALL = 0xFFFFFFFF, // Used only to mask bits. Never use as LOG((LF_ALL, ...))
23
24 // LogFacility2: all 32-bit of LogFacility are used, need a 2nd DWORD for more facilities
25 LF2_MULTICOREJIT = 0x00000001 // Multicore JIT
26};
27
28
29#define LL_EVERYTHING 10
30#define LL_INFO1000000 9 // can be expected to generate 1,000,000 logs per small but not trival run
31#define LL_INFO100000 8 // can be expected to generate 100,000 logs per small but not trival run
32#define LL_INFO10000 7 // can be expected to generate 10,000 logs per small but not trival run
33#define LL_INFO1000 6 // can be expected to generate 1,000 logs per small but not trival run
34#define LL_INFO100 5 // can be expected to generate 100 logs per small but not trival run
35#define LL_INFO10 4 // can be expected to generate 10 logs per small but not trival run
36#define LL_WARNING 3
37#define LL_ERROR 2
38#define LL_FATALERROR 1
39#define LL_ALWAYS 0 // impossible to turn off (log level never negative)
40
41
42#define INFO5 LL_INFO10
43#define INFO4 LL_INFO100
44#define INFO3 LL_INFO1000
45#define INFO2 LL_INFO10000
46#define INFO1 LL_INFO100000
47#define WARNING 0
48#define ERROR 0
49#define FATALERROR 0
50
51#ifndef LOGGING
52
53#define LOG(x)
54#define LOG2(x)
55
56#define InitializeLogging()
57#define InitLogging()
58#define ShutdownLogging()
59#define FlushLogging()
60#define LoggingOn(facility, level) 0
61#define Logging2On(facility, level) 0
62#define EnterLogLock()
63#define LeaveLogLock()
64
65#else
66
67extern VOID InitializeLogging();
68extern VOID InitLogging();
69extern VOID ShutdownLogging();
70extern VOID FlushLogging();
71
72extern VOID LogSpew(DWORD facility, DWORD level, const char *fmt, ... );
73extern VOID LogSpewValist(DWORD facility, DWORD level, const char *fmt, va_list args);
74
75extern VOID LogSpew2(DWORD facility2, DWORD level, const char *fmt, ... );
76extern VOID LogSpew2Valist(DWORD facility2, DWORD level, const char *fmt, va_list args);
77
78extern VOID LogSpewAlwaysValist(const char *fmt, va_list args);
79extern VOID LogSpewAlways (const char *fmt, ... );
80extern VOID EnterLogLock();
81extern VOID LeaveLogLock();
82
83VOID AddLoggingFacility( DWORD facility );
84VOID SetLoggingLevel( DWORD level );
85bool LoggingEnabled();
86bool LoggingOn(DWORD facility, DWORD level);
87bool Logging2On(DWORD facility, DWORD level);
88
89#define LOG(x) do { if (LoggingEnabled()) { LogSpew x; } } while (0)
90
91#define LOG2(x) do { if (LoggingEnabled()) { LogSpew2 x; } } while (0)
92
93#endif
94
95#ifdef __cplusplus
96#include "stresslog.h" // special logging for retail code
97#endif
98
99#endif //__LOG_H__
100