Changeset 13034 in webkit for trunk/JavaScriptCore/kxmlcore/Assertions.cpp
- Timestamp:
- Feb 27, 2006, 7:51:43 PM (19 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kxmlcore/Assertions.cpp
r13027 r13034 1 1 // -*- mode: c++; c-basic-offset: 4 -*- 2 2 /* 3 * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.3 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 28 28 #include "Assertions.h" 29 29 30 #define SUPPORT_OBJC_LOGGING 1 31 32 #if SUPPORT_OBJC_LOGGING 30 #if __APPLE__ 33 31 #include <CoreFoundation/CFString.h> 34 32 #endif 35 33 36 #include <Foundation/NSString.h>37 #include <Foundation/NSUserDefaults.h>38 #include <Foundation/NSScanner.h>39 40 34 extern "C" { 41 35 36 // This is to work around the "you should use a printf format attribute" warning on GCC 37 // We can't use _attribute__ ((format (printf, 2, 3))) since we allow %@ 42 38 static int (* vfprintf_no_warning)(FILE *, const char *, va_list) = vfprintf; 43 39 44 static void vprintf_stderr_ objc(const char *format, va_list args)40 static void vprintf_stderr_common(const char *format, va_list args) 45 41 { 46 #if SUPPORT_OBJC_LOGGING42 #if __APPLE__ 47 43 if (!strstr(format, "%@")) { 48 44 CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFStringEncodingUTF8); … … 77 73 va_list args; 78 74 va_start(args, format); 79 vprintf_stderr_ objc(format, args);75 vprintf_stderr_common(format, args); 80 76 va_end(args); 81 77 fprintf(stderr, "\n%s (%s:%d %s)\n=================\n", assertion, file, line, function); … … 92 88 va_list args; 93 89 va_start(args, format); 94 vprintf_stderr_ objc(format, args);90 vprintf_stderr_common(format, args); 95 91 va_end(args); 96 92 fprintf(stderr, "\n(%s:%d %s)\n=================\n", file, line, function); … … 102 98 va_list args; 103 99 va_start(args, format); 104 vprintf_stderr_ objc(format, args);100 vprintf_stderr_common(format, args); 105 101 va_end(args); 106 102 fprintf(stderr, "\n(%s:%d %s)\n=================\n", file, line, function); 107 103 } 108 104 109 static void fprintf_objc(const char *format, ...)110 {111 va_list args;112 va_start(args, format);113 vprintf_stderr_objc(format, args);114 va_end(args);115 }116 117 118 105 void KXCLog(const char*, int, const char*, KXCLogChannel *channel, const char *format, ...) 119 { 120 if (channel->state == KXCLogChannelUninitialized) { 121 channel->state = KXCLogChannelOff; 122 NSString *logLevelString = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithCString:channel->defaultName]]; 123 if (logLevelString) { 124 unsigned logLevel; 125 if (![[NSScanner scannerWithString:logLevelString] scanHexInt:&logLevel]) { 126 fprintf_objc("unable to parse hex value for %s (%@), logging is off", channel->defaultName, logLevelString); 127 } 128 if ((logLevel & channel->mask) == channel->mask) { 129 channel->state = KXCLogChannelOn; 130 } 131 } 132 } 133 106 { 134 107 if (channel->state != KXCLogChannelOn) 135 108 return; … … 137 110 va_list args; 138 111 va_start(args, format); 139 vprintf_stderr_ objc(format, args);112 vprintf_stderr_common(format, args); 140 113 va_end(args); 141 114 if (format[strlen(format) - 1] != '\n')
Note:
See TracChangeset
for help on using the changeset viewer.