Skip to content

Commit

Permalink
Merge pull request #5 from pulimento/fix_logger_directory
Browse files Browse the repository at this point in the history
Fix logger directory
  • Loading branch information
vigneshuvi authored Jan 23, 2018
2 parents 127fbab + 57620a2 commit 002d91f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion SwiftLoggly/Sources/Loggly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,24 @@ public enum LogFormatType {
open var maxFileCount = 4;

///The directory in which the log files will be written
open var directory = Loggly.defaultDirectory();
open var directory : String = Loggly.defaultDirectory() {
didSet {
guard directory.count > 0 else {
print("Error changing logger directory. The value \(directory) is not valid. Using default value instead")
directory = Loggly.defaultDirectory()
return
}
let fileManager = FileManager.default
if !fileManager.fileExists(atPath: directory) {
do {
try fileManager.createDirectory(atPath: directory, withIntermediateDirectories: false, attributes: nil)
} catch _ {
print("Error changing logger directory. The value \(directory) is not valid. Using default value instead")
directory = Loggly.defaultDirectory()
}
}
}
}

///The reportDirectory in which the report files will be written
var reportDirectory = Loggly.defaultReportDirectory();
Expand Down

0 comments on commit 002d91f

Please sign in to comment.