Add Logger and LogItem. Start work on log window.
This commit is contained in:
parent
0bc84aa50c
commit
7e2420700c
|
@ -310,6 +310,19 @@
|
|||
<constraint firstAttribute="width" constant="64" id="AmG-EL-4l7"/>
|
||||
</constraints>
|
||||
</progressIndicator>
|
||||
<popUpButton translatesAutoresizingMaskIntoConstraints="NO" id="cUf-Xf-7Zp">
|
||||
<rect key="frame" x="46" y="2" width="86" height="21"/>
|
||||
<popUpButtonCell key="cell" type="bevel" title="145 feeds" bezelStyle="rounded" alignment="center" lineBreakMode="truncatingTail" state="on" imageScaling="proportionallyDown" inset="2" selectedItem="0uo-gF-YhP" id="WnX-IX-51j">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<menu key="menu" id="tCE-z0-Fkp">
|
||||
<items>
|
||||
<menuItem title="145 feeds" state="on" id="0uo-gF-YhP"/>
|
||||
<menuItem title="Refreshed 11:05 am" id="vPN-Sq-MoK"/>
|
||||
</items>
|
||||
</menu>
|
||||
</popUpButtonCell>
|
||||
</popUpButton>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="NOS-H9-Mdl" firstAttribute="centerY" secondItem="FWz-dC-55q" secondAttribute="centerY" priority="999" id="0NZ-ry-RwE"/>
|
||||
|
@ -317,11 +330,14 @@
|
|||
<constraint firstItem="Vq0-Di-DO2" firstAttribute="centerY" secondItem="FWz-dC-55q" secondAttribute="centerY" id="2sf-bK-T3N"/>
|
||||
<constraint firstItem="kVh-DT-vkQ" firstAttribute="centerY" secondItem="FWz-dC-55q" secondAttribute="centerY" id="4h2-eA-vEm"/>
|
||||
<constraint firstAttribute="height" constant="25" id="5Xu-xj-rhU"/>
|
||||
<constraint firstItem="cUf-Xf-7Zp" firstAttribute="baseline" secondItem="k7g-zd-q4Q" secondAttribute="baseline" constant="1" id="Ji3-U0-5n0"/>
|
||||
<constraint firstItem="NOS-H9-Mdl" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Vq0-Di-DO2" secondAttribute="trailing" constant="8" id="Kdn-fY-Pg0"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="cUf-Xf-7Zp" secondAttribute="trailing" constant="20" symbolic="YES" id="OQx-lz-gfC"/>
|
||||
<constraint firstItem="k7g-zd-q4Q" firstAttribute="leading" secondItem="FWz-dC-55q" secondAttribute="leading" constant="2" id="WyI-Mr-ysi"/>
|
||||
<constraint firstItem="kVh-DT-vkQ" firstAttribute="leading" secondItem="k7g-zd-q4Q" secondAttribute="trailing" constant="8" id="g6B-We-Dqz"/>
|
||||
<constraint firstItem="Vq0-Di-DO2" firstAttribute="leading" secondItem="kVh-DT-vkQ" secondAttribute="trailing" constant="8" id="pcT-32-3jd"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="NOS-H9-Mdl" secondAttribute="trailing" constant="8" id="twV-E5-yKX"/>
|
||||
<constraint firstItem="cUf-Xf-7Zp" firstAttribute="leading" secondItem="k7g-zd-q4Q" secondAttribute="trailing" constant="2" id="u3B-PO-OMH"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<outlet property="progressIndicator" destination="kVh-DT-vkQ" id="xDW-pX-IcH"/>
|
||||
|
|
|
@ -96,6 +96,12 @@
|
|||
84B99C9A1FAE650100ECDEDB /* OPMLRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C991FAE650100ECDEDB /* OPMLRepresentable.swift */; };
|
||||
84B99C9B1FAE650100ECDEDB /* OPMLRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C991FAE650100ECDEDB /* OPMLRepresentable.swift */; };
|
||||
84BB45431D6909C700B48537 /* NSMutableDictionary-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84BB45421D6909C700B48537 /* NSMutableDictionary-Extensions.swift */; };
|
||||
84C687301FBAA30800345C9E /* LogWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84C6872F1FBAA30800345C9E /* LogWindow.xib */; };
|
||||
84C687321FBAA3DF00345C9E /* LogWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C687311FBAA3DF00345C9E /* LogWindowController.swift */; };
|
||||
84C687351FBC025600345C9E /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C687341FBC025600345C9E /* Logger.swift */; };
|
||||
84C687361FBC025600345C9E /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C687341FBC025600345C9E /* Logger.swift */; };
|
||||
84C687381FBC028900345C9E /* LogItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C687371FBC028900345C9E /* LogItem.swift */; };
|
||||
84C687391FBC028900345C9E /* LogItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C687371FBC028900345C9E /* LogItem.swift */; };
|
||||
84CFF4FA1AC3C69700CEA6C8 /* RSCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 84CFF4F91AC3C69700CEA6C8 /* RSCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
84CFF5001AC3C69700CEA6C8 /* RSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84CFF4F41AC3C69700CEA6C8 /* RSCore.framework */; };
|
||||
84CFF5071AC3C69700CEA6C8 /* RSCoreTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CFF5061AC3C69700CEA6C8 /* RSCoreTests.m */; };
|
||||
|
@ -198,6 +204,10 @@
|
|||
84B99C931FAE64D400ECDEDB /* DisplayNameProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DisplayNameProvider.swift; path = RSCore/DisplayNameProvider.swift; sourceTree = "<group>"; };
|
||||
84B99C991FAE650100ECDEDB /* OPMLRepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OPMLRepresentable.swift; path = RSCore/OPMLRepresentable.swift; sourceTree = "<group>"; };
|
||||
84BB45421D6909C700B48537 /* NSMutableDictionary-Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSMutableDictionary-Extensions.swift"; sourceTree = "<group>"; };
|
||||
84C6872F1FBAA30800345C9E /* LogWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = LogWindow.xib; path = AppKit/LogWindow.xib; sourceTree = "<group>"; };
|
||||
84C687311FBAA3DF00345C9E /* LogWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LogWindowController.swift; path = AppKit/LogWindowController.swift; sourceTree = "<group>"; };
|
||||
84C687341FBC025600345C9E /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
|
||||
84C687371FBC028900345C9E /* LogItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogItem.swift; sourceTree = "<group>"; };
|
||||
84CFF4F41AC3C69700CEA6C8 /* RSCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RSCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
84CFF4F81AC3C69700CEA6C8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = RSCore/Info.plist; sourceTree = "<group>"; };
|
||||
84CFF4F91AC3C69700CEA6C8 /* RSCore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RSCore.h; path = RSCore/RSCore.h; sourceTree = "<group>"; };
|
||||
|
@ -426,6 +436,10 @@
|
|||
8461387E1DB3F5BE00048B83 /* RSToolbarItem.swift */,
|
||||
8479213B1FBA426B004AD08C /* WebViewWindow.xib */,
|
||||
8479213D1FBA4285004AD08C /* WebViewWindowController.swift */,
|
||||
84C6872F1FBAA30800345C9E /* LogWindow.xib */,
|
||||
84C687311FBAA3DF00345C9E /* LogWindowController.swift */,
|
||||
84C687341FBC025600345C9E /* Logger.swift */,
|
||||
84C687371FBC028900345C9E /* LogItem.swift */,
|
||||
842DD7F91E1499FA00E061EB /* Views */,
|
||||
);
|
||||
name = AppKit;
|
||||
|
@ -632,6 +646,7 @@
|
|||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
84C687301FBAA30800345C9E /* LogWindow.xib in Resources */,
|
||||
8479213C1FBA426B004AD08C /* WebViewWindow.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -661,6 +676,7 @@
|
|||
842DD7F31E14996B00E061EB /* NSMutableDictionary-Extensions.swift in Sources */,
|
||||
842DD7DF1E14996300E061EB /* NSDictionary+RSCore.m in Sources */,
|
||||
842DD7C81E14995C00E061EB /* RSConstants.m in Sources */,
|
||||
84C687391FBC028900345C9E /* LogItem.swift in Sources */,
|
||||
842DD7D41E14995C00E061EB /* DiskSaver.swift in Sources */,
|
||||
842DD7E11E14996300E061EB /* NSFileManager+RSCore.m in Sources */,
|
||||
842DD7C61E14995C00E061EB /* RSBlocks.m in Sources */,
|
||||
|
@ -675,6 +691,7 @@
|
|||
842DD7EF1E14996300E061EB /* NSString+RSCore.m in Sources */,
|
||||
842DD7F21E14996B00E061EB /* Date+Extensions.swift in Sources */,
|
||||
842DD7ED1E14996300E061EB /* NSSet+RSCore.m in Sources */,
|
||||
84C687361FBC025600345C9E /* Logger.swift in Sources */,
|
||||
842DD7CA1E14995C00E061EB /* RSPlatform.m in Sources */,
|
||||
842DD7D91E14996300E061EB /* NSCalendar+RSCore.m in Sources */,
|
||||
842DD7F11E14996300E061EB /* NSTimer+RSCore.m in Sources */,
|
||||
|
@ -706,10 +723,13 @@
|
|||
84CFF5441AC3CD3500CEA6C8 /* NSNotificationCenter+RSCore.m in Sources */,
|
||||
84CFF55D1AC3D01F00CEA6C8 /* RSBackgroundColorView.m in Sources */,
|
||||
84CFF5131AC3C6D800CEA6C8 /* RSBlocks.m in Sources */,
|
||||
84C687321FBAA3DF00345C9E /* LogWindowController.swift in Sources */,
|
||||
84C687381FBC028900345C9E /* LogItem.swift in Sources */,
|
||||
8432B1861DACA0E90057D6DF /* NSResponder-Extensions.swift in Sources */,
|
||||
849B08981BF7BCE30090CEE4 /* NSPasteboard+RSCore.m in Sources */,
|
||||
842635571D7FA1C800196285 /* NSTableView+Extensions.swift in Sources */,
|
||||
84F20F831F16BA6200D8E682 /* PropertyList.swift in Sources */,
|
||||
84C687351FBC025600345C9E /* Logger.swift in Sources */,
|
||||
84CFF5611AC3D0CE00CEA6C8 /* RSBinaryCache.m in Sources */,
|
||||
84CFF5301AC3CB1900CEA6C8 /* NSDate+RSCore.m in Sources */,
|
||||
84CFF5281AC3C9A200CEA6C8 /* NSArray+RSCore.m in Sources */,
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13770" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13770"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="LogWindowController" customModule="RSCore" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="textView" destination="cG6-u8-uMj" id="KV1-Ym-Yn7"/>
|
||||
<outlet property="window" destination="QvC-M9-y7g" id="BuO-Xt-18T"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="457" y="982" width="480" height="270"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
|
||||
<value key="minSize" type="size" width="480" height="270"/>
|
||||
<value key="maxSize" type="size" width="2048" height="2048"/>
|
||||
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<scrollView borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qkQ-6Y-KmD">
|
||||
<rect key="frame" x="0.0" y="32" width="480" height="238"/>
|
||||
<clipView key="contentView" id="FKH-aI-1be">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="238"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textView importsGraphics="NO" verticallyResizable="YES" usesFontPanel="YES" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" quoteSubstitution="YES" dashSubstitution="YES" spellingCorrection="YES" smartInsertDelete="YES" id="cG6-u8-uMj">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="238"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<size key="minSize" width="480" height="238"/>
|
||||
<size key="maxSize" width="481" height="10000000"/>
|
||||
<color key="insertionPointColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</textView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</clipView>
|
||||
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="Vod-9Z-5Kc">
|
||||
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="QCg-T8-ydO">
|
||||
<rect key="frame" x="464" y="0.0" width="16" height="238"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="quV-wb-dTF">
|
||||
<rect key="frame" x="284" y="3" width="84" height="25"/>
|
||||
<buttonCell key="cell" type="roundTextured" title="Clear" bezelStyle="texturedRounded" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="luW-96-yKD">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="clearContents:" target="-2" id="cZR-Ic-VD0"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Eeo-dn-vtp">
|
||||
<rect key="frame" x="376" y="3" width="84" height="25"/>
|
||||
<buttonCell key="cell" type="roundTextured" title="Save to File" bezelStyle="texturedRounded" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="tTX-36-gJT">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="saveToFile:" target="-2" id="702-Lb-l3d"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="cUl-9V-D2b">
|
||||
<rect key="frame" x="173" y="127" width="134" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="This doesn’t work yet" id="Tuo-hs-CNa">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="Eeo-dn-vtp" secondAttribute="trailing" constant="20" symbolic="YES" id="2Ct-CF-MiD"/>
|
||||
<constraint firstAttribute="trailing" secondItem="qkQ-6Y-KmD" secondAttribute="trailing" id="3FZ-jN-K85"/>
|
||||
<constraint firstItem="cUl-9V-D2b" firstAttribute="centerY" secondItem="EiT-Mj-1SZ" secondAttribute="centerY" id="8Nw-Pj-sr0"/>
|
||||
<constraint firstItem="Eeo-dn-vtp" firstAttribute="baseline" secondItem="quV-wb-dTF" secondAttribute="baseline" id="8dT-ag-UwE"/>
|
||||
<constraint firstAttribute="bottom" secondItem="Eeo-dn-vtp" secondAttribute="bottom" constant="5" id="KIn-jy-T6Y"/>
|
||||
<constraint firstAttribute="bottom" secondItem="qkQ-6Y-KmD" secondAttribute="bottom" constant="32" id="NCo-rh-VJo"/>
|
||||
<constraint firstItem="qkQ-6Y-KmD" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" id="T57-rw-GIA"/>
|
||||
<constraint firstItem="Eeo-dn-vtp" firstAttribute="width" secondItem="quV-wb-dTF" secondAttribute="width" id="UVb-RA-1p3"/>
|
||||
<constraint firstItem="cUl-9V-D2b" firstAttribute="centerX" secondItem="EiT-Mj-1SZ" secondAttribute="centerX" id="W0v-k5-Ug2"/>
|
||||
<constraint firstItem="qkQ-6Y-KmD" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" id="lfP-xK-X0J"/>
|
||||
<constraint firstItem="Eeo-dn-vtp" firstAttribute="leading" secondItem="quV-wb-dTF" secondAttribute="trailing" constant="8" symbolic="YES" id="osp-9K-DSB"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<contentBorderThickness minY="32"/>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
|
@ -0,0 +1,62 @@
|
|||
//
|
||||
// LogWindowController.swift
|
||||
// RSCore
|
||||
//
|
||||
// Created by Brent Simmons on 11/13/17.
|
||||
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class LogWindowController: NSWindowController {
|
||||
|
||||
@IBOutlet private var textView: NSTextView!
|
||||
private var title: String!
|
||||
// private let attributes = [NSFont.Att
|
||||
public convenience init(title: String) {
|
||||
|
||||
self.init(windowNibName: NSNib.Name(rawValue: "LogWindow"))
|
||||
self.title = title
|
||||
}
|
||||
|
||||
override func windowDidLoad() {
|
||||
|
||||
window!.title = title
|
||||
}
|
||||
|
||||
public func appendLine(_ s: String) {
|
||||
|
||||
// Adds two line feeds before the text.
|
||||
|
||||
|
||||
}
|
||||
|
||||
public func setTextViewText(_ s: String) {
|
||||
|
||||
let attributedString = NSAttributedString(string: s)
|
||||
textView.textStorage?.setAttributedString(attributedString)
|
||||
|
||||
validateButtons()
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@IBAction func clearContents(_ sender: Any?) {
|
||||
|
||||
setTextViewText("")
|
||||
}
|
||||
|
||||
@IBAction func saveToFile(_ sender: Any?) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension LogWindowController {
|
||||
|
||||
func validateButtons() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// LogItem.swift
|
||||
// RSCore
|
||||
//
|
||||
// Created by Brent Simmons on 11/14/17.
|
||||
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct LogItem: Hashable {
|
||||
|
||||
public enum ItemType {
|
||||
case notification, warning, error
|
||||
}
|
||||
|
||||
public let type: ItemType
|
||||
public let message: String
|
||||
public let date: Date
|
||||
public let hashValue: Int
|
||||
|
||||
public init(type: ItemType, message: String) {
|
||||
|
||||
self.type = type
|
||||
self.message = message
|
||||
self.date = Date()
|
||||
self.hashValue = message.hashValue + self.date.hashValue
|
||||
}
|
||||
|
||||
static public func ==(lhs: LogItem, rhs: LogItem) -> Bool {
|
||||
|
||||
return lhs.type == rhs.type && lhs.message == rhs.message && lhs.date == rhs.date
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Logger.swift
|
||||
// RSCore
|
||||
//
|
||||
// Created by Brent Simmons on 11/14/17.
|
||||
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public class Logger {
|
||||
|
||||
var logItems = [LogItem]()
|
||||
|
||||
public func addLogItem(_ logItem: LogItem) {
|
||||
|
||||
logItems += [logItem]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue