Skip to content

Commit 088869a

Browse files
committed
Update README and properly pass configuration parameters
1 parent 113e524 commit 088869a

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Logsene/Classes/Core.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,17 @@ public class LogsLocation {
4040
- appToken: Your Logsene application token.
4141
- type: The Elasticsearch type to use for all events.
4242
- receiverUrl: The receiver url (optional).
43-
- maxOfflineMessages: The maximum number of messages (5,000 by default) stored while device is offline (optional).
43+
- maxOfflineFileSize: The maximum size of a single file used for offline storage (optional, 100000 by default).
44+
- maxOfflineFiles: The maximum number of files used for offline storage (optional, 10 by default).
4445
- automaticLocationEnriching: When set to true the library will automatically enrich log events with location of the user (optional, false by default).
4546
- useLocationOnlyInForeground: When set to true the location data will only be used when the application is in foreground (optional, true by default).
4647
*/
47-
public func LogseneInit(_ appToken: String, type: String, receiverUrl: String = "https://logsene-receiver.sematext.com", maxOfflineMessages: Int = 5000, automaticLocationEnriching: Bool = false, useLocationOnlyInForeground: Bool = true) throws {
48+
public func LogseneInit(_ appToken: String, type: String, receiverUrl: String = "https://logsene-receiver.sematext.com", maxOfflineFileSize: Int = 100000, maxOfflineFiles: Int = 10, automaticLocationEnriching: Bool = false, useLocationOnlyInForeground: Bool = true) throws {
4849
var maybeError: Error? = nil
4950
DispatchQueue.once(token: Logsene.onceToken) {
5051
let client = LogseneClient(receiverUrl: receiverUrl, appToken: appToken, configuration: URLSessionConfiguration.default)
5152
do {
52-
Logsene.worker = try Worker(client: client, type: type, maxOfflineMessages: maxOfflineMessages, automaticLocationEnriching: automaticLocationEnriching, useLocationOnlyInForeground: useLocationOnlyInForeground)
53+
Logsene.worker = try Worker(client: client, type: type, maxOfflineFileSize: maxOfflineFileSize, maxOfflineFiles: maxOfflineFiles, automaticLocationEnriching: automaticLocationEnriching, useLocationOnlyInForeground: useLocationOnlyInForeground)
5354
} catch (let err) {
5455
NSLog("Unable to initialize Logsene worker: \(err)")
5556
maybeError = err

Logsene/Classes/Worker.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class Worker: NSObject {
2828
fileprivate var locationManager: CLLocationManager? = nil
2929
#endif
3030

31-
init(client: LogseneClient, type: String, maxOfflineMessages: Int, automaticLocationEnriching: Bool, useLocationOnlyInForeground: Bool) throws {
31+
init(client: LogseneClient, type: String, maxOfflineFileSize: Int, maxOfflineFiles: Int, automaticLocationEnriching: Bool,
32+
useLocationOnlyInForeground: Bool) throws {
3233
serialQueue = DispatchQueue(label: "logworker_events", attributes: [])
3334
#if os(watchOS)
3435
#else
@@ -37,7 +38,7 @@ class Worker: NSObject {
3738

3839
// Setup buffer for storing messages before sending them to Logsene
3940
// This also acts as the offline buffer if device is not online
40-
preflightBuffer = try FileStorage(logsFilePath: "sematextLogsStorage", maxFileSize: 100000, maxNumberOfFiles: 10)
41+
preflightBuffer = try FileStorage(logsFilePath: "sematextLogsStorage", maxFileSize: maxOfflineFileSize, maxNumberOfFiles: maxOfflineFiles)
4142

4243
self.client = client
4344
self.type = type

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5858
}
5959
```
6060

61-
You can optionaly provide the `receiverUrl` parameter if you are using [Sematext Enterprise](https://sematext.com/enterprise), and `maxOfflineMessages` to configure how many messages are stored while device is offline (5,000 by default).
61+
Additional options are available:
62+
- the `receiverUrl` parameter allows specifying the data reciver if you are using our EU location or [Sematext Enterprise](https://sematext.com/enterprise)
63+
- the `automaticLocationEnriching` parameter enabled automatic enrichment of logs from the mobile application with location data
64+
- offline storage size can be configured by using the `maxOfflineFileSize` (100000 by default) and `maxOfflineFiles` (10 by default) parameters. The size of the offline storage will be equal to `maxOfflineFileSize` multiplied by `maxOfflineFiles`.
6265

6366
**Note**: We highly recommend creating a write-only token in your application settings for use in your mobile apps.
6467

0 commit comments

Comments
 (0)