Skip to content

Commit

Permalink
Merge pull request #23 from sematext/change_logging_level_for_file_re…
Browse files Browse the repository at this point in the history
…lated_events

Move logging to DEBUG
  • Loading branch information
Rafał Kuć authored Dec 15, 2020
2 parents b8bb1ed + b34a928 commit 879622b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Logsene.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'Logsene'
s.version = '1.7.0'
s.version = '1.7.1'
s.summary = 'Sematext Cloud Logs is ELK as a Service. This library lets you collect mobile analytics and log data from your iOS applications.'

s.description = <<-DESC
Expand Down
2 changes: 2 additions & 0 deletions Logsene/Classes/File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ internal struct File {
let attributes = try FileManager.default.attributesOfItem(atPath: url.path)
return attributes[.size] as? UInt64 ?? 0
} catch {
#if DEBUG
NSLog("Error reading current log file size")
#endif
}
return 0
}
Expand Down
16 changes: 16 additions & 0 deletions Logsene/Classes/FileStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class FileStorage {
}
return documents
} catch {
#if DEBUG
NSLog("Error reading data from file \(file.name)")
#endif
}
return nil
}
Expand All @@ -51,7 +53,9 @@ class FileStorage {

// Rolls file creating new one
func rollFile() {
#if DEBUG
NSLog("Rolling file")
#endif
do {
try openNewLogsFile()
} catch {
Expand Down Expand Up @@ -80,10 +84,14 @@ class FileStorage {
// Deletes file
func deleteFile(file: File) {
do {
#if DEBUG
NSLog("Deleting file \(file.name)")
#endif
try file.delete()
} catch {
#if DEBUG
NSLog("Error while deleting file: \(file.name)")
#endif
}
}

Expand All @@ -94,7 +102,9 @@ class FileStorage {

// Cleans up logs data directory deleting files that are not needed
private func cleanUp() {
#if DEBUG
NSLog("Starting log files directory cleanup")
#endif
do {
let files = try self.logsDirectory.listFiles()
var numFilesToDelete = files.count - maxNumberOfFiles + 1
Expand All @@ -109,10 +119,14 @@ class FileStorage {
}
}
} else {
#if DEBUG
NSLog("Nothing needs to be cleaned, skipping")
#endif
}
} catch {
#if DEBUG
NSLog("Error during files cleanup, skipping")
#endif
}
}

Expand All @@ -121,7 +135,9 @@ class FileStorage {
}

private func openNewLogsFile() throws {
#if DEBUG
NSLog("Opening new logs file")
#endif
let newLogsFileName = getNextFileName()
self.currentlyUsedFileName = newLogsFileName
self.currentLogsFile = try self.logsDirectory.createFile(named: newLogsFileName)
Expand Down
2 changes: 2 additions & 0 deletions Logsene/Classes/Worker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ class Worker: NSObject {
for source in batch {
documents.append((source: String(jsonObject: source)!, type: type))
}
#if DEBUG
NSLog("Attempting to send bulk data to logsene")
#endif
return attemptExecute(BulkIndex(documents: documents), attempts: 3)
}

Expand Down

0 comments on commit 879622b

Please sign in to comment.