DDSampleFileManager.m 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Software License Agreement (BSD License)
  2. //
  3. // Copyright (c) 2010-2025, 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. #import "DDSampleFileManager.h"
  16. @interface DDSampleFileManager ()
  17. @property (nonatomic) NSString *header;
  18. @end
  19. @implementation DDSampleFileManager
  20. - (instancetype)initWithLogFileHeader:(NSString *)header {
  21. self = [super initWithLogsDirectory:[NSTemporaryDirectory() stringByAppendingString:[NSUUID UUID].UUIDString]];
  22. if (self) {
  23. _header = header;
  24. }
  25. return self;
  26. }
  27. - (instancetype)initWithLogsDirectory:(NSString *)logsDirectory {
  28. return [self initWithLogFileHeader:nil];
  29. }
  30. - (NSString *)logFileHeader {
  31. return _header;
  32. }
  33. - (void)didArchiveLogFile:(NSString *)logFilePath wasRolled:(BOOL)wasRolled {
  34. _archivedLogFilePath = logFilePath;
  35. }
  36. - (NSString *)newLogFileName {
  37. if (self.customLogFileName) {
  38. return self.customLogFileName;
  39. }
  40. return [super newLogFileName];
  41. }
  42. - (BOOL)isLogFile:(NSString *)fileName {
  43. if (self.customLogFileName) {
  44. return [self.customLogFileName isEqualToString:fileName];
  45. }
  46. return [super isLogFile:fileName];
  47. }
  48. @end