Skip to content

Commit

Permalink
Adding App Center Logging Destination
Browse files Browse the repository at this point in the history
  • Loading branch information
brennerryan-okta committed May 12, 2021
1 parent 615a241 commit 901a6fc
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 16 deletions.
11 changes: 10 additions & 1 deletion OktaLogger.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "OktaLogger"
s.version = "1.1.2"
s.version = "1.2.0"
s.summary = "Logging proxy for standardized logging interface across products"
s.description = "Standard interface for all logging in Okta apps + SDK. Supports file, console, firebase logging destinations."
s.homepage = "https://github.com/okta/okta-logger-swift"
Expand All @@ -22,6 +22,7 @@ Pod::Spec.new do |s|

s.subspec "MacOS" do |macos|
macos.dependency 'OktaLogger/FileLogger'
macos.dependency 'OktaLogger/AppCenterLogger'
end

s.subspec 'FileLogger' do |fileLogger|
Expand All @@ -40,6 +41,14 @@ Pod::Spec.new do |s|
crashlytics.dependency 'OktaLogger/Core'
end

s.subspec 'AppCenterLogger' do |appCenterLogger|
appCenterLogger.source_files = [
'OktaLogger/AppCenterLogger/*'
]
appCenterLogger.dependency 'AppCenter', '~>4.1.1'
appCenterLogger.dependency 'OktaLogger/Core'
end

s.subspec "Core" do |core|
core.source_files = 'OktaLogger/*.{h,m,swift}'
core.exclude_files = [
Expand Down
20 changes: 16 additions & 4 deletions OktaLogger.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
804F18F724C0174800894A52 /* OktaLoggerFileLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 804F18F624C0174800894A52 /* OktaLoggerFileLoggerTests.swift */; };
806FF25E24B95A3300994D4D /* OktaLoggerFileLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 806FF25D24B95A3300994D4D /* OktaLoggerFileLogger.swift */; };
80AA110224BE799800981074 /* DemoTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80AA110124BE799800981074 /* DemoTableViewCell.swift */; };
8DCF5F682644B25D008698CD /* AppCenterLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DCF5F672644B25D008698CD /* AppCenterLogger.swift */; };
B3E071E3B33C4657A8B4381B /* libPods-OktaLogger.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 62BB891524DBDEF8FC8E9711 /* libPods-OktaLogger.a */; };
C4AA0759EDAC342A3B6B6796 /* libPods-OktaLoggerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4FFB48B8C0D4F4DD1D258FFD /* libPods-OktaLoggerTests.a */; };
D52C2AD12474A4F5003CCF4D /* ReadWriteLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = D52C2AD02474A4F5003CCF4D /* ReadWriteLock.swift */; };
Expand All @@ -26,11 +27,11 @@
D5C824E32469DBF1005CF747 /* OktaLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5C824E22469DBF1005CF747 /* OktaLoggerTests.swift */; };
D5C824E52469DBF1005CF747 /* OktaLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = D5C824D72469DBF1005CF747 /* OktaLogger.h */; settings = {ATTRIBUTES = (Public, ); }; };
D5D0978E246DE00800C1362F /* OktaLoggerConsoleLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5D0978D246DE00800C1362F /* OktaLoggerConsoleLoggerTests.swift */; };
DE1A7B3925EFF432007A5F60 /* LoggerDemoViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1A7B3825EFF432007A5F60 /* LoggerDemoViewModel.swift */; };
DE2FFE21260B89650028CAD6 /* OktaLoggerFileLoggerMultithreadingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE2FFE20260B89650028CAD6 /* OktaLoggerFileLoggerMultithreadingTests.swift */; };
DE504DC425BEE84A00B27BDD /* OktaLoggerFileLogFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE504DC325BEE84A00B27BDD /* OktaLoggerFileLogFormatter.swift */; };
DEABAFC9260C7C0100DB7008 /* FileTestsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEABAFC8260C7C0100DB7008 /* FileTestsHelper.swift */; };
DE1A7B3925EFF432007A5F60 /* LoggerDemoViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1A7B3825EFF432007A5F60 /* LoggerDemoViewModel.swift */; };
DE6A163725F1120100B0FBA0 /* LogsBrowseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6A163625F1120100B0FBA0 /* LogsBrowseViewController.swift */; };
DEABAFC9260C7C0100DB7008 /* FileTestsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEABAFC8260C7C0100DB7008 /* FileTestsHelper.swift */; };
DEC5276624DBF9630022B698 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = DEC5276524DBF9630022B698 /* GoogleService-Info.plist */; };
DEF2CC23260A341300F8B644 /* OktaLoggerMultithreadingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEF2CC22260A341300F8B644 /* OktaLoggerMultithreadingTests.swift */; };
DEFB59E124EAC76400A1744F /* OktaLoggerFirebaseCrashlyticsLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEFB59E024EAC76300A1744F /* OktaLoggerFirebaseCrashlyticsLogger.swift */; };
Expand Down Expand Up @@ -101,6 +102,7 @@
806FF25D24B95A3300994D4D /* OktaLoggerFileLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OktaLoggerFileLogger.swift; sourceTree = "<group>"; };
80AA110124BE799800981074 /* DemoTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoTableViewCell.swift; sourceTree = "<group>"; };
80DDE79324B972FC00D0E2F3 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
8DCF5F672644B25D008698CD /* AppCenterLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppCenterLogger.swift; sourceTree = "<group>"; };
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>"; };
D52C2AD02474A4F5003CCF4D /* ReadWriteLock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadWriteLock.swift; sourceTree = "<group>"; };
D54461C02469FFBA00C755F1 /* OktaLoggerLogLevel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OktaLoggerLogLevel.swift; sourceTree = "<group>"; };
Expand All @@ -119,11 +121,11 @@
D5C824E42469DBF1005CF747 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D5D0978D246DE00800C1362F /* OktaLoggerConsoleLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OktaLoggerConsoleLoggerTests.swift; sourceTree = "<group>"; };
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>"; };
DE1A7B3825EFF432007A5F60 /* LoggerDemoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggerDemoViewModel.swift; sourceTree = "<group>"; };
DE2FFE20260B89650028CAD6 /* OktaLoggerFileLoggerMultithreadingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OktaLoggerFileLoggerMultithreadingTests.swift; sourceTree = "<group>"; };
DE504DC325BEE84A00B27BDD /* OktaLoggerFileLogFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OktaLoggerFileLogFormatter.swift; sourceTree = "<group>"; };
DEABAFC8260C7C0100DB7008 /* FileTestsHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileTestsHelper.swift; sourceTree = "<group>"; };
DE1A7B3825EFF432007A5F60 /* LoggerDemoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggerDemoViewModel.swift; sourceTree = "<group>"; };
DE6A163625F1120100B0FBA0 /* LogsBrowseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogsBrowseViewController.swift; sourceTree = "<group>"; };
DEABAFC8260C7C0100DB7008 /* FileTestsHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileTestsHelper.swift; sourceTree = "<group>"; };
DEC5276524DBF9630022B698 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
DEF2CC22260A341300F8B644 /* OktaLoggerMultithreadingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OktaLoggerMultithreadingTests.swift; sourceTree = "<group>"; };
DEFB59E024EAC76300A1744F /* OktaLoggerFirebaseCrashlyticsLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OktaLoggerFirebaseCrashlyticsLogger.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -180,6 +182,14 @@
path = FileLoggers;
sourceTree = "<group>";
};
8DCF5F662644B23F008698CD /* AppCenterLogger */ = {
isa = PBXGroup;
children = (
8DCF5F672644B25D008698CD /* AppCenterLogger.swift */,
);
path = AppCenterLogger;
sourceTree = "<group>";
};
9200B49349EABD23B114BB0F /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -218,6 +228,7 @@
D5C824D62469DBF1005CF747 /* OktaLogger */ = {
isa = PBXGroup;
children = (
8DCF5F662644B23F008698CD /* AppCenterLogger */,
8004832F24C1F0F0008BFF3A /* FileLoggers */,
DEFB59DF24EAC76300A1744F /* FirebaseCrashlyticsLogger */,
D5C824D72469DBF1005CF747 /* OktaLogger.h */,
Expand Down Expand Up @@ -557,6 +568,7 @@
D54461C3246A023000C755F1 /* OktaLogger.swift in Sources */,
D54461CB246B55A600C755F1 /* OktaLoggerDestination.swift in Sources */,
8004832E24C1EFDF008BFF3A /* OktaLoggerFileLoggerConfig.swift in Sources */,
8DCF5F682644B25D008698CD /* AppCenterLogger.swift in Sources */,
806FF25E24B95A3300994D4D /* OktaLoggerFileLogger.swift in Sources */,
D52C2AD12474A4F5003CCF4D /* ReadWriteLock.swift in Sources */,
6582A2024047A1BC55BC98D3 /* LumberjackLoggerDelegate.swift in Sources */,
Expand Down
28 changes: 28 additions & 0 deletions OktaLogger/AppCenterLogger/AppCenterLogger.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Created by Brenner Ryan on 5/11/21.
// Copyright (c) 2021 Okta, Inc. All rights reserved.
//

import AppCenterAnalytics

/**
Concrete logging class for App Center events.
*/
class AppCenterLogger: OktaLoggerDestinationBase {
override open func log(level: OktaLoggerLogLevel, eventName: String, message: String?, properties: [AnyHashable: Any]?, file: String, line: NSNumber, funcName: String) {
switch level {
case .error:
guard let propertiesStrings = properties as? [String: String] else {
Analytics.trackEvent(eventName)
return
}
Analytics.trackEvent(eventName, withProperties: propertiesStrings, flags: .critical)
default:
guard let propertiesStrings = properties as? [String: String] else {
Analytics.trackEvent(eventName)
return
}
Analytics.trackEvent(eventName, withProperties: propertiesStrings)
}
}
}
1 change: 1 addition & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ platform :ios, '11.0'
use_modular_headers!

target 'OktaLogger' do
pod 'AppCenter', '~>4.1.1'
pod 'Firebase/Crashlytics', '~>7.4.0'
pod 'CocoaLumberjack/Swift', '~>3.6.0'
end
Expand Down
32 changes: 21 additions & 11 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
PODS:
- AppCenter (4.1.1):
- AppCenter/Analytics (= 4.1.1)
- AppCenter/Crashes (= 4.1.1)
- AppCenter/Analytics (4.1.1):
- AppCenter/Core
- AppCenter/Core (4.1.1)
- AppCenter/Crashes (4.1.1):
- AppCenter/Core
- CocoaLumberjack/Core (3.6.2)
- CocoaLumberjack/Swift (3.6.2):
- CocoaLumberjack/Core
Expand Down Expand Up @@ -40,36 +48,36 @@ PODS:
- nanopb/encode (= 2.30907.0)
- nanopb/decode (2.30907.0)
- nanopb/encode (2.30907.0)
- OktaLogger (1.1.2):
- OktaLogger/Complete (= 1.1.2)
- OktaLogger (1.2.0):
- OktaLogger/Complete (= 1.2.0)
- SwiftLint
- OktaLogger/Complete (1.1.2):
- OktaLogger/Complete (1.2.0):
- OktaLogger/FileLogger
- OktaLogger/FirebaseCrashlytics
- SwiftLint
- OktaLogger/Core (1.1.2):
- OktaLogger/Core (1.2.0):
- SwiftLint
- OktaLogger/FileLogger (1.1.2):
- OktaLogger/FileLogger (1.2.0):
- CocoaLumberjack/Swift (~> 3.6.0)
- OktaLogger/Core
- SwiftLint
- OktaLogger/FirebaseCrashlytics (1.1.2):
- OktaLogger/FirebaseCrashlytics (1.2.0):
- Firebase/Crashlytics (~> 7.4.0)
- OktaLogger/Core
- SwiftLint
- PromisesObjC (1.2.12)
- SwiftLint (0.39.2)

DEPENDENCIES:
- AppCenter (~> 4.1.1)
- CocoaLumberjack/Swift (~> 3.6.0)
- Firebase/Crashlytics (~> 7.4.0)
- OktaLogger (from `.`)

SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
- CocoaLumberjack
- SwiftLint
trunk:
- AppCenter
- CocoaLumberjack
- Firebase
- FirebaseCore
- FirebaseCoreDiagnostics
Expand All @@ -79,12 +87,14 @@ SPEC REPOS:
- GoogleUtilities
- nanopb
- PromisesObjC
- SwiftLint

EXTERNAL SOURCES:
OktaLogger:
:path: "."

SPEC CHECKSUMS:
AppCenter: cd53e3ed3563cc720bcb806c9731a12389b40d44
CocoaLumberjack: bd155f2dd06c0e0b03f876f7a3ee55693122ec94
Firebase: 09fb40287b6dfc8ee65f726fa0b788719d3f2a07
FirebaseCore: 99c06e5a1e8d6952e75cb1f0a6d0b23c0f5ccdcf
Expand All @@ -94,10 +104,10 @@ SPEC CHECKSUMS:
GoogleDataTransport: 1024b1a4dfbd7a0e92cb20d7e0a6f1fb66b449a4
GoogleUtilities: 31c5b01f978a70c6cff2afc6272b3f1921614b43
nanopb: 59221d7f958fb711001e6a449489542d92ae113e
OktaLogger: f8f1c20b9af20dd30e5c5e0136cf6108046a0e5c
OktaLogger: b79c52418ce9bfb3e695597fba5545931a75ef35
PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97
SwiftLint: 22ccbbe3b8008684be5955693bab135e0ed6a447

PODFILE CHECKSUM: 56d87b5cb773d85ba14abcf465af02c04739eccb
PODFILE CHECKSUM: 0d62d957d380013c75e13aeb32bd0c568a713007

COCOAPODS: 1.10.1
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Destination is an entity which perform log operation according to its implementa
1. [Console (OktaLoggerConsoleLogger)](#console-destination)
2. [File (OktaLoggerFileLogger)](#file-destination)
3. [Firebase (OktaLoggerFirebaseCrashlyticsLogger)](#firebase-crashlytics-destination)
4. [AppCenter (AppCenterLogger)](#app-center-destination)

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

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

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

### App Center destination

Related class -
[AppCenterLogger]
(OktaLogger/AppCenterLogger/AppCenterLogger.swift).
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.
There are a few important features and restrictions in this destination:

- 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).
- Logs with 'error' levels are sent as critical events to App Center [event flags](https://docs.microsoft.com/en-us/appcenter/sdk/analytics/macos)
- 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

This destination is using [App Center SDK](https://github.com/microsoft/appcenter-sdk-apple) for logging implementation

### Custom destinations

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`.
Expand Down

0 comments on commit 901a6fc

Please sign in to comment.