Açıklama Yok

GTMSessionFetcherLogging.h 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* Copyright 2014 Google Inc. All rights reserved.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #import "GTMSessionFetcher.h"
  16. // GTM HTTP Logging
  17. //
  18. // All traffic using GTMSessionFetcher can be easily logged. Call
  19. //
  20. // [GTMSessionFetcher setLoggingEnabled:YES];
  21. //
  22. // to begin generating log files.
  23. //
  24. // Unless explicitly set by the application using +setLoggingDirectory:,
  25. // logs are put into a default directory, located at:
  26. // * macOS: ~/Desktop/GTMHTTPDebugLogs
  27. // * iOS simulator: ~/GTMHTTPDebugLogs (in application sandbox)
  28. // * iOS device: ~/Documents/GTMHTTPDebugLogs (in application sandbox)
  29. //
  30. // Tip: use the Finder's "Sort By Date" to find the most recent logs.
  31. //
  32. // Each run of an application gets a separate set of log files. An html
  33. // file is generated to simplify browsing the run's http transactions.
  34. // The html file includes javascript links for inline viewing of uploaded
  35. // and downloaded data.
  36. //
  37. // A symlink is created in the logs folder to simplify finding the html file
  38. // for the latest run of the application; the symlink is called
  39. //
  40. // AppName_http_log_newest.html
  41. //
  42. // For better viewing of XML logs, use Camino or Firefox rather than Safari.
  43. //
  44. // Each fetcher may be given a comment to be inserted as a label in the logs,
  45. // such as
  46. // [fetcher setCommentWithFormat:@"retrieve item %@", itemName];
  47. //
  48. // Projects may define STRIP_GTM_FETCH_LOGGING to remove logging code.
  49. #if !STRIP_GTM_FETCH_LOGGING
  50. @interface GTMSessionFetcher (GTMSessionFetcherLogging)
  51. // Note: on macOS the default logs directory is ~/Desktop/GTMHTTPDebugLogs; on
  52. // iOS simulators it will be the ~/GTMHTTPDebugLogs (in the app sandbox); on
  53. // iOS devices it will be in ~/Documents/GTMHTTPDebugLogs (in the app sandbox).
  54. // These directories will be created as needed, and are excluded from backups
  55. // to iCloud and iTunes.
  56. //
  57. // If a custom directory is set, the directory should already exist. It is
  58. // the application's responsibility to exclude any custom directory from
  59. // backups, if desired.
  60. + (void)setLoggingDirectory:(NSString *)path;
  61. + (NSString *)loggingDirectory;
  62. // client apps can turn logging on and off
  63. + (void)setLoggingEnabled:(BOOL)isLoggingEnabled;
  64. + (BOOL)isLoggingEnabled;
  65. // client apps can turn off logging to a file if they want to only check
  66. // the fetcher's log property
  67. + (void)setLoggingToFileEnabled:(BOOL)isLoggingToFileEnabled;
  68. + (BOOL)isLoggingToFileEnabled;
  69. // client apps can optionally specify process name and date string used in
  70. // log file names
  71. + (void)setLoggingProcessName:(NSString *)processName;
  72. + (NSString *)loggingProcessName;
  73. + (void)setLoggingDateStamp:(NSString *)dateStamp;
  74. + (NSString *)loggingDateStamp;
  75. // client apps can specify the directory for the log for this specific run,
  76. // typically to match the directory used by another fetcher class, like:
  77. //
  78. // [GTMSessionFetcher setLogDirectoryForCurrentRun:[GTMHTTPFetcher logDirectoryForCurrentRun]];
  79. //
  80. // Setting this overrides the logging directory, process name, and date stamp when writing
  81. // the log file.
  82. + (void)setLogDirectoryForCurrentRun:(NSString *)logDirectoryForCurrentRun;
  83. + (NSString *)logDirectoryForCurrentRun;
  84. // Prunes old log directories that have not been modified since the provided date.
  85. // This will not delete the current run's log directory.
  86. + (void)deleteLogDirectoriesOlderThanDate:(NSDate *)date;
  87. // internal; called by fetcher
  88. - (void)logFetchWithError:(NSError *)error;
  89. - (NSInputStream *)loggedInputStreamForInputStream:(NSInputStream *)inputStream;
  90. - (GTMSessionFetcherBodyStreamProvider)loggedStreamProviderForStreamProvider:
  91. (GTMSessionFetcherBodyStreamProvider)streamProvider;
  92. // internal; accessors useful for viewing logs
  93. + (NSString *)processNameLogPrefix;
  94. + (NSString *)symlinkNameSuffix;
  95. + (NSString *)htmlFileName;
  96. @end
  97. #endif // !STRIP_GTM_FETCH_LOGGING