3.6. SMFileLogger

This class provides the function which outputs the StarIO.framework and StarIO_Extension.framework logs to files. It extends the SMLogger class.

  • Property

    Name Description
    sharedInstance The singleton instance of the SMFileLogger class.
    maxLogSize Specifies the maximum log size to be kept.
    logDirectoryPath The directory path of log files to save.

The output log file is saved under the Documents/starlog directory of the application. You can access the saved file by using the file sharing function.

Ex.1: When using iTunes file sharing

It is necessary to set items to Information Property List. The setting procedure is as follows.

  1. Select the Information Property List (“Info.plist” by default).
  2. Added Key Application supports iTunes file sharing
  3. Set YES to [Value] of “Item 0” displayed by clicking â–½ on the left side of the item name
Ex. 2: Using opening documents in place

It is necessary to set items to Information Property List. The setting procedure is as follows.

  1. Select the Information Property List (“Info.plist” by default).
  2. Added Key Supports opening documents in place
  3. Set YES to [Value] of “Item 0” displayed by clicking â–½ on the left side of the item name

3.6.1. sharedInstance

The singleton instance of the SMFileLogger class.

  • Declaration

    @property (class, nonatomic, readonly, nonnull) SMFileLogger *sharedInstance;
    
  • Value

    Description Object type
    The singleton class of the SMFileLogger instance. SMFileLogger

3.6.2. maxLogSize

Specifies the maximum log size to be kept.

  • Declaration

    @property(nonatomic) NSUInteger maxLogSize;
    
  • Value

    Description Object type
    Maximum log size to be kept (in MB)
    Default value: 50 (MB)
    If 0 is specified, no limit on log size is set.
    NSUInteger

3.6.3. logDirectoryPath

The directory path of log files to save.

  • Declaration

    @property (nonatomic, readonly) NSString *logDirectoryPath;
    
  • Value

    Description Object type
    The directory path of log files to save “Documents/starlog” is set. NSString

3.6.4. Sample of log output using the SMFileLogger class

// Get SMFileLogger class singleton instance.
SMFileLogger *logger = SMFileLogger.sharedInstance;

// Set the log level.
logger.logLevel = SMLogLevelDefault;

// Set the maximum log size to be kept (optional).
logger.maxLogSize = 10;

// Start log output.
[logger start];

// Output the desired string (optional).
[logger logString:@"(Log message)"];

// Stop log output.
[logger stop];