diff --git a/Code/Support/lcl_config_logger.h b/Code/Support/lcl_config_logger.h index 44eabdcc6c..4c83f49070 100644 --- a/Code/Support/lcl_config_logger.h +++ b/Code/Support/lcl_config_logger.h @@ -20,3 +20,4 @@ // NSLog #import "LCLNSLog.h" +#import "LCLLogFile.h" diff --git a/RestKit.podspec b/RestKit.podspec new file mode 100644 index 0000000000..b0fc722bc6 --- /dev/null +++ b/RestKit.podspec @@ -0,0 +1,82 @@ +Pod::Spec.new do |s| + s.name = 'RestKit' + s.version = '0.10.5' + s.summary = 'RestKit is a framework for consuming and modeling RESTful web resources on iOS and OS X.' + s.homepage = 'http://www.restkit.org' + s.author = { 'Blake Watters' => 'blakewatters@gmail.com' } + s.source = { :git => 'https://github.com/timehop/RestKit.git', :tag => '0.10.5' } + s.license = 'Apache License, Version 2.0' + + s.source_files = 'Code/RestKit.h' + + ### Preferred dependencies + + s.preferred_dependency = 'JSON' + + s.subspec 'JSON' do |js| + js.dependency 'RestKit/Network' + js.dependency 'RestKit/ObjectMapping/JSON' + js.dependency 'RestKit/ObjectMapping/CoreData' + js.dependency 'RestKit/ObjectMapping' + js.dependency 'RestKit/UI' + end + + s.subspec 'XML' do |xs| + xs.dependency 'RestKit/Network' + xs.dependency 'RestKit/ObjectMapping/XML' + xs.dependency 'RestKit/ObjectMapping/CoreData' + xs.dependency 'RestKit/UI' + end + + ### Subspecs + + s.subspec 'Network' do |ns| + ns.source_files = 'Code/Network', 'Code/Support', 'Vendor/LibComponentLogging', 'Vendor/LibComponentLogging/NSLog', 'Vendor/LibComponentLogging/Core' + ns.ios.frameworks = 'CFNetwork', 'Security', 'MobileCoreServices', 'SystemConfiguration' + ns.osx.frameworks = 'CoreServices', 'Security', 'SystemConfiguration' + ns.dependency 'cocoa-oauth' + ns.dependency 'FileMD5Hash' + ns.dependency 'SOCKit' + end + + s.subspec 'UI' do |us| + us.ios.source_files = 'Code/UI' + us.ios.framework = 'QuartzCore' + #us.ios.dependency 'UDTableView' + + us.osx.source_files = 'Code/UI/UIImage+RKAdditions.{h,m}' + end + + s.subspec 'ObjectMapping' do |os| + os.dependency 'ISO8601DateFormatter', '>= 0.6' + os.dependency 'RestKit/Network' + + + os.subspec 'Core' do |cos| + cos.source_files = 'Code/ObjectMapping/' + end + + os.subspec 'JSON' do |jos| + jos.source_files = 'Code/Support/Parsers/JSON/RKJSONParserJSONKit.{h,m}' + jos.dependency 'JSONKit', '>= 1.5pre' + jos.dependency 'RestKit/ObjectMapping/Core' + end + + os.subspec 'XML' do |xos| + xos.source_files = 'Code/Support/Parsers/XML/RKXMLParserXMLReader.{h,m}' + xos.libraries = 'xml2' + xos.dependency 'XMLReader' + xos.dependency 'RestKit/ObjectMapping/Core' + end + + os.subspec 'CoreData' do |cdos| + cdos.source_files = 'Code/CoreData' + cdos.frameworks = 'CoreData' + cdos.dependency 'RestKit/ObjectMapping/Core' + end + end + + s.subspec 'Testing' do |ts| + ts.source_files = 'Code/Testing' + end +end \ No newline at end of file diff --git a/RestKit.xcodeproj/project.pbxproj b/RestKit.xcodeproj/project.pbxproj index be393f4311..6f63e966b7 100644 --- a/RestKit.xcodeproj/project.pbxproj +++ b/RestKit.xcodeproj/project.pbxproj @@ -7,6 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 204C3B831830737600069F56 /* LCLLogFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 204C3B801830737600069F56 /* LCLLogFile.h */; }; + 204C3B841830737600069F56 /* LCLLogFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 204C3B811830737600069F56 /* LCLLogFile.m */; }; + 204C3B851830737600069F56 /* LCLLogFileConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 204C3B821830737600069F56 /* LCLLogFileConfig.h */; }; 2501405315366000004E0466 /* RKObjectiveCppTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2501405215366000004E0466 /* RKObjectiveCppTest.mm */; }; 2501405415366000004E0466 /* RKObjectiveCppTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2501405215366000004E0466 /* RKObjectiveCppTest.mm */; }; 25055B8414EEF32A00B9C4DD /* RKMappingTest.h in Headers */ = {isa = PBXBuildFile; fileRef = 25055B8014EEF32A00B9C4DD /* RKMappingTest.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -775,6 +778,9 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 204C3B801830737600069F56 /* LCLLogFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCLLogFile.h; sourceTree = ""; }; + 204C3B811830737600069F56 /* LCLLogFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LCLLogFile.m; sourceTree = ""; }; + 204C3B821830737600069F56 /* LCLLogFileConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCLLogFileConfig.h; sourceTree = ""; }; 2501405215366000004E0466 /* RKObjectiveCppTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RKObjectiveCppTest.mm; sourceTree = ""; }; 25055B8014EEF32A00B9C4DD /* RKMappingTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RKMappingTest.h; path = Testing/RKMappingTest.h; sourceTree = ""; }; 25055B8114EEF32A00B9C4DD /* RKMappingTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RKMappingTest.m; path = Testing/RKMappingTest.m; sourceTree = ""; }; @@ -1293,6 +1299,16 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 204C3B861830737B00069F56 /* LogFile */ = { + isa = PBXGroup; + children = ( + 204C3B801830737600069F56 /* LCLLogFile.h */, + 204C3B811830737600069F56 /* LCLLogFile.m */, + 204C3B821830737600069F56 /* LCLLogFileConfig.h */, + ); + name = LogFile; + sourceTree = ""; + }; 250CA67A147D8E7F0047D347 /* OCHamcrest */ = { isa = PBXGroup; children = ( @@ -1651,6 +1667,7 @@ children = ( 25160EA11456532C0060A5C5 /* Core */, 25160EAE1456532C0060A5C5 /* NSLog */, + 204C3B861830737B00069F56 /* LogFile */, ); path = LibComponentLogging; sourceTree = ""; @@ -2180,6 +2197,7 @@ 25160E1A145650490060A5C5 /* RKObjectMapping.h in Headers */, 25160E1C145650490060A5C5 /* RKObjectMappingDefinition.h in Headers */, 25160E1D145650490060A5C5 /* RKObjectMappingOperation.h in Headers */, + 204C3B831830737600069F56 /* LCLLogFile.h in Headers */, 25160E1F145650490060A5C5 /* RKObjectMappingProvider.h in Headers */, 25160E21145650490060A5C5 /* RKObjectMappingResult.h in Headers */, 25160E23145650490060A5C5 /* RKObjectPropertyInspector.h in Headers */, @@ -2221,6 +2239,7 @@ 25B408261491CDDC00F21111 /* RKDirectory.h in Headers */, 2513504E14B8FE6B00A7E893 /* RKConfigurationDelegate.h in Headers */, 250DF22A14C5190E0001DEFA /* RKOrderedDictionary.h in Headers */, + 204C3B851830737600069F56 /* LCLLogFileConfig.h in Headers */, 49D2759D14C9EF1E0090845D /* ISO8601DateFormatter.h in Headers */, 49A66B0C14CEFB0400A6F062 /* XMLReader.h in Headers */, 250DF25F14C680F90001DEFA /* RKObjectMappingProvider+Contexts.h in Headers */, @@ -2732,6 +2751,7 @@ 25160E1B145650490060A5C5 /* RKObjectMapping.m in Sources */, 25160E1E145650490060A5C5 /* RKObjectMappingOperation.m in Sources */, 25160E20145650490060A5C5 /* RKObjectMappingProvider.m in Sources */, + 204C3B841830737600069F56 /* LCLLogFile.m in Sources */, 25160E22145650490060A5C5 /* RKObjectMappingResult.m in Sources */, 25160E24145650490060A5C5 /* RKObjectPropertyInspector.m in Sources */, 25160E26145650490060A5C5 /* RKObjectRelationshipMapping.m in Sources */, diff --git a/Vendor/LibComponentLogging/LCLLogFile.h b/Vendor/LibComponentLogging/LCLLogFile.h new file mode 100755 index 0000000000..fddf618b3b --- /dev/null +++ b/Vendor/LibComponentLogging/LCLLogFile.h @@ -0,0 +1,304 @@ +// +// +// LCLLogFile.h +// +// +// Copyright (c) 2008-2013 Arne Harren +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#define _LCLLOGFILE_VERSION_MAJOR 1 +#define _LCLLOGFILE_VERSION_MINOR 2 +#define _LCLLOGFILE_VERSION_BUILD 3 +#define _LCLLOGFILE_VERSION_SUFFIX "" + +// +// LCLLogFile +// +// LCLLogFile is a logging back-end implementation which writes log messages to +// an application-specific log file. LCLLogFile can be used as a logging +// back-end for LibComponentLogging, but it is also useable as a standalone +// logging class without the Core files of LibComponentLogging. +// +// The log file is opened automatically when the first log message needs to be +// written to the log file. There is no need to call open, close, reset, etc. +// manually. +// +// The log file gets rotated if a given maximum file size is reached. +// +// LCLLogFile is configured via the following #defines in LCLLogFileConfig.h +// (see #import below): +// +// - Full path of the log file (type NSString *) +// #define _LCLLogFile_LogFilePath +// +// - Append to an existing log file on startup? (type BOOL) +// #define _LCLLogFile_AppendToExistingLogFile +// +// - Maximum size of the log file in bytes (type size_t) +// #define _LCLLogFile_MaxLogFileSizeInBytes +// +// - Mirror log messages to stderr? (type BOOL) +// #define _LCLLogFile_MirrorMessagesToStdErr +// +// - Escape ('\\' and) '\n' line feed characters in log messages (type BOOL) +// #define _LCLLogFile_EscapeLineFeeds +// +// - Maximum size of a log message in characters (type NSUInteger) +// #define _LCLLogFile_MaxMessageSizeInCharacters +// +// - Show file names in the log messages? (type BOOL) +// #define _LCLLogFile_ShowFileNames +// +// - Show line numbers in the log messages? (type BOOL) +// #define _LCLLogFile_ShowLineNumbers +// +// - Show function names in the log messages? (type BOOL) +// #define _LCLLogFile_ShowFunctionNames +// +// +// When using LCLLogFile as a back-end for LibComponentLogging, simply add an +// #import "LCLLogFile.h" +// statement to your lcl_config_logger.h file and use the LCLLogFileConfig.h +// file for detailed configuration of the LCLLogFile class. +// + + +#import +#import "LCLLogFileConfig.h" + + +@interface LCLLogFile : NSObject { + +} + + +// +// Logging methods. +// + + +// Writes the given log message to the log file. ++ (void)logWithIdentifier:(const char *)identifier level:(uint32_t)level + path:(const char *)path line:(uint32_t)line + function:(const char *)function + message:(NSString *)message; + +// Writes the given log message to the log file (format and va_list var args). ++ (void)logWithIdentifier:(const char *)identifier level:(uint32_t)level + path:(const char *)path line:(uint32_t)line + function:(const char *)function + format:(NSString *)format args:(va_list)args; + +// Writes the given log message to the log file (format and ... var args). ++ (void)logWithIdentifier:(const char *)identifier level:(uint32_t)level + path:(const char *)path line:(uint32_t)line + function:(const char *)function + format:(NSString *)format, ... __attribute__((format(__NSString__, 6, 7))); + + +// +// Configuration. +// + + +// Returns/sets the path of the log file. Setting the path implies a reset. ++ (NSString *)path; ++ (void)setPath:(NSString *)path; + +// Returns the path of the backup log file. ++ (NSString *)path0; + +// Returns/sets whether log messages get appended to an existing log file on +// startup. ++ (BOOL)appendsToExistingLogFile; ++ (void)setAppendsToExistingLogFile:(BOOL)value; + +// Returns/sets the maximum size of the log file (as defined by +// _LCLLogFile_MaxLogFileSizeInBytes). ++ (size_t)maxSize; ++ (void)setMaxSize:(size_t)value; + +// Returns/sets whether log messages are mirrored to stderr. ++ (BOOL)mirrorsToStdErr; ++ (void)setMirrorsToStdErr:(BOOL)value; + +// Returns/sets whether ('\\' and) '\n' line feed characters are escaped in +// log messages. ++ (BOOL)escapesLineFeeds; ++ (void)setEscapesLineFeeds:(BOOL)value; + +// Returns/sets the maximum size of a log message in characters (without +// prefixes). The value 0 indicates that there is no maximum size for log +// messages. ++ (NSUInteger)maxMessageSize; ++ (void)setMaxMessageSize:(NSUInteger)value; + +// Returns/sets whether file names are shown. ++ (BOOL)showsFileNames; ++ (void)setShowsFileNames:(BOOL)value; + +// Returns/sets whether line numbers are shown. ++ (BOOL)showsLineNumbers; ++ (void)setShowsLineNumbers:(BOOL)value; + +// Returns/sets whether function names are shown. ++ (BOOL)showsFunctionNames; ++ (void)setShowsFunctionNames:(BOOL)value; + + +// +// Status information and internals. +// + + +// Returns the current size of the log file. ++ (size_t)size; + +// Opens the log file. ++ (void)open; + +// Closes the log file. ++ (void)close; + +// Resets the log file. This also deletes the existing log file. ++ (void)reset; + +// Rotates the log file. ++ (void)rotate; + + +// +// Methods for creating log file paths. +// + + +// Returns a default path for a log file which is based on the Info.plist +// files which are associated with this class. The returned path has the form +// ~/Library/Logs/
/.log +// where +//
is the name (or identifier) of the application's main bundle, and +// is the name (or identifier) of the bundle to which this LCLLogFile +// class belongs. +// This method is a convenience method which calls defaultPathWithPathPrefix +// with the prefix ~/Library/Logs and the given fallback path. ++ (NSString *)defaultPathInHomeLibraryLogsOrPath:(NSString *)path; + +// Returns a default path for a log file which is based on the Info.plist +// files which are associated with this class. The returned path has the form +// /
/.log +// where +// is the given path prefix, +//
is the name (or identifier) of the application's main bundle, and +// is the name (or identifier) of the bundle to which this LCLLogFile +// class belongs. +// If the name or identifier cannot be retrieved from the main bundle, the +// returned default path has the form +// //..log +// where +// is the current process id. +// If the name or identifier cannot be retrieved from the bundle which +// corresponds to this LCLLogFile class, or if the given path prefix is +// nil, the given fallback path is returned. ++ (NSString *)defaultPathWithPathPrefix:(NSString *)pathPrefix + orPath:(NSString *)path; + +// Returns a default path component for a log file which is based on the given +// bundles' Info.plist files. The returned path has the form +// /.log +// where +// is the name (or identifier) of the given path bundle, and +// is the name (or identifier) of the given file bundle. +// If the name or identifier cannot be retrieved from the path bundle, the +// returned default path has the form +// /..log +// where +// is the current process id. +// If the name or identifier cannot be retrieved from the file bundle, the +// given fallback path component is returned. ++ (NSString *)defaultPathComponentFromPathBundle:(NSBundle *)pathBundle + fileBundle:(NSBundle *)fileBundle + orPathComponent:(NSString *)pathComponent; + +// Returns the name from the given bundle's Info.plist file. If the name doesn't +// exist, the bundle's identifier is returned. If the identifier doesn't exist, +// the given fallback string is returned. ++ (NSString *)nameOrIdentifierFromBundle:(NSBundle *)bundle + orString:(NSString *)string; + + +@end + + +// +// Integration with LibComponentLogging Core. +// + + +// ARC/non-ARC autorelease pool +#define _lcl_logger_autoreleasepool_arc 0 +#if defined(__has_feature) +# if __has_feature(objc_arc) +# undef _lcl_logger_autoreleasepool_arc +# define _lcl_logger_autoreleasepool_arc 1 +# endif +#endif +#if _lcl_logger_autoreleasepool_arc +# define _lcl_logger_autoreleasepool_begin \ + @autoreleasepool { +# define _lcl_logger_autoreleasepool_end \ + } +#else +# define _lcl_logger_autoreleasepool_begin \ + NSAutoreleasePool *_lcl_logger_autoreleasepool = [[NSAutoreleasePool alloc] init]; +# define _lcl_logger_autoreleasepool_end \ + [_lcl_logger_autoreleasepool release]; +#endif + +#ifndef _LCL_NO_IGNORE_WARNINGS +# ifdef __clang__ + // Ignore some warnings about variadic macros when using '-Weverything'. +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunknown-pragmas" +# pragma clang diagnostic ignored "-Wvariadic-macros" +# pragma clang diagnostic ignored "-Wpedantic" +# endif +#endif + +// Define the _lcl_logger macro which integrates LCLLogFile as a logging +// back-end for LibComponentLogging and pass the header of a log component as +// the identifier to LCLLogFile's log method. +#define _lcl_logger(_component, _level, _format, ...) { \ + _lcl_logger_autoreleasepool_begin \ + [LCLLogFile logWithIdentifier:_lcl_component_header[_component] \ + level:_level \ + path:__FILE__ \ + line:__LINE__ \ + function:__PRETTY_FUNCTION__ \ + format:_format, \ + ## __VA_ARGS__]; \ + _lcl_logger_autoreleasepool_end \ +} + +#ifndef _LCL_NO_IGNORE_WARNINGS +# ifdef __clang__ +# pragma clang diagnostic pop +# endif +#endif + diff --git a/Vendor/LibComponentLogging/LCLLogFile.m b/Vendor/LibComponentLogging/LCLLogFile.m new file mode 100755 index 0000000000..a9f4d16dd2 --- /dev/null +++ b/Vendor/LibComponentLogging/LCLLogFile.m @@ -0,0 +1,925 @@ +// +// +// LCLLogFile.m +// +// +// Copyright (c) 2008-2013 Arne Harren +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "LCLLogFile.h" + +#include +#include +#include +#include + + +// +// Configuration checks. +// + + +#ifndef LCLLogFile +#error 'LCLLogFile' must be defined in LCLLogFileConfig.h +#endif + +#ifndef _LCLLogFile_LogFilePath +#error '_LCLLogFile_LogFilePath' must be defined in LCLLogFileConfig.h +#endif + +#ifndef _LCLLogFile_AppendToExistingLogFile +#error '_LCLLogFile_AppendToExistingLogFile' must be defined in LCLLogFileConfig.h +#endif + +#ifndef _LCLLogFile_MaxLogFileSizeInBytes +#error '_LCLLogFile_MaxLogFileSizeInBytes' must be defined in LCLLogFileConfig.h +#endif + +#ifndef _LCLLogFile_MirrorMessagesToStdErr +#error '_LCLLogFile_MirrorMessagesToStdErr' must be defined in LCLLogFileConfig.h +#endif + +#ifndef _LCLLogFile_EscapeLineFeeds +#error '_LCLLogFile_EscapeLineFeeds' must be defined in LCLLogFileConfig.h +#endif + +#ifndef _LCLLogFile_MaxMessageSizeInCharacters +#error '_LCLLogFile_MaxMessageSizeInCharacters' must be defined in LCLLogFileConfig.h +#endif + +#ifndef _LCLLogFile_ShowFileNames +#error '_LCLLogFile_ShowFileNames' must be defined in LCLLogFileConfig.h +#endif + +#ifndef _LCLLogFile_ShowLineNumbers +#error '_LCLLogFile_ShowLineNumbers' must be defined in LCLLogFileConfig.h +#endif + +#ifndef _LCLLogFile_ShowFunctionNames +#error '_LCLLogFile_ShowFunctionNames' must be defined in LCLLogFileConfig.h +#endif + + +// +// Fields. +// + + +// A lock which is held when the log file is used, opened, etc. +static NSRecursiveLock *_LCLLogFile_lock = nil; + +// A handle to the current log file, if opened. +static volatile FILE *_LCLLogFile_fileHandle = NULL; + +// YES, if logging is active. +static volatile BOOL _LCLLogFile_isActive = NO; + +// YES, if log messages should be appended to an existing log file. +static BOOL _LCLLogFile_appendToExistingLogFile = NO; + +// YES, if log messages should be mirrored to stderr. +static BOOL _LCLLogFile_mirrorToStdErr = NO; + +// YES, if '\\' and '\n' characters should be escaped in log messages. +static BOOL _LCLLogFile_escapeLineFeeds = NO; + +// YES, if the file name should be shown. +static BOOL _LCLLogFile_showFileName = NO; + +// YES, if the line number should be shown. +static BOOL _LCLLogFile_showLineNumber = NO; + +// YES, if the function name should be shown. +static BOOL _LCLLogFile_showFunctionName = NO; + +// Max size of a log message (without prefixes). +static NSUInteger _LCLLogFile_maxMessageSize = 0; + +// Max size of log file. +static size_t _LCLLogFile_fileSizeMax = 0; + +// Current size of log file. +static size_t _LCLLogFile_fileSize = 0; + +// Paths of log files. +static NSString *_LCLLogFile_filePath = nil; +static char *_LCLLogFile_filePath_c = NULL; +static NSString *_LCLLogFile_filePath0 = nil; +static char *_LCLLogFile_filePath0_c = NULL; + +// The process id. +static pid_t _LCLLogFile_processId = 0; + +// The log level headers we use. +static const char * const _LCLLogFile_levelHeader[] = { + "-", + "C", + "E", + "W", + "I", + "D", + "T" +}; + + +// __has_feature for non-clang compilers +#if !defined(__has_feature) +#define __has_feature(_feature) 0 +#endif + + +// ARC defines for non-ARC builds +#if !__has_feature(objc_arc) +#ifndef __bridge +#define __bridge +#endif +#endif + + +// ARC/non-ARC autorelease pool +#if __has_feature(objc_arc) +#define _LCLLogFile_autoreleasepool_begin \ + @autoreleasepool { +#define _LCLLogFile_autoreleasepool_end \ + } +#else +#define _LCLLogFile_autoreleasepool_begin \ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; +#define _LCLLogFile_autoreleasepool_end \ + [pool release]; +#endif + + +#if __has_feature(objc_arc) +#define _LCLLogFile_var_release(_var) \ + if (_var != nil) { \ + _var = nil; \ + } +#else +#define _LCLLogFile_var_release(_var) \ + if (_var != nil) { \ + [_var release]; \ + _var = nil; \ + } +#endif + +#define _LCLLogFile_var_free(_var) \ + if (_var != NULL) { \ + free(_var); \ + _var = NULL; \ + } \ + + +@implementation LCLLogFile + + +// +// File path. +// + + +static void _LCLLogFile_setLogFilePath(NSString *path) { + // release old path + _LCLLogFile_var_release(_LCLLogFile_filePath); + _LCLLogFile_var_free(_LCLLogFile_filePath_c); + + // release old backup path + _LCLLogFile_var_release(_LCLLogFile_filePath0); + _LCLLogFile_var_free(_LCLLogFile_filePath0_c); + + if (path != nil) { + // standardize the given path + path = [path stringByStandardizingPath]; + + // create parent paths + NSString *parentpath = [path stringByDeletingLastPathComponent]; + [[NSFileManager defaultManager] createDirectoryAtPath:parentpath + withIntermediateDirectories:YES + attributes:nil + error:NULL]; + + // create the path of the backup file + NSString *path0 = [path stringByAppendingString:@".0"]; + + // create the paths' file system representations + CFIndex path_c_max_len = CFStringGetMaximumSizeOfFileSystemRepresentation((__bridge CFStringRef)path); + CFIndex path0_c_max_len = CFStringGetMaximumSizeOfFileSystemRepresentation((__bridge CFStringRef)path0); + + char *path_c = malloc(path_c_max_len); + char *path0_c = malloc(path0_c_max_len); + + if (path_c != NULL && path0_c != NULL) { + Boolean path_fsr_created = CFStringGetFileSystemRepresentation((__bridge CFStringRef)path, path_c, path_c_max_len); + Boolean path0_fsr_created = CFStringGetFileSystemRepresentation((__bridge CFStringRef)path0, path0_c, path0_c_max_len); + + // create local copies of the paths + if (path_fsr_created && path0_fsr_created) { + _LCLLogFile_filePath = [path copy]; + _LCLLogFile_filePath_c = strdup(path_c); + _LCLLogFile_filePath0 = [path0 copy]; + _LCLLogFile_filePath0_c = strdup(path0_c); + } + } + + _LCLLogFile_var_free(path_c); + _LCLLogFile_var_free(path0_c); + } + + // creation of paths failed? clean up and fall back to stderr + if (_LCLLogFile_filePath_c == NULL || _LCLLogFile_filePath0_c == NULL) { + NSLog(@"error: invalid log file path '%@'", path); + + // fall back to stderr + _LCLLogFile_mirrorToStdErr = YES; + + // release path + _LCLLogFile_var_release(_LCLLogFile_filePath); + _LCLLogFile_var_free(_LCLLogFile_filePath_c); + + // release backup path + _LCLLogFile_var_release(_LCLLogFile_filePath0); + _LCLLogFile_var_free(_LCLLogFile_filePath0_c); + } +} + + +// +// Initialization. +// + + +// No instances, please. ++(id)alloc { + [LCLLogFile doesNotRecognizeSelector:_cmd]; + return nil; +} + +// Initializes the class. ++ (void)initialize { + // perform initialization only once + if (self != [LCLLogFile class]) + return; + + _LCLLogFile_autoreleasepool_begin + + // create the lock + _LCLLogFile_lock = [[NSRecursiveLock alloc] init]; + + // get the process id + _LCLLogFile_processId = getpid(); + + // get the max file size, at least 4k + _LCLLogFile_fileSizeMax = (_LCLLogFile_MaxLogFileSizeInBytes); + if (_LCLLogFile_fileSizeMax < 4 * 1024) { + _LCLLogFile_fileSizeMax = 4 * 1024; + } + + // get whether we should append to an existing log file + _LCLLogFile_appendToExistingLogFile = (_LCLLogFile_AppendToExistingLogFile); + + // get whether we should mirror log messages to stderr + _LCLLogFile_mirrorToStdErr = (_LCLLogFile_MirrorMessagesToStdErr); + + // get whether we should escape '\\' and '\n' characters in log messages + _LCLLogFile_escapeLineFeeds = (_LCLLogFile_EscapeLineFeeds); + + // get max size of a log message + _LCLLogFile_maxMessageSize = (_LCLLogFile_MaxMessageSizeInCharacters); + + // get whether we should show file names + _LCLLogFile_showFileName = (_LCLLogFile_ShowFileNames); + + // get whether we should show line numbers + _LCLLogFile_showLineNumber = (_LCLLogFile_ShowLineNumbers); + + // get whether we should show function names + _LCLLogFile_showFunctionName = (_LCLLogFile_ShowFunctionNames); + + // get the full path of the log file + NSString *path = (_LCLLogFile_LogFilePath); + + // create log file paths + _LCLLogFile_filePath = nil; + _LCLLogFile_filePath_c = NULL; + _LCLLogFile_filePath0 = nil; + _LCLLogFile_filePath0_c = NULL; + _LCLLogFile_setLogFilePath(path); + + // log file size is zero + _LCLLogFile_fileSize = 0; + + _LCLLogFile_autoreleasepool_end +} + + +// +// Logging methods. +// + + +// Creates the log message prefix. +static NSString *_LCLLogFile_prefix(const char *identifier_c, uint32_t level, + const char *path_c, uint32_t line, + const char *function_c) { + // get settings + const int show_file = _LCLLogFile_showFileName; + const int show_line = _LCLLogFile_showLineNumber; + const int show_function = _LCLLogFile_showFunctionName; + + // get file name from path + const char *file_c = NULL; + if (show_file) { + file_c = path_c != NULL ? strrchr(path_c, '/') : NULL; + file_c = (file_c != NULL) ? (file_c + 1) : (path_c); + } + + // get line + char line_c[11]; + if (show_line) { + snprintf(line_c, sizeof(line_c), "%u", line); + line_c[sizeof(line_c) - 1] = '\0'; + } + + // get the level header + char level_ca[11]; + const char *level_c; + if (level < sizeof(_LCLLogFile_levelHeader)/sizeof(const char *)) { + // a known level, e.g. E, W, I + level_c = _LCLLogFile_levelHeader[level]; + } else { + // unknown level, use the level number + snprintf(level_ca, sizeof(level_ca), "%u", level); + level_c = level_ca; + } + + // create prefix + NSString *prefix = [NSString stringWithFormat:@" %u:%x %s %s%s%s%s%s%s%s ", + /* */ + /* %u */ _LCLLogFile_processId, + /* %x */ mach_thread_self(), + /* */ + /* %s */ level_c, + /* */ + /* %s */ identifier_c, + /* %s */ show_file ? ":" : "", + /* %s */ show_file ? file_c : "", + /* %s */ show_line ? ":" : "", + /* %s */ show_line ? line_c : "", + /* %s */ show_function ? ":" : "", + /* %s */ show_function ? function_c : "" + /* */ + ]; + + return prefix; +} + +// Writes the given log message to the log file (internal). +static void _LCLLogFile_log(const char *identifier_c, uint32_t level, + const char *path_c, uint32_t line, + const char *function_c, + NSString *message) { + _LCLLogFile_autoreleasepool_begin + + // create the prefix + NSString *prefix = _LCLLogFile_prefix(identifier_c, level, path_c, line, function_c); + + // restrict size of log message + if (_LCLLogFile_maxMessageSize != 0) { + NSUInteger message_len = [message length]; + if (message_len > _LCLLogFile_maxMessageSize) { + message = [message substringToIndex:_LCLLogFile_maxMessageSize]; + } + } + + // escape '\\' and '\n' characters + if (_LCLLogFile_escapeLineFeeds) { + NSMutableString *emessage = [[NSMutableString alloc] initWithCapacity:[message length] * 2]; +# if !__has_feature(objc_arc) + [emessage autorelease]; +# endif + [emessage appendString:message]; +# ifndef _LCL_NO_IGNORE_WARNINGS +# ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunknown-pragmas" +# pragma clang diagnostic ignored "-Wassign-enum" +# endif +# endif + [emessage replaceOccurrencesOfString:@"\\" withString:@"\\\\" options:0 range:NSMakeRange(0, [emessage length])]; + [emessage replaceOccurrencesOfString:@"\n" withString:@"\\n" options:0 range:NSMakeRange(0, [emessage length])]; +# ifndef _LCL_NO_IGNORE_WARNINGS +# ifdef __clang__ +# pragma clang diagnostic pop +# endif +# endif + message = emessage; + } + + // create C strings + const char *prefix_c = [prefix UTF8String]; + const char *message_c = [message UTF8String]; + + // get size of log entry + char time_c[24]; + const int backslash_n_len = 1; + size_t entry_len = sizeof(time_c) + strlen(prefix_c) + strlen(message_c) + backslash_n_len; + + // under lock protection ... + [_LCLLogFile_lock lock]; + { + FILE *filehandle = (FILE *)_LCLLogFile_fileHandle; + + // rotate the log file if required + if (filehandle) { + if (_LCLLogFile_fileSize + entry_len > _LCLLogFile_fileSizeMax) { + [LCLLogFile rotate]; + [LCLLogFile open]; + filehandle = (FILE *)_LCLLogFile_fileHandle; + } + } + + // get current time + struct timeval now; + struct tm now_tm; + gettimeofday(&now, NULL); + localtime_r(&now.tv_sec, &now_tm); + snprintf(time_c, sizeof(time_c), "%04d-%02d-%02d %02d:%02d:%02d.%03d", + now_tm.tm_year + 1900, + now_tm.tm_mon + 1, + now_tm.tm_mday, + now_tm.tm_hour, + now_tm.tm_min, + now_tm.tm_sec, + now.tv_usec / 1000); + + // write the log message + if (filehandle) { + // increase file size + _LCLLogFile_fileSize += entry_len; + + // write current time and log message + fprintf(filehandle, "%s%s%s\n", time_c, prefix_c, message_c); + + // flush the file + fflush(filehandle); + } + + // mirror to stderr? + if (_LCLLogFile_mirrorToStdErr) { +# ifndef __LCLLogFile_stderr +# define __LCLLogFile_stderr stderr +# endif + fprintf(__LCLLogFile_stderr, "%s%s%s\n", time_c, prefix_c, message_c); + } + } + // ... done + [_LCLLogFile_lock unlock]; + + _LCLLogFile_autoreleasepool_end +} + +// Writes the given log message to the log file (message). ++ (void)logWithIdentifier:(const char *)identifier level:(uint32_t)level + path:(const char *)path line:(uint32_t)line + function:(const char *)function + message:(NSString *)message { + // open the log file + if (!_LCLLogFile_isActive) { + [LCLLogFile open]; + } + + // write log message if the log file is opened or mirroring is enabled + if (_LCLLogFile_fileHandle || _LCLLogFile_mirrorToStdErr) { + // write log message + _LCLLogFile_log(identifier, level, path, line, function, message); + } +} + +// Writes the given log message to the log file (format and va_list var args). ++ (void)logWithIdentifier:(const char *)identifier level:(uint32_t)level + path:(const char *)path line:(uint32_t)line + function:(const char *)function + format:(NSString *)format args:(va_list)args { + // open the log file + if (!_LCLLogFile_isActive) { + [LCLLogFile open]; + } + + // write log message if the log file is opened or mirroring is enabled + if (_LCLLogFile_fileHandle || _LCLLogFile_mirrorToStdErr) { + // create log message +# ifndef _LCL_NO_IGNORE_WARNINGS +# ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunknown-pragmas" +# pragma clang diagnostic ignored "-Wformat-nonliteral" +# endif +# endif + NSString *message = [[NSString alloc] initWithFormat:format arguments:args]; +# ifndef _LCL_NO_IGNORE_WARNINGS +# ifdef __clang__ +# pragma clang diagnostic pop +# endif +# endif + + // write log message + _LCLLogFile_log(identifier, level, path, line, function, message); + + // release local objects +# if !__has_feature(objc_arc) + [message release]; +# endif + } +} + +// Writes the given log message to the log file (format and ... var args). ++ (void)logWithIdentifier:(const char *)identifier level:(uint32_t)level + path:(const char *)path line:(uint32_t)line + function:(const char *)function + format:(NSString *)format, ... { + // open the log file + if (!_LCLLogFile_isActive) { + [LCLLogFile open]; + } + + // write log message if the log file is opened or mirroring is enabled + if (_LCLLogFile_fileHandle || _LCLLogFile_mirrorToStdErr) { + // create log message + va_list args; + va_start(args, format); + NSString *message = [[NSString alloc] initWithFormat:format arguments:args]; + va_end(args); + + // write log message + _LCLLogFile_log(identifier, level, path, line, function, message); + + // release local objects +# if !__has_feature(objc_arc) + [message release]; +# endif + } +} + + +// +// Configuration. +// + + +// Returns the path of the log file. ++ (NSString *)path { + return _LCLLogFile_filePath; +} + +// Returns the path of the backup log file. ++ (NSString *)path0 { + return _LCLLogFile_filePath0; +} + +// Sets the path of the log file. ++ (void)setPath:(NSString *)path { + [_LCLLogFile_lock lock]; + { + _LCLLogFile_autoreleasepool_begin + + [LCLLogFile reset]; + _LCLLogFile_setLogFilePath(path); + + _LCLLogFile_autoreleasepool_end + } + [_LCLLogFile_lock unlock]; +} + +// Returns/sets whether log messages get appended to an existing log file on startup. ++ (BOOL)appendsToExistingLogFile { + return _LCLLogFile_appendToExistingLogFile; +} ++ (void)setAppendsToExistingLogFile:(BOOL)value { + [_LCLLogFile_lock lock]; + { + _LCLLogFile_appendToExistingLogFile = value; + } + [_LCLLogFile_lock unlock]; +} + +// Returns/sets the maximum size of the log file (as defined by +// _LCLLogFile_MaxLogFileSizeInBytes). ++ (size_t)maxSize { + return _LCLLogFile_fileSizeMax; +} ++ (void)setMaxSize:(size_t)value { + [_LCLLogFile_lock lock]; + { + _LCLLogFile_fileSizeMax = value; + if (_LCLLogFile_fileSizeMax < 4 * 1024) { + _LCLLogFile_fileSizeMax = 4 * 1024; + } + } + [_LCLLogFile_lock unlock]; +} + +// Returns/sets whether log messages are mirrored to stderr. ++ (BOOL)mirrorsToStdErr { + return _LCLLogFile_mirrorToStdErr; +} ++ (void)setMirrorsToStdErr:(BOOL)value { + [_LCLLogFile_lock lock]; + { + _LCLLogFile_mirrorToStdErr = value; + } + [_LCLLogFile_lock unlock]; +} + +// Returns/sets whether ('\\' and) '\n' line feed characters are escaped in +// log messages. ++ (BOOL)escapesLineFeeds { + return _LCLLogFile_escapeLineFeeds; +} ++ (void)setEscapesLineFeeds:(BOOL)value { + [_LCLLogFile_lock lock]; + { + _LCLLogFile_escapeLineFeeds = value; + } + [_LCLLogFile_lock unlock]; +} + +// Returns/sets the maximum size of a log message in characters (without +// prefixes). The value 0 indicates that there is no maximum size for log +// messages. ++ (NSUInteger)maxMessageSize { + return _LCLLogFile_maxMessageSize; +} ++ (void)setMaxMessageSize:(NSUInteger)value { + [_LCLLogFile_lock lock]; + { + _LCLLogFile_maxMessageSize = value; + } + [_LCLLogFile_lock unlock]; +} + +// Returns/sets whether file names are shown. ++ (BOOL)showsFileNames { + return _LCLLogFile_showFileName; +} ++ (void)setShowsFileNames:(BOOL)value { + [_LCLLogFile_lock lock]; + { + _LCLLogFile_showFileName = value; + } + [_LCLLogFile_lock unlock]; +} + +// Returns/sets whether line numbers are shown. ++ (BOOL)showsLineNumbers { + return _LCLLogFile_showLineNumber; +} ++ (void)setShowsLineNumbers:(BOOL)value { + [_LCLLogFile_lock lock]; + { + _LCLLogFile_showLineNumber = value; + } + [_LCLLogFile_lock unlock]; +} + +// Returns/sets whether function names are shown. ++ (BOOL)showsFunctionNames { + return _LCLLogFile_showFunctionName; +} ++ (void)setShowsFunctionNames:(BOOL)value { + [_LCLLogFile_lock lock]; + { + _LCLLogFile_showFunctionName = value; + } + [_LCLLogFile_lock unlock]; +} + + +// +// Status information and internals. +// + + +// Returns the current size of the log file. ++ (size_t)size { + size_t sz = 0; + [_LCLLogFile_lock lock]; + { + // get the size + sz = _LCLLogFile_fileSize; + } + [_LCLLogFile_lock unlock]; + return sz; +} + +// Opens the log file. ++ (void)open { + [_LCLLogFile_lock lock]; + { + if (_LCLLogFile_fileHandle == NULL) { + // size of log file is 0 + _LCLLogFile_fileSize = 0; + + if (_LCLLogFile_isActive || !_LCLLogFile_appendToExistingLogFile) { + // create a new log file + _LCLLogFile_fileHandle = NULL; + if (_LCLLogFile_filePath_c != NULL) { + _LCLLogFile_fileHandle = fopen(_LCLLogFile_filePath_c, "w"); + } + } else { + // append to existing log file, get size from file + _LCLLogFile_fileHandle = NULL; + if (_LCLLogFile_filePath_c != NULL) { + _LCLLogFile_fileHandle = fopen(_LCLLogFile_filePath_c, "a"); + } + + // try to get size of existing log file + struct stat stat_c; + if (_LCLLogFile_filePath_c != NULL && stat(_LCLLogFile_filePath_c, &stat_c) == 0) { + _LCLLogFile_fileSize = (size_t)stat_c.st_size; + } + } + + // logging is active + _LCLLogFile_isActive = YES; + } + } + [_LCLLogFile_lock unlock]; +} + +// Closes the log file. ++ (void)close { + [_LCLLogFile_lock lock]; + { + // close the log file + FILE *filehandle = (FILE *)_LCLLogFile_fileHandle; + if (filehandle != NULL) { + fclose(filehandle); + _LCLLogFile_fileHandle = NULL; + } + + // log file size is zero + _LCLLogFile_fileSize = 0; + } + [_LCLLogFile_lock unlock]; +} + +// Resets the log file. ++ (void)reset { + [_LCLLogFile_lock lock]; + { + // close the log file + [LCLLogFile close]; + + // unlink existing log files + if (_LCLLogFile_filePath_c != NULL) { + unlink(_LCLLogFile_filePath_c); + } + if (_LCLLogFile_filePath0_c != NULL) { + unlink(_LCLLogFile_filePath0_c); + } + + // logging is not active + _LCLLogFile_isActive = NO; + + } + [_LCLLogFile_lock unlock]; +} + +// Rotates the log file. ++ (void)rotate { + [_LCLLogFile_lock lock]; + { + // close the log file + [LCLLogFile close]; + + // keep a copy of the current log file + if (_LCLLogFile_filePath_c != NULL && _LCLLogFile_filePath0_c != NULL) { + rename(_LCLLogFile_filePath_c, _LCLLogFile_filePath0_c); + } + } + [_LCLLogFile_lock unlock]; +} + + +// +// Methods for creating log file paths. +// + + +// Returns a default path for a log file which is based on the Info.plist +// files which are associated with this class. The returned path has the form +// ~/Library/Logs/
/.log +// where +//
is the name (or identifier) of the application's main bundle, and +// is the name (or identifier) of the bundle to which this LCLLogFile +// class belongs. +// This method is a convenience method which calls defaultPathWithPathPrefix +// with the prefix ~/Library/Logs and the given fallback path. ++ (NSString *)defaultPathInHomeLibraryLogsOrPath:(NSString *)path { + return [LCLLogFile defaultPathWithPathPrefix: + [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Logs"] + orPath:path]; +} + +// Returns a default path for a log file which is based on the Info.plist +// files which are associated with this class. The returned path has the form +// /
/.log +// where +// is the given path prefix, +//
is the name (or identifier) of the application's main bundle, and +// is the name (or identifier) of the bundle to which this LCLLogFile +// class belongs. +// If the name or identifier cannot be retrieved from the main bundle, the +// returned default path has the form +// //..log +// where +// is the current process id. +// If the name or identifier cannot be retrieved from the bundle which +// corresponds to this LCLLogFile class, or if the given path prefix is +// nil, the given fallback path is returned. ++ (NSString *)defaultPathWithPathPrefix:(NSString *)pathPrefix + orPath:(NSString *)path { + // get the main bundle and the bundle which corresponds to this class + NSBundle *pathBundle = [NSBundle mainBundle]; + NSBundle *fileBundle = [NSBundle bundleForClass:[LCLLogFile class]]; + + NSString *pathComponent = [LCLLogFile defaultPathComponentFromPathBundle:pathBundle + fileBundle:fileBundle + orPathComponent:nil]; + + if (pathPrefix != nil && pathComponent != nil) { + return [pathPrefix stringByAppendingPathComponent:pathComponent]; + } else { + return path; + } +} + +// Returns a default path component for a log file which is based on the given +// bundles' Info.plist files. The returned path has the form +// /.log +// where +// is the name (or identifier) of the given path bundle, and +// is the name (or identifier) of the given file bundle. +// If the name or identifier cannot be retrieved from the path bundle, the +// returned default path has the form +// /..log +// where +// is the current process id. +// If the name or identifier cannot be retrieved from the file bundle, the +// given fallback path component is returned. ++ (NSString *)defaultPathComponentFromPathBundle:(NSBundle *)pathBundle + fileBundle:(NSBundle *)fileBundle + orPathComponent:(NSString *)pathComponent { + NSString *pathName = [LCLLogFile nameOrIdentifierFromBundle:pathBundle + orString:nil]; + NSString *fileName = [LCLLogFile nameOrIdentifierFromBundle:fileBundle + orString:nil]; + + if (pathName != nil && fileName != nil) { + // we have a path name and a file name + return [NSString stringWithFormat:@"%@/%@.log", pathName, fileName]; + } else if (pathName == nil && fileName != nil) { + // we don't have a path name, but a file name, use the file name as + // the path name and append the pid to the file name to avoid collisions + return [NSString stringWithFormat:@"%@/%@.%u.log", fileName, fileName, getpid()]; + } else { + // no information from the bundles, fail + return pathComponent; + } +} + +// Returns the name from the given bundle's Info.plist file. If the name doesn't +// exist, the bundle's identifier is returned. If the identifier doesn't exist, +// the given fallback string is returned. ++ (NSString *)nameOrIdentifierFromBundle:(NSBundle *)bundle + orString:(NSString *)string { + id bundleName = [bundle objectForInfoDictionaryKey:@"CFBundleName"]; + if (bundleName != nil && [bundleName isKindOfClass:[NSString class]]) { + return (NSString *)bundleName; + } + NSString *bundleIdentifier = [bundle bundleIdentifier]; + if (bundleIdentifier != nil) { + return bundleIdentifier; + } + return string; +} + +@end + diff --git a/Vendor/LibComponentLogging/LCLLogFileConfig.h b/Vendor/LibComponentLogging/LCLLogFileConfig.h new file mode 100755 index 0000000000..9c5340ffa7 --- /dev/null +++ b/Vendor/LibComponentLogging/LCLLogFileConfig.h @@ -0,0 +1,75 @@ +// +// +// LCLLogFileConfig.h +// +// +// Copyright (c) 2008-2013 Arne Harren +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// +// LCLLogFileConfig.h template for the LCLLogFile logging class. +// + + +// Rename the LCLLogFile class by adding your application/framework's unique +// prefix in order to avoid duplicate symbols in the global class namespace. +#ifndef LCLLogFile +#define LCLLogFile \ + RKLCLLogFile +#endif + +// Tell LCLLogFile the path of the log file. +#define _LCLLogFile_LogFilePath /* (NSString *) */ \ + [LCLLogFile defaultPathInHomeLibraryLogsOrPath:nil] + +// Tell LCLLogFile whether it should append to an existing log file on startup, +// instead of creating a new log file. +#define _LCLLogFile_AppendToExistingLogFile /* (BOOL) */ \ + YES + +// Tell LCLLogFile the maximum size of a log file in bytes. +#define _LCLLogFile_MaxLogFileSizeInBytes /* (size_t) */ \ + 2 * 1024 * 1024 + +// Tell LCLLogFile whether it should mirror the log messages to stderr. +#define _LCLLogFile_MirrorMessagesToStdErr /* (BOOL) */ \ + NO + +// Tell LCLLogFile the maximum size of a log message in characters. +#define _LCLLogFile_MaxMessageSizeInCharacters /* NSUInteger */ \ + 0 + +// Tell LCLLogFile whether it should escape ('\\' and) '\n' line feed characters +// in log messages +#define _LCLLogFile_EscapeLineFeeds /* BOOL */ \ + YES + +// Tell LCLLogFile whether it should show file names. +#define _LCLLogFile_ShowFileNames /* (BOOL) */ \ + YES + +// Tell LCLLogFile whether it should show line numbers. +#define _LCLLogFile_ShowLineNumbers /* (BOOL) */ \ + YES + +// Tell LCLLogFile whether it should show function names. +#define _LCLLogFile_ShowFunctionNames /* (BOOL) */ \ + YES + diff --git a/Vendor/LibComponentLogging/NSLog/lcl_config_logger.h b/Vendor/LibComponentLogging/NSLog/lcl_config_logger.h index b476ca6f8f..d13979cb1a 100644 --- a/Vendor/LibComponentLogging/NSLog/lcl_config_logger.h +++ b/Vendor/LibComponentLogging/NSLog/lcl_config_logger.h @@ -26,4 +26,5 @@ // Use the LCLNSLog logger. #import "LCLNSLog.h" +#import "LCLLogFile.h"