1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 Contains: Implementation of debugging utilities. Requires a POSIX environment.
25 #include "mDNSDebug.h"
29 #if defined(WIN32) || defined(EFI32) || defined(EFI64) || defined(EFIX64)
30 // Need to add Windows/EFI syslog support here
33 #define LOG_PERROR 0x20
38 #include "mDNSEmbeddedAPI.h"
40 mDNSexport
int mDNS_LoggingEnabled
= 0;
41 mDNSexport
int mDNS_PacketLoggingEnabled
= 0;
44 mDNSexport
int mDNS_DebugMode
= mDNStrue
;
46 mDNSexport
int mDNS_DebugMode
= mDNSfalse
;
49 // Note, this uses mDNS_vsnprintf instead of standard "vsnprintf", because mDNS_vsnprintf knows
50 // how to print special data types like IP addresses and length-prefixed domain names
51 #if MDNS_DEBUGMSGS > 1
52 mDNSexport
void verbosedebugf_(const char *format
, ...)
57 buffer
[mDNS_vsnprintf(buffer
, sizeof(buffer
), format
, ptr
)] = 0;
59 mDNSPlatformWriteDebugMsg(buffer
);
63 // Log message with default "mDNSResponder" ident string at the start
64 mDNSlocal
void LogMsgWithLevelv(mDNSLogLevel_t logLevel
, const char *format
, va_list ptr
)
67 buffer
[mDNS_vsnprintf((char *)buffer
, sizeof(buffer
), format
, ptr
)] = 0;
68 mDNSPlatformWriteLogMsg(ProgramName
, buffer
, logLevel
);
71 #define LOG_HELPER_BODY(L) \
74 va_start(ptr,format); \
75 LogMsgWithLevelv(L, format, ptr); \
80 #if !MDNS_HAS_VA_ARG_MACROS
81 void LogMsg_(const char *format
, ...) LOG_HELPER_BODY(MDNS_LOG_MSG
)
82 void LogOperation_(const char *format
, ...) LOG_HELPER_BODY(MDNS_LOG_OPERATION
)
83 void LogSPS_(const char *format
, ...) LOG_HELPER_BODY(MDNS_LOG_SPS
)
84 void LogInfo_(const char *format
, ...) LOG_HELPER_BODY(MDNS_LOG_INFO
)
88 void debugf_(const char *format
, ...) LOG_HELPER_BODY(MDNS_LOG_DEBUG
)
91 // Log message with default "mDNSResponder" ident string at the start
92 mDNSexport
void LogMsgWithLevel(mDNSLogLevel_t logLevel
, const char *format
, ...)
93 LOG_HELPER_BODY(logLevel
)