Skip to content

Commit

Permalink
Added TB prefix to logging classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoronin committed Sep 9, 2023
1 parent 0c99581 commit d4a8003
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion TomatoBar/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct TBApp: App {
init() {
TBStatusItem.shared = appDelegate
LaunchAtLogin.migrateIfNeeded()
logger.append(event: LogEventAppStart())
logger.append(event: TBLogEventAppStart())
}

var body: some Scene {
Expand Down
12 changes: 6 additions & 6 deletions TomatoBar/Log.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import Foundation
import SwiftUI

protocol LogEvent: Encodable {
protocol TBLogEvent: Encodable {
var type: String { get }
var timestamp: Date { get }
}

class LogEventAppStart: LogEvent {
class TBLogEventAppStart: TBLogEvent {
internal let type = "appstart"
internal let timestamp: Date = Date()
}

class LogEventTransition: LogEvent {
class TBLogEventTransition: TBLogEvent {
internal let type = "transition"
internal let timestamp: Date = Date()

Expand All @@ -29,9 +29,9 @@ class LogEventTransition: LogEvent {
private let logFileName = "TomatoBar.log"
private let lineEnd = "\n".data(using: .utf8)!

internal let logger = Logger()
internal let logger = TBLogger()

class Logger {
class TBLogger {
private let logHandle: FileHandle?
private let encoder = JSONEncoder()

Expand Down Expand Up @@ -61,7 +61,7 @@ class Logger {
}
}

func append(event: LogEvent) {
func append(event: TBLogEvent) {
guard let logHandle = logHandle else {
return
}
Expand Down
2 changes: 1 addition & 1 deletion TomatoBar/Timer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class TBTimer: ObservableObject {
stateMachine.addAnyHandler(.rest => .work, handler: onRestFinish)
stateMachine.addAnyHandler(.any => .idle, handler: onIdleStart)
stateMachine.addAnyHandler(.any => .any, handler: { ctx in
logger.append(event: LogEventTransition(fromContext: ctx))
logger.append(event: TBLogEventTransition(fromContext: ctx))
})

stateMachine.addErrorHandler { ctx in fatalError("state machine context: <\(ctx)>") }
Expand Down

0 comments on commit d4a8003

Please sign in to comment.