1/* 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "config.h" 27 28#include "Logging.h" 29 30namespace WebCore { 31 32static inline void initializeWithUserDefault(WTFLogChannel& channel) 33{ 34 NSString *logLevelString = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:channel.defaultName]]; 35 if (logLevelString) { 36 unsigned logLevel; 37 if (![[NSScanner scannerWithString:logLevelString] scanHexInt:&logLevel]) 38 NSLog(@"unable to parse hex value for %s (%@), logging is off", channel.defaultName, logLevelString); 39 if ((logLevel & channel.mask) == channel.mask) 40 channel.state = WTFLogChannelOn; 41 else 42 channel.state = WTFLogChannelOff; 43 } 44} 45 46void InitializeLoggingChannelsIfNecessary() 47{ 48 static bool haveInitializedLoggingChannels = false; 49 if (haveInitializedLoggingChannels) 50 return; 51 haveInitializedLoggingChannels = true; 52 53 initializeWithUserDefault(LogNotYetImplemented); 54 initializeWithUserDefault(LogFrames); 55 initializeWithUserDefault(LogLoading); 56 initializeWithUserDefault(LogPopupBlocking); 57 initializeWithUserDefault(LogEvents); 58 initializeWithUserDefault(LogEditing); 59 initializeWithUserDefault(LogLiveConnect); 60 initializeWithUserDefault(LogIconDatabase); 61 initializeWithUserDefault(LogSQLDatabase); 62 initializeWithUserDefault(LogSpellingAndGrammar); 63 initializeWithUserDefault(LogBackForward); 64 initializeWithUserDefault(LogHistory); 65 initializeWithUserDefault(LogPageCache); 66 initializeWithUserDefault(LogPlatformLeaks); 67 initializeWithUserDefault(LogResourceLoading); 68 initializeWithUserDefault(LogNetwork); 69 initializeWithUserDefault(LogFTP); 70 initializeWithUserDefault(LogThreading); 71 initializeWithUserDefault(LogStorageAPI); 72 initializeWithUserDefault(LogMedia); 73 initializeWithUserDefault(LogPlugins); 74 initializeWithUserDefault(LogArchives); 75} 76 77} 78