Skip to content
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

Replace uses of #file with #fileID #322

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Change Log

* **Version 7.0.1**: *(2020/02/04)* - Updated for Xcode 11.3.1, adds in missing convenience methods for notice, alert, and emergency (thanks @hk05)
* **Version 7.0.0**: *(2019/03/26)* - Updated for Xcode 10.2/Swift 5.0, adds additional log levels: notice, alert, and emergency
* **Version 6.1.0**: *(2018/09/16)* - Fix for Xcode 10.0 warnings/Swift 4.2, other minor tweaks
* **Version 6.0.4**: *(2018/06/11)* - Fix for Xcode 9.3 warnings/Swift 4.1 (thanks @ijaureguialzo), and other fixes
Expand Down
4 changes: 2 additions & 2 deletions DemoApps/iOSDemo/iOSDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 7.0.0;
CURRENT_PROJECT_VERSION = 7.0.1;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -761,7 +761,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 7.0.0;
CURRENT_PROJECT_VERSION = 7.0.1;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down
156 changes: 120 additions & 36 deletions DemoApps/iOSDemo/iOSDemo/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

49 changes: 47 additions & 2 deletions DemoApps/iOSDemo/iOSDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ class ViewController: UIViewController {
}
}

@IBAction func noticeButtonTouchUpInside(_ sender: AnyObject) {
log.notice("Notice button tapped")
log.notice {
// add expensive code required only for logging, then return an optional String
return "Executed notice code block" // or nil
}
}

@IBAction func warningButtonTouchUpInside(_ sender: AnyObject) {
log.warning("Warning button tapped")
log.warning {
Expand All @@ -73,6 +81,22 @@ class ViewController: UIViewController {
}
}

@IBAction func alertButtonTouchUpInside(_ sender: AnyObject) {
log.alert("Alert button tapped")
log.alert {
// add expensive code required only for logging, then return an optional String
return "Executed alert code block" // or nil
}
}

@IBAction func emergencyButtonTouchUpInside(_ sender: AnyObject) {
log.emergency("Emergency button tapped")
log.emergency {
// add expensive code required only for logging, then return an optional String
return "Executed emergency code block" // or nil
}
}

@IBAction func verboseSensitiveButtonTouchUpInside(_ sender: AnyObject) {
// Can add multiple Dev/Tag objects together using the | operator
log.verbose("Verbose (Sensitive) button tapped", userInfo: Dev.dave | Tag.sensitive)
Expand All @@ -87,6 +111,10 @@ class ViewController: UIViewController {
log.info("Info (Sensitive) button tapped", userInfo: Dev.dave | Tag.sensitive | Tag("informative"))
}

@IBAction func noticeSensitiveButtonTouchUpInside(_ sender: AnyObject) {
log.notice("Notice (Sensitive) button tapped", userInfo: Dev.dave | Tag.sensitive)
}

@IBAction func warningSensitiveButtonTouchUpInside(_ sender: AnyObject) {
// Can add a bunch of Dev/Tag objects
log.warning("Warning (Sensitive) button tapped", userInfo: Dev.sabby | Dev.dave | Tag.sensitive | Tag.ui)
Expand All @@ -104,6 +132,14 @@ class ViewController: UIViewController {
log.severe("Severe (Sensitive) button tapped", userInfo: Tag.sensitive.dictionary)
}

@IBAction func alertSensitiveButtonTouchUpInside(_ sender: AnyObject) {
log.alert("Alert (Sensitive) button tapped", userInfo: Dev.dave | Tag.sensitive)
}

@IBAction func emergencySensitiveButtonTouchUpInside(_ sender: AnyObject) {
log.emergency("Emergency (Sensitive) button tapped", userInfo: Dev.dave | Tag.sensitive)
}

@IBAction func logLevelSliderValueChanged(_ sender: AnyObject) {
var logLevel: XCGLogger.Level = .verbose

Expand All @@ -117,14 +153,23 @@ class ViewController: UIViewController {
logLevel = .info
}
else if (3 <= logLevelSlider.value && logLevelSlider.value < 4) {
logLevel = .warning
logLevel = .notice
}
else if (4 <= logLevelSlider.value && logLevelSlider.value < 5) {
logLevel = .error
logLevel = .warning
}
else if (5 <= logLevelSlider.value && logLevelSlider.value < 6) {
logLevel = .error
}
else if (6 <= logLevelSlider.value && logLevelSlider.value < 7) {
logLevel = .severe
}
else if (7 <= logLevelSlider.value && logLevelSlider.value < 8) {
logLevel = .alert
}
else if (8 <= logLevelSlider.value && logLevelSlider.value < 9) {
logLevel = .emergency
}
else {
logLevel = .none
}
Expand Down
12 changes: 12 additions & 0 deletions DemoApps/iOSDemo/watchOSDemo Extension/InterfaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class InterfaceController: WKInterfaceController {
log.info("Info tapped on the Watch")
}

@IBAction func noticeButtonTapped(_ sender: WKInterfaceButton) {
log.notice("Notice tapped on the Watch")
}

@IBAction func warningButtonTapped(_ sender: WKInterfaceButton) {
log.warning("Warning tapped on the Watch")
}
Expand All @@ -68,4 +72,12 @@ class InterfaceController: WKInterfaceController {
@IBAction func severeButtonTapped(_ sender: WKInterfaceButton) {
log.severe("Severe tapped on the Watch")
}

@IBAction func alertButtonTapped(_ sender: WKInterfaceButton) {
log.alert("Alert tapped on the Watch")
}

@IBAction func emergencyButtonTapped(_ sender: WKInterfaceButton) {
log.emergency("Emergency tapped on the Watch")
}
}
25 changes: 19 additions & 6 deletions DemoApps/iOSDemo/watchOSDemo/Base.lproj/Interface.storyboard
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="14490.70" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
<device id="watch38" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="15705" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
<device id="watch38"/>
<dependencies>
<deployment identifier="watchOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="14490.21"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="15501"/>
</dependencies>
<scenes>
<!--Interface Controller-->
Expand All @@ -31,6 +29,11 @@
<action selector="infoButtonTapped:" destination="AgC-eL-Hgc" id="2Ml-zm-XCX"/>
</connections>
</button>
<button width="1" alignment="left" title="Notice" id="YJQ-W7-897">
<connections>
<action selector="noticeButtonTapped:" destination="AgC-eL-Hgc" id="9zs-fL-oQQ"/>
</connections>
</button>
<button width="1" alignment="left" title="Warning" id="VeQ-ne-yJl">
<connections>
<action selector="warningButtonTapped:" destination="AgC-eL-Hgc" id="YaW-Af-kfI"/>
Expand All @@ -46,6 +49,16 @@
<action selector="severeButtonTapped:" destination="AgC-eL-Hgc" id="BqP-U9-gpq"/>
</connections>
</button>
<button width="1" alignment="left" title="Alert" id="VYx-3P-oet">
<connections>
<action selector="alertButtonTapped:" destination="AgC-eL-Hgc" id="I39-m2-cZY"/>
</connections>
</button>
<button width="1" alignment="left" title="Emergency" id="o6Q-75-9zu">
<connections>
<action selector="emergencyButtonTapped:" destination="AgC-eL-Hgc" id="5Gg-My-IZ4"/>
</connections>
</button>
</items>
</group>
</items>
Expand Down
9 changes: 4 additions & 5 deletions DemoApps/macOSDemo/macOSDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1130;
ORGANIZATIONNAME = "Cerebral Gardens";
TargetAttributes = {
555FFCAC19D77B1800F62246 = {
Expand All @@ -298,10 +298,9 @@
};
buildConfigurationList = 555FFCA819D77B1800F62246 /* Build configuration list for PBXProject "macOSDemo" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -497,7 +496,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 7.0.0;
CURRENT_PROJECT_VERSION = 7.0.1;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -554,7 +553,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 7.0.0;
CURRENT_PROJECT_VERSION = 7.0.1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -41,6 +41,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "555FFCAC19D77B1800F62246"
BuildableName = "macOSDemo.app"
BlueprintName = "macOSDemo"
ReferencedContainer = "container:macOSDemo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -53,17 +62,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "555FFCAC19D77B1800F62246"
BuildableName = "macOSDemo.app"
BlueprintName = "macOSDemo"
ReferencedContainer = "container:macOSDemo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -85,8 +83,6 @@
ReferencedContainer = "container:macOSDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
49 changes: 42 additions & 7 deletions DemoApps/macOSDemo/macOSDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

@IBAction func noticeButtonTouchUpInside(_ sender: AnyObject) {
log.notice("Notice button tapped")
log.notice {
// add expensive code required only for logging, then return an optional String
return "Executed notice code block" // or nil
}
}

@IBAction func warningButtonTouchUpInside(_ sender: AnyObject) {
log.warning("Warning button tapped")
log.warning {
Expand All @@ -150,14 +158,32 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

@IBAction func rotateLogFileButtonTouchUpInside(_ sender: AnyObject) {
if let fileDestination = log.destination(withIdentifier: "advancedLogger.fileDestination") as? FileDestination {
@IBAction func alertButtonTouchUpInside(_ sender: AnyObject) {
log.alert("Alert button tapped")
log.alert {
// add expensive code required only for logging, then return an optional String
return "Executed alert code block" // or nil
}
}

let dateHash: String = dateHashFormatter.string(from: Date())
let archiveFilePath: String = ("~/Desktop/XCGLogger_Log_\(dateHash).txt" as NSString).expandingTildeInPath
@IBAction func emergencyButtonTouchUpInside(_ sender: AnyObject) {
log.emergency("Emergency button tapped")
log.emergency {
// add expensive code required only for logging, then return an optional String
return "Executed emergency code block" // or nil
}
}

fileDestination.rotateFile(to: archiveFilePath)
@IBAction func rotateLogFileButtonTouchUpInside(_ sender: AnyObject) {
guard let fileDestination = log.destination(withIdentifier: "advancedLogger.fileDestination") as? FileDestination else {
log.error("File destination not found, unable to rotate the log")
return
}

let dateHash: String = dateHashFormatter.string(from: Date())
let archiveFilePath: String = ("~/Desktop/XCGLogger_Log_\(dateHash).txt" as NSString).expandingTildeInPath

fileDestination.rotateFile(to: archiveFilePath)
}

@IBAction func logLevelSliderValueChanged(_ sender: AnyObject) {
Expand All @@ -173,14 +199,23 @@ class AppDelegate: NSObject, NSApplicationDelegate {
logLevel = .info
}
else if (3 <= logLevelSlider.floatValue && logLevelSlider.floatValue < 4) {
logLevel = .warning
logLevel = .notice
}
else if (4 <= logLevelSlider.floatValue && logLevelSlider.floatValue < 5) {
logLevel = .error
logLevel = .warning
}
else if (5 <= logLevelSlider.floatValue && logLevelSlider.floatValue < 6) {
logLevel = .error
}
else if (6 <= logLevelSlider.floatValue && logLevelSlider.floatValue < 7) {
logLevel = .severe
}
else if (7 <= logLevelSlider.floatValue && logLevelSlider.floatValue < 8) {
logLevel = .alert
}
else if (8 <= logLevelSlider.floatValue && logLevelSlider.floatValue < 9) {
logLevel = .emergency
}
else {
logLevel = .none
}
Expand Down
Loading