No Description

AWSLogging.h 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License").
  5. // You may not use this file except in compliance with the License.
  6. // A copy of the License is located at
  7. //
  8. // http://aws.amazon.com/apache2.0
  9. //
  10. // or in the "license" file accompanying this file. This file is distributed
  11. // on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. // express or implied. See the License for the specific language governing
  13. // permissions and limitations under the License.
  14. //
  15. #import <Foundation/Foundation.h>
  16. #define AWSLogFormat @"%@ line:%d | %s | "
  17. #define AWSLogError(fmt, ...) [[AWSLogger defaultLogger] log:AWSLogLevelError format:(AWSLogFormat fmt), [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__]
  18. #define AWSLogWarn(fmt, ...) [[AWSLogger defaultLogger] log:AWSLogLevelWarn format:(AWSLogFormat fmt), [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__]
  19. #define AWSLogInfo(fmt, ...) [[AWSLogger defaultLogger] log:AWSLogLevelInfo format:(AWSLogFormat fmt), [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__]
  20. #define AWSLogDebug(fmt, ...) [[AWSLogger defaultLogger] log:AWSLogLevelDebug format:(AWSLogFormat fmt), [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__]
  21. #define AWSLogVerbose(fmt, ...) [[AWSLogger defaultLogger] log:AWSLogLevelVerbose format:(AWSLogFormat fmt), [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__]
  22. typedef NS_ENUM(NSInteger, AWSLogLevel) {
  23. AWSLogLevelUnknown = -1,
  24. AWSLogLevelNone = 0,
  25. AWSLogLevelError = 1,
  26. AWSLogLevelWarn = 2,
  27. AWSLogLevelInfo = 3,
  28. AWSLogLevelDebug = 4,
  29. AWSLogLevelVerbose = 5
  30. };
  31. /**
  32. `AWSLogger` is an utility class that handles logging to the console. Changing log levels during development may make debugging easier. You can change the log level by importing `AWSCore.h` and calling:
  33. *Swift*
  34. AWSLogger.defaultLogger().logLevel = .None
  35. The following logging level options are available:
  36. .None
  37. .Error
  38. .Warn
  39. .Info
  40. .Debug (This is the default.)
  41. .Verbose
  42. *Objective-C*
  43. [AWSLogger defaultLogger].logLevel = AWSLogLevelNone;
  44. The following logging level options are available:
  45. AWSLogLevelNone
  46. AWSLogLevelError
  47. AWSLogLevelWarn
  48. AWSLogLevelInfo
  49. AWSLogLevelDebug (This is the default.)
  50. AWSLogLevelVerbose
  51. @note We recommend setting the log level to `None` before publishing to the Apple App Store.
  52. */
  53. __attribute__((deprecated("use AWSDDLog instead")))
  54. @interface AWSLogger : NSObject
  55. /**
  56. The log level setting. The default value is `Debug`.
  57. */
  58. @property (atomic, assign) AWSLogLevel logLevel;
  59. /**
  60. Returns the shared logger object.
  61. @return The shared logger object.
  62. */
  63. + (instancetype)defaultLogger;
  64. /**
  65. Prints out the formatted logs to the console. You can use the following predefined shorthand methods instead:
  66. AWSLogError(fmt, ...)
  67. AWSLogWarn(fmt, ...)
  68. AWSLogInfo(fmt, ...)
  69. AWSLogDebug(fmt, ...)
  70. AWSLogVerbose(fmt, ...)
  71. @param logLevel The level of this log.
  72. @param fmt The formatted string to log.
  73. */
  74. - (void)log:(AWSLogLevel)logLevel
  75. format:(NSString *)fmt, ... NS_FORMAT_FUNCTION(2, 3);
  76. @end