Skip to content

Commit b876a92

Browse files
Adding App Center Logging Destination
1 parent 615a241 commit b876a92

File tree

6 files changed

+93
-17
lines changed

6 files changed

+93
-17
lines changed

OktaLogger.podspec

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "OktaLogger"
3-
s.version = "1.1.2"
3+
s.version = "1.2.0"
44
s.summary = "Logging proxy for standardized logging interface across products"
55
s.description = "Standard interface for all logging in Okta apps + SDK. Supports file, console, firebase logging destinations."
66
s.homepage = "https://github.com/okta/okta-logger-swift"
@@ -22,6 +22,7 @@ Pod::Spec.new do |s|
2222

2323
s.subspec "MacOS" do |macos|
2424
macos.dependency 'OktaLogger/FileLogger'
25+
macos.dependency 'OktaLogger/AppCenterLogger'
2526
end
2627

2728
s.subspec 'FileLogger' do |fileLogger|
@@ -40,12 +41,21 @@ Pod::Spec.new do |s|
4041
crashlytics.dependency 'OktaLogger/Core'
4142
end
4243

44+
s.subspec 'AppCenterLogger' do |appCenterLogger|
45+
appCenterLogger.source_files = [
46+
'OktaLogger/AppCenterLogger/*'
47+
]
48+
appCenterLogger.dependency 'AppCenter', '~>4.1.1'
49+
appCenterLogger.dependency 'OktaLogger/Core'
50+
end
51+
4352
s.subspec "Core" do |core|
4453
core.source_files = 'OktaLogger/*.{h,m,swift}'
4554
core.exclude_files = [
4655
'OktaLogger/Info.plist',
4756
'OktaLogger/FileLoggers',
48-
'OktaLogger/FirebaseCrashlyticsLogger'
57+
'OktaLogger/FirebaseCrashlyticsLogger',
58+
'OktaLogger/AppCenterLogger'
4959
]
5060
end
5161

OktaLogger.xcodeproj/project.pbxproj

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
804F18F724C0174800894A52 /* OktaLoggerFileLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 804F18F624C0174800894A52 /* OktaLoggerFileLoggerTests.swift */; };
1414
806FF25E24B95A3300994D4D /* OktaLoggerFileLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 806FF25D24B95A3300994D4D /* OktaLoggerFileLogger.swift */; };
1515
80AA110224BE799800981074 /* DemoTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80AA110124BE799800981074 /* DemoTableViewCell.swift */; };
16+
8DCF5F682644B25D008698CD /* AppCenterLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DCF5F672644B25D008698CD /* AppCenterLogger.swift */; };
1617
B3E071E3B33C4657A8B4381B /* libPods-OktaLogger.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 62BB891524DBDEF8FC8E9711 /* libPods-OktaLogger.a */; };
1718
C4AA0759EDAC342A3B6B6796 /* libPods-OktaLoggerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4FFB48B8C0D4F4DD1D258FFD /* libPods-OktaLoggerTests.a */; };
1819
D52C2AD12474A4F5003CCF4D /* ReadWriteLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = D52C2AD02474A4F5003CCF4D /* ReadWriteLock.swift */; };
@@ -26,11 +27,11 @@
2627
D5C824E32469DBF1005CF747 /* OktaLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5C824E22469DBF1005CF747 /* OktaLoggerTests.swift */; };
2728
D5C824E52469DBF1005CF747 /* OktaLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = D5C824D72469DBF1005CF747 /* OktaLogger.h */; settings = {ATTRIBUTES = (Public, ); }; };
2829
D5D0978E246DE00800C1362F /* OktaLoggerConsoleLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5D0978D246DE00800C1362F /* OktaLoggerConsoleLoggerTests.swift */; };
30+
DE1A7B3925EFF432007A5F60 /* LoggerDemoViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1A7B3825EFF432007A5F60 /* LoggerDemoViewModel.swift */; };
2931
DE2FFE21260B89650028CAD6 /* OktaLoggerFileLoggerMultithreadingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE2FFE20260B89650028CAD6 /* OktaLoggerFileLoggerMultithreadingTests.swift */; };
3032
DE504DC425BEE84A00B27BDD /* OktaLoggerFileLogFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE504DC325BEE84A00B27BDD /* OktaLoggerFileLogFormatter.swift */; };
31-
DEABAFC9260C7C0100DB7008 /* FileTestsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEABAFC8260C7C0100DB7008 /* FileTestsHelper.swift */; };
32-
DE1A7B3925EFF432007A5F60 /* LoggerDemoViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1A7B3825EFF432007A5F60 /* LoggerDemoViewModel.swift */; };
3333
DE6A163725F1120100B0FBA0 /* LogsBrowseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6A163625F1120100B0FBA0 /* LogsBrowseViewController.swift */; };
34+
DEABAFC9260C7C0100DB7008 /* FileTestsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEABAFC8260C7C0100DB7008 /* FileTestsHelper.swift */; };
3435
DEC5276624DBF9630022B698 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = DEC5276524DBF9630022B698 /* GoogleService-Info.plist */; };
3536
DEF2CC23260A341300F8B644 /* OktaLoggerMultithreadingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEF2CC22260A341300F8B644 /* OktaLoggerMultithreadingTests.swift */; };
3637
DEFB59E124EAC76400A1744F /* OktaLoggerFirebaseCrashlyticsLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEFB59E024EAC76300A1744F /* OktaLoggerFirebaseCrashlyticsLogger.swift */; };
@@ -101,6 +102,7 @@
101102
806FF25D24B95A3300994D4D /* OktaLoggerFileLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OktaLoggerFileLogger.swift; sourceTree = "<group>"; };
102103
80AA110124BE799800981074 /* DemoTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoTableViewCell.swift; sourceTree = "<group>"; };
103104
80DDE79324B972FC00D0E2F3 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
105+
8DCF5F672644B25D008698CD /* AppCenterLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppCenterLogger.swift; sourceTree = "<group>"; };
104106
C58A9E54B6CE1A902894264C /* Pods-OktaLoggerDemoApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OktaLoggerDemoApp.debug.xcconfig"; path = "Target Support Files/Pods-OktaLoggerDemoApp/Pods-OktaLoggerDemoApp.debug.xcconfig"; sourceTree = "<group>"; };
105107
D52C2AD02474A4F5003CCF4D /* ReadWriteLock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadWriteLock.swift; sourceTree = "<group>"; };
106108
D54461C02469FFBA00C755F1 /* OktaLoggerLogLevel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OktaLoggerLogLevel.swift; sourceTree = "<group>"; };
@@ -119,11 +121,11 @@
119121
D5C824E42469DBF1005CF747 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
120122
D5D0978D246DE00800C1362F /* OktaLoggerConsoleLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OktaLoggerConsoleLoggerTests.swift; sourceTree = "<group>"; };
121123
DB510C00105E7489E2C16BA3 /* Pods-OktaLoggerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OktaLoggerTests.debug.xcconfig"; path = "Target Support Files/Pods-OktaLoggerTests/Pods-OktaLoggerTests.debug.xcconfig"; sourceTree = "<group>"; };
124+
DE1A7B3825EFF432007A5F60 /* LoggerDemoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggerDemoViewModel.swift; sourceTree = "<group>"; };
122125
DE2FFE20260B89650028CAD6 /* OktaLoggerFileLoggerMultithreadingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OktaLoggerFileLoggerMultithreadingTests.swift; sourceTree = "<group>"; };
123126
DE504DC325BEE84A00B27BDD /* OktaLoggerFileLogFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OktaLoggerFileLogFormatter.swift; sourceTree = "<group>"; };
124-
DEABAFC8260C7C0100DB7008 /* FileTestsHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileTestsHelper.swift; sourceTree = "<group>"; };
125-
DE1A7B3825EFF432007A5F60 /* LoggerDemoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggerDemoViewModel.swift; sourceTree = "<group>"; };
126127
DE6A163625F1120100B0FBA0 /* LogsBrowseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogsBrowseViewController.swift; sourceTree = "<group>"; };
128+
DEABAFC8260C7C0100DB7008 /* FileTestsHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileTestsHelper.swift; sourceTree = "<group>"; };
127129
DEC5276524DBF9630022B698 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
128130
DEF2CC22260A341300F8B644 /* OktaLoggerMultithreadingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OktaLoggerMultithreadingTests.swift; sourceTree = "<group>"; };
129131
DEFB59E024EAC76300A1744F /* OktaLoggerFirebaseCrashlyticsLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OktaLoggerFirebaseCrashlyticsLogger.swift; sourceTree = "<group>"; };
@@ -180,6 +182,14 @@
180182
path = FileLoggers;
181183
sourceTree = "<group>";
182184
};
185+
8DCF5F662644B23F008698CD /* AppCenterLogger */ = {
186+
isa = PBXGroup;
187+
children = (
188+
8DCF5F672644B25D008698CD /* AppCenterLogger.swift */,
189+
);
190+
path = AppCenterLogger;
191+
sourceTree = "<group>";
192+
};
183193
9200B49349EABD23B114BB0F /* Frameworks */ = {
184194
isa = PBXGroup;
185195
children = (
@@ -218,6 +228,7 @@
218228
D5C824D62469DBF1005CF747 /* OktaLogger */ = {
219229
isa = PBXGroup;
220230
children = (
231+
8DCF5F662644B23F008698CD /* AppCenterLogger */,
221232
8004832F24C1F0F0008BFF3A /* FileLoggers */,
222233
DEFB59DF24EAC76300A1744F /* FirebaseCrashlyticsLogger */,
223234
D5C824D72469DBF1005CF747 /* OktaLogger.h */,
@@ -557,6 +568,7 @@
557568
D54461C3246A023000C755F1 /* OktaLogger.swift in Sources */,
558569
D54461CB246B55A600C755F1 /* OktaLoggerDestination.swift in Sources */,
559570
8004832E24C1EFDF008BFF3A /* OktaLoggerFileLoggerConfig.swift in Sources */,
571+
8DCF5F682644B25D008698CD /* AppCenterLogger.swift in Sources */,
560572
806FF25E24B95A3300994D4D /* OktaLoggerFileLogger.swift in Sources */,
561573
D52C2AD12474A4F5003CCF4D /* ReadWriteLock.swift in Sources */,
562574
6582A2024047A1BC55BC98D3 /* LumberjackLoggerDelegate.swift in Sources */,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Created by Brenner Ryan on 5/11/21.
3+
// Copyright (c) 2021 Okta, Inc. All rights reserved.
4+
//
5+
6+
import AppCenterAnalytics
7+
8+
/**
9+
Concrete logging class for App Center events.
10+
*/
11+
class AppCenterLogger: OktaLoggerDestinationBase {
12+
override open func log(level: OktaLoggerLogLevel, eventName: String, message: String?, properties: [AnyHashable: Any]?, file: String, line: NSNumber, funcName: String) {
13+
switch level {
14+
case .error:
15+
guard let propertiesStrings = properties as? [String: String] else {
16+
Analytics.trackEvent(eventName)
17+
return
18+
}
19+
Analytics.trackEvent(eventName, withProperties: propertiesStrings, flags: .critical)
20+
default:
21+
guard let propertiesStrings = properties as? [String: String] else {
22+
Analytics.trackEvent(eventName)
23+
return
24+
}
25+
Analytics.trackEvent(eventName, withProperties: propertiesStrings)
26+
}
27+
}
28+
}

Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ platform :ios, '11.0'
22
use_modular_headers!
33

44
target 'OktaLogger' do
5+
pod 'AppCenter', '~>4.1.1'
56
pod 'Firebase/Crashlytics', '~>7.4.0'
67
pod 'CocoaLumberjack/Swift', '~>3.6.0'
78
end

Podfile.lock

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
PODS:
2+
- AppCenter (4.1.1):
3+
- AppCenter/Analytics (= 4.1.1)
4+
- AppCenter/Crashes (= 4.1.1)
5+
- AppCenter/Analytics (4.1.1):
6+
- AppCenter/Core
7+
- AppCenter/Core (4.1.1)
8+
- AppCenter/Crashes (4.1.1):
9+
- AppCenter/Core
210
- CocoaLumberjack/Core (3.6.2)
311
- CocoaLumberjack/Swift (3.6.2):
412
- CocoaLumberjack/Core
@@ -40,36 +48,36 @@ PODS:
4048
- nanopb/encode (= 2.30907.0)
4149
- nanopb/decode (2.30907.0)
4250
- nanopb/encode (2.30907.0)
43-
- OktaLogger (1.1.2):
44-
- OktaLogger/Complete (= 1.1.2)
51+
- OktaLogger (1.2.0):
52+
- OktaLogger/Complete (= 1.2.0)
4553
- SwiftLint
46-
- OktaLogger/Complete (1.1.2):
54+
- OktaLogger/Complete (1.2.0):
4755
- OktaLogger/FileLogger
4856
- OktaLogger/FirebaseCrashlytics
4957
- SwiftLint
50-
- OktaLogger/Core (1.1.2):
58+
- OktaLogger/Core (1.2.0):
5159
- SwiftLint
52-
- OktaLogger/FileLogger (1.1.2):
60+
- OktaLogger/FileLogger (1.2.0):
5361
- CocoaLumberjack/Swift (~> 3.6.0)
5462
- OktaLogger/Core
5563
- SwiftLint
56-
- OktaLogger/FirebaseCrashlytics (1.1.2):
64+
- OktaLogger/FirebaseCrashlytics (1.2.0):
5765
- Firebase/Crashlytics (~> 7.4.0)
5866
- OktaLogger/Core
5967
- SwiftLint
6068
- PromisesObjC (1.2.12)
6169
- SwiftLint (0.39.2)
6270

6371
DEPENDENCIES:
72+
- AppCenter (~> 4.1.1)
6473
- CocoaLumberjack/Swift (~> 3.6.0)
6574
- Firebase/Crashlytics (~> 7.4.0)
6675
- OktaLogger (from `.`)
6776

6877
SPEC REPOS:
69-
https://github.com/CocoaPods/Specs.git:
70-
- CocoaLumberjack
71-
- SwiftLint
7278
trunk:
79+
- AppCenter
80+
- CocoaLumberjack
7381
- Firebase
7482
- FirebaseCore
7583
- FirebaseCoreDiagnostics
@@ -79,12 +87,14 @@ SPEC REPOS:
7987
- GoogleUtilities
8088
- nanopb
8189
- PromisesObjC
90+
- SwiftLint
8291

8392
EXTERNAL SOURCES:
8493
OktaLogger:
8594
:path: "."
8695

8796
SPEC CHECKSUMS:
97+
AppCenter: cd53e3ed3563cc720bcb806c9731a12389b40d44
8898
CocoaLumberjack: bd155f2dd06c0e0b03f876f7a3ee55693122ec94
8999
Firebase: 09fb40287b6dfc8ee65f726fa0b788719d3f2a07
90100
FirebaseCore: 99c06e5a1e8d6952e75cb1f0a6d0b23c0f5ccdcf
@@ -94,10 +104,10 @@ SPEC CHECKSUMS:
94104
GoogleDataTransport: 1024b1a4dfbd7a0e92cb20d7e0a6f1fb66b449a4
95105
GoogleUtilities: 31c5b01f978a70c6cff2afc6272b3f1921614b43
96106
nanopb: 59221d7f958fb711001e6a449489542d92ae113e
97-
OktaLogger: f8f1c20b9af20dd30e5c5e0136cf6108046a0e5c
107+
OktaLogger: 88bee0372ff1edb302006057286fdeb6e78858b6
98108
PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97
99109
SwiftLint: 22ccbbe3b8008684be5955693bab135e0ed6a447
100110

101-
PODFILE CHECKSUM: 56d87b5cb773d85ba14abcf465af02c04739eccb
111+
PODFILE CHECKSUM: 0d62d957d380013c75e13aeb32bd0c568a713007
102112

103113
COCOAPODS: 1.10.1

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Destination is an entity which perform log operation according to its implementa
8787
1. [Console (OktaLoggerConsoleLogger)](#console-destination)
8888
2. [File (OktaLoggerFileLogger)](#file-destination)
8989
3. [Firebase (OktaLoggerFirebaseCrashlyticsLogger)](#firebase-crashlytics-destination)
90+
4. [AppCenter (AppCenterLogger)](#app-center-destination)
9091

9192
All of the default logging destinations are thread-safe and could be used from any thread.
9293

@@ -129,6 +130,20 @@ There are few important features and restrictions in this destination:
129130

130131
This destination is using [Firebase Crashlytics SDK](https://github.com/firebase/firebase-ios-sdk) for logging implementation.
131132

133+
### App Center destination
134+
135+
Related class -
136+
[AppCenterLogger]
137+
(OktaLogger/AppCenterLogger/AppCenterLogger.swift).
138+
This destination is using AppCenter SDK to send events, so they can be accessed from the App Center console. The only functionality supported by this destination is sending events to the App Center dashboard.
139+
There are a few important features and restrictions in this destination:
140+
141+
- Logger will not send events unless App Center is already configured in AppDelegate [setup App Center](https://docs.microsoft.com/en-us/appcenter/sdk/getting-started/macos).
142+
- Logs with 'error' levels are sent as critical events to App Center [event flags](https://docs.microsoft.com/en-us/appcenter/sdk/analytics/macos)
143+
- Log messages are ignored so they can be left as nil. The eventName parameter is the name of the event sent to App Center, and properties are sent as the properties of the event. Make sure that the properties are in [String: String] format or they may not be sent to App Center
144+
145+
This destination is using [App Center SDK](https://github.com/microsoft/appcenter-sdk-apple) for logging implementation
146+
132147
### Custom destinations
133148

134149
If you want to create your custom destination it is recommended to inherit it from `OktaLoggerDestinationBase` class, as this class implements some basic functionality. Hovewer, the only requirement for destinations is to conform to `OktaLoggerDestinationProtocol`.

0 commit comments

Comments
 (0)