-
Notifications
You must be signed in to change notification settings - Fork 58
adding config class to swift wrappers #1141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2d3b890
adding config class
absaroj 768132e
adding comment
absaroj a0be17d
correcting the cmake min version
absaroj b767ff1
adding checks for libs being linked in cmake
absaroj 7626e98
correcting comments and args
absaroj 5c94a60
changing filename
absaroj 71d739b
Merge branch 'absaroj/add_config' of https://github.com/microsoft/cpp…
absaroj 289abd9
removing comment
absaroj 248f057
Merge branch 'main' into absaroj/add_config
ThomsonTan c039ef9
correcting the use of optional in swift wrapper
absaroj 94e1b4d
marking class final
absaroj 49c64e2
Merge branch 'main' into absaroj/add_config
absaroj 47cc3ad
taking merge from main
absaroj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,53 @@ | ||
| ####################################################################################################### | ||
| # Generates project files for Swift wrapper files and generates executable based on the main.swift file. | ||
| # | ||
| # Dependecies: | ||
| # Please build Obj-c dependencies required by Swift by running | ||
| # ./build.sh clean release | ||
| # in the source folder to generate the required Obj-C library. It should be installed at /usr/local/lib | ||
| ####################################################################################################### | ||
|
|
||
| CMAKE_MINIMUM_REQUIRED(VERSION 3.15) | ||
|
|
||
| PROJECT(Swift_Wrapper) | ||
|
|
||
| message("${CMAKE_CURRENT_SOURCE_DIR}") | ||
|
|
||
| enable_language(Swift) | ||
|
|
||
| # TODO: add logic to build dependencies | ||
| # Set flags and paths | ||
| set(CMAKE_CXX_STANDARD 11) | ||
| set(CMAKE_Swift_FLAGS "${CMAKE_Swift_FLAGS} -import-objc-header Swift_Wrapper-Bridging-Header.h") | ||
| set(INSTALLED_LIB_PATH "/usr/local/lib") | ||
|
|
||
| # Add system libs | ||
| find_library(SYSTEM_CONFIGURATION SystemConfiguration) | ||
| find_package(ZLIB REQUIRED) | ||
| find_library(NETWORK_FRAMEWORK Network) | ||
|
|
||
| include_directories( | ||
| ../../lib/include/public/ | ||
| ../../lib/include/mat/ | ||
| ) | ||
| # Add libmat.a library which has Obj-C dependencies built needed by Swift | ||
| find_library(MAT_LIB libmat.a PATHS ${INSTALLED_LIB_PATH}) | ||
| find_library(SQLITE3_LIB libsqlite3.a PATH ${INSTALLED_LIB_PATH}) | ||
absaroj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if(NOT SQLITE3_LIB) | ||
| set(SQLITE3_LIB "sqlite3") | ||
| endif() | ||
|
|
||
| if(NOT MAT_LIB) | ||
| message(FATAL_ERROR, "libmat.a not found at /usr/local/lib. Please run ./build.sh at root and install libmat.a.") | ||
| endif() | ||
|
|
||
| get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) | ||
| foreach(dir ${dirs}) | ||
| message(STATUS "dir='${dir}'") | ||
| endforeach() | ||
|
|
||
| # Add source files to the target | ||
| set(PLATFORM_FILES main.swift SDWEventProperties.swift) | ||
| set(CMAKE_Swift_FLAGS "${CMAKE_Swift_FLAGS} -import-objc-header Swift_Wrapper-Bridging-Header.h") | ||
| add_executable(swift_sample ${PLATFORM_FILES}) | ||
| target_link_libraries(swift_sample) | ||
| file(GLOB SWIFT_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.swift") | ||
| add_executable(swift_sample ${SWIFT_FILES}) | ||
|
|
||
| target_link_libraries(swift_sample | ||
absaroj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ${MAT_LIB} | ||
| ${SYSTEM_CONFIGURATION} | ||
| ${SQLITE3_LIB} | ||
| stdc++ | ||
| ZLIB::ZLIB | ||
| ${NETWORK_FRAMEWORK}) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,214 @@ | ||
| // | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| /// Class wrapping `ODWLogConfiguration` ObjC class object, representing configuration related to events. | ||
| public final class LogConfiguration { | ||
| private var odwLogConfiguration: ODWLogConfiguration | ||
|
|
||
| /** | ||
| Constructs `self` with provided config as `ODWLogConfiguration` object. | ||
|
|
||
| - Parameters: | ||
| - config: `ODWLogConfiguration` object which would be wrapped to. | ||
| */ | ||
| public init(config: ODWLogConfiguration) { | ||
absaroj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| self.odwLogConfiguration = config | ||
| } | ||
|
|
||
| /// Return a copy of the default configuration | ||
| public static func getLogConfigurationCopy() -> LogConfiguration? { | ||
absaroj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if let odwLogConfiguration = ODWLogConfiguration.getCopy() { | ||
| return LogConfiguration(config: odwLogConfiguration) | ||
| } else { | ||
| return nil | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| Sets the "URI" of the event collector. | ||
|
|
||
| - Parameters: | ||
| - collectorUri: `String` for event collector uri. | ||
| */ | ||
| public static func setEventCollectorUri(_ collectorUri: String) { | ||
| ODWLogConfiguration.setEventCollectorUri(collectorUri) | ||
| } | ||
|
|
||
| /// Returns a `String` containing "URI" of the event collector. | ||
| public static func eventCollectorUri() -> String? { | ||
| return ODWLogConfiguration.eventCollectorUri(); | ||
| } | ||
|
|
||
| /** | ||
| Sets the RAM queue size limit in bytes. | ||
|
|
||
| - Parameters: | ||
| - sizeInBytes: A `Long` value for memory size limit in bytes. | ||
| */ | ||
| public static func setCacheMemorySizeLimitInBytes(_ sizeInBytes: UInt64) { | ||
absaroj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ODWLogConfiguration.setCacheMemorySizeLimitInBytes(sizeInBytes) | ||
| } | ||
|
|
||
| /// Returns the RAM queue size as `Long` value having limit in bytes. | ||
| public static func cacheMemorySizeLimitInBytes() -> UInt64 { | ||
| return ODWLogConfiguration.cacheMemorySizeLimitInBytes() | ||
| } | ||
|
|
||
| /** | ||
| Sets the size limit of the disk file used to cache events on the client side. | ||
|
|
||
| - Parameters: | ||
| - sizeInBytes: A `Long` value for cache file size limit. | ||
| */ | ||
| public static func setCacheFileSizeLimitInBytes(_ sizeInBytes: UInt64) { | ||
| ODWLogConfiguration.setCacheFileSizeLimitInBytes(sizeInBytes) | ||
| } | ||
|
|
||
| /// Returns the size limit of the disk file as a `Long` used to cache events on the client side. | ||
| public static func cacheFileSizeLimitInBytes() -> UInt64 { | ||
| return ODWLogConfiguration.cacheFileSizeLimitInBytes() | ||
| } | ||
|
|
||
| /** | ||
| Sets max teardown upload time in seconds. | ||
|
|
||
| - Parameters: | ||
| - timeInSecs: An `Integer` that represents time in seconds. | ||
| */ | ||
| public static func setMaxTeardownUploadTimeInSec(_ timeInSecs: Int32) { | ||
| ODWLogConfiguration.setMaxTeardownUploadTimeInSec(timeInSecs) | ||
| } | ||
|
|
||
| /** | ||
| Sets if trace logging to file is enabled. | ||
|
|
||
| - Parameters: | ||
| - trace: `True` if tracing should be enabled, `False` otherwise. | ||
| */ | ||
| public static func setEnableTrace(_ trace: Bool) { | ||
| ODWLogConfiguration.setEnableTrace(trace) | ||
| } | ||
|
|
||
| /** | ||
| Sets if console logging from the iOS wrapper is enabled. | ||
|
|
||
| - Parameters: | ||
| - enableLogging: `True` if logging is enabled, `False` otherwise. | ||
| */ | ||
| public static func setEnableConsoleLogging(_ enableLogging: Bool) { | ||
| ODWLogConfiguration.setEnableConsoleLogging(enableLogging) | ||
| } | ||
|
|
||
| /** | ||
| Sets the internal SDK debugging trace level. | ||
|
|
||
| - Parameters: | ||
| - traceLevel: one of the `ACTTraceLevel` values. | ||
| */ | ||
| public static func setTraceLevel(_ traceLevel: Int32) { | ||
| ODWLogConfiguration.setTraceLevel(traceLevel) | ||
| } | ||
|
|
||
| /// Returns `True` if tracing is enabled, `False` otherwise. | ||
| public static func enableTrace() -> Bool { | ||
| return ODWLogConfiguration.enableTrace() | ||
| } | ||
|
|
||
| /// Returns `True` if console logging is enabled, `False` otherwise. | ||
| public static func enableConsoleLogging() -> Bool { | ||
| return ODWLogConfiguration.enableConsoleLogging() | ||
| } | ||
|
|
||
| /** | ||
| Sets if inner exceptions should be surface to Wrapper consumers. | ||
|
|
||
| - Parameters: | ||
| - surfaceObjCExcecptions: `True` if C++ exceptions should be surfaced, `False` otherwise. | ||
| */ | ||
| public static func setSurfaceCppExceptions(_ surfaceExceptions: Bool) { | ||
| ODWLogConfiguration.setSurfaceCppExceptions(surfaceExceptions) | ||
| } | ||
|
|
||
| /// Returns `True` if inner C++ exceptions are surfaced to Wrapper consumers, `False` otherwise. | ||
| public static func surfaceCppExceptions() -> Bool { | ||
| return ODWLogConfiguration.surfaceCppExceptions() | ||
| } | ||
|
|
||
| /** | ||
| Sets if session timestamp should be reset after a session ends. | ||
|
|
||
| - Parameters: | ||
| - enableSessionReset: `True` if session should be reset on session end, `False` otherwise. | ||
| */ | ||
| public static func setEnableSessionReset(_ sessionReset: Bool) { | ||
| ODWLogConfiguration.setEnableSessionReset(sessionReset) | ||
| } | ||
|
|
||
| /// Returns `True` if session will be reset on session end, `False` otherwise. | ||
| public static func enableSessionReset() -> Bool { | ||
| return ODWLogConfiguration.enableSessionReset() | ||
| } | ||
|
|
||
| /** | ||
| Set cache file path. | ||
|
|
||
| - Parameters: | ||
| - cacheFilePath: A `String` for the cache path. | ||
| */ | ||
| public static func setCacheFilePath(_ cacheFilePath: String) { | ||
| ODWLogConfiguration.setCacheFilePath(cacheFilePath) | ||
| } | ||
|
|
||
| /// Returns the cache file path as a `String`. | ||
| public static func cacheFilePath() -> String? { | ||
| return ODWLogConfiguration.cacheFilePath() | ||
| } | ||
|
|
||
| /** | ||
| Controls if DB will be checkpointed when flushing. | ||
|
|
||
| - Parameters: | ||
| - enableDBCheckpointOnFlush: `True` if DB should be checkpointed when flushing. | ||
| */ | ||
| public static func setEnableDBCheckpointOnFlush(_ enableDBCheckpointOnFlush: Bool) { | ||
| ODWLogConfiguration.setEnableDbCheckpointOnFlush(enableDBCheckpointOnFlush) | ||
| } | ||
|
|
||
| /// Returns `True` if DB will checkpointed when flushing, `False` otherwise. | ||
| public static func enableDBCheckpointOnFlush() -> Bool { | ||
| return ODWLogConfiguration.enableDbCheckpointOnFlush() | ||
| } | ||
|
|
||
| /** | ||
| Sets a config key to a string value for the copied config. | ||
|
|
||
| - Parameters: | ||
| - key: A key as a `String`. | ||
| - value: A value as a `String`. | ||
| */ | ||
| public func set(_ key: String, havingValue value: String) { | ||
| self.odwLogConfiguration.set(key, withValue: value) | ||
| } | ||
|
|
||
| /// Returns the value as `String` for the given `String` key. | ||
| public func value(forKey key: String) -> String? { | ||
| return self.odwLogConfiguration.value(forKey: key) | ||
| } | ||
|
|
||
| /** | ||
| Sets the host value. | ||
|
|
||
| - Parameters: | ||
| - host: A host value as `String`. | ||
| */ | ||
| public func setHost(_ host: String) { | ||
| self.odwLogConfiguration.setHost(host) | ||
| } | ||
|
|
||
| /// Returns the host value as `String`. | ||
| public func host() -> String? { | ||
| return self.odwLogConfiguration.host() | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.