Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. // Software License Agreement (BSD License)
  2. //
  3. // Copyright (c) 2010-2016, Deusty, LLC
  4. // All rights reserved.
  5. //
  6. // Redistribution and use of this software in source and binary forms,
  7. // with or without modification, are permitted provided that the following conditions are met:
  8. //
  9. // * Redistributions of source code must retain the above copyright notice,
  10. // this list of conditions and the following disclaimer.
  11. //
  12. // * Neither the name of Deusty nor the names of its contributors may be used
  13. // to endorse or promote products derived from this software without specific
  14. // prior written permission of Deusty, LLC.
  15.  
  16. #import "AWSDDOSLogger.h"
  17. #import <os/log.h>
  18.  
  19. static AWSDDOSLogger *sharedInstance;
  20.  
  21. @implementation AWSDDOSLogger
  22.  
  23. + (instancetype)sharedInstance {
  24. static dispatch_once_t AWSDDOSLoggerOnceToken;
  25.  
  26. dispatch_once(&AWSDDOSLoggerOnceToken, ^{
  27. sharedInstance = [[[self class] alloc] init];
  28. });
  29.  
  30. return sharedInstance;
  31. }
  32.  
  33. - (instancetype)init {
  34. if (sharedInstance != nil) {
  35. return nil;
  36. }
  37.  
  38. if (self = [super init]) {
  39. return self;
  40. }
  41.  
  42. return nil;
  43. }
  44.  
  45. - (void)logMessage:(AWSDDLogMessage *)logMessage {
  46. // Skip captured log messages
  47. if ([logMessage->_fileName isEqualToString:@"AWSDDASLLogCapture"]) {
  48. return;
  49. }
  50.  
  51. NSString * message = _logFormatter ? [_logFormatter formatLogMessage:logMessage] : logMessage->_message;
  52.  
  53. if (message) {
  54. const char *msg = [message UTF8String];
  55.  
  56. switch (logMessage->_flag) {
  57. case AWSDDLogFlagError :
  58. os_log_error(OS_LOG_DEFAULT, "%{public}s", msg); //fix for XCode 9 compile error - badger (9/23/17)
  59. break;
  60. case AWSDDLogFlagWarning :
  61. case AWSDDLogFlagInfo :
  62. os_log_info(OS_LOG_DEFAULT, "%{public}s", msg); //fix for XCode 9 compile error - badger (9/23/17)
  63. break;
  64. case AWSDDLogFlagDebug :
  65. case AWSDDLogFlagVerbose :
  66. default :
  67. os_log_debug(OS_LOG_DEFAULT, "%{public}s", msg); //fix for XCode 9 compile error - badger (9/23/17)
  68. break;
  69. }
  70. }
  71. }
  72.  
  73. - (NSString *)loggerName {
  74. return @"cocoa.lumberjack.osLogger";
  75. }
  76.  
  77. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement