mirror of
https://github.com/carey314/mio-plugin-fund.git
synced 2026-08-10 05:44:31 +00:00
Real-time OTC fund and gold tracker for the macOS notch. Three tabs: - 持仓: live intraday estimates from 天天基金, hero card with total value / today P&L / cumulative P&L, per-row 当日 + 累计. - 黄金: SHFE 沪金 realtime + daily K-line + 伦敦金 reference. - 添加: search 26k+ public funds via 东方财富 suggest API. No API keys, no Python, no servers. All data comes from public endpoints (天天基金, 东方财富, 新浪财经). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
42 lines
1.4 KiB
Swift
42 lines
1.4 KiB
Swift
//
|
|
// FundDebugLog.swift
|
|
// 看盘侠 plugin
|
|
//
|
|
// Plugin-bundle NSLog calls don't reliably surface in `log show` from
|
|
// the host process — they get filtered, deduped, or eaten by the
|
|
// subsystem. This helper writes timestamped lines to a known file so
|
|
// we can `tail -f` it during debugging without guessing log filters.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
enum FundDebugLog {
|
|
static let path = "/tmp/fund-plugin.log"
|
|
private static let queue = DispatchQueue(label: "fund.debug.log")
|
|
private static let dateFmt: DateFormatter = {
|
|
let f = DateFormatter()
|
|
f.locale = Locale(identifier: "en_US_POSIX")
|
|
f.timeZone = TimeZone.current
|
|
f.dateFormat = "HH:mm:ss.SSS"
|
|
return f
|
|
}()
|
|
|
|
static func write(_ message: String) {
|
|
let stamp = dateFmt.string(from: Date())
|
|
let line = "[\(stamp)] \(message)\n"
|
|
queue.async {
|
|
if let data = line.data(using: .utf8) {
|
|
if FileManager.default.fileExists(atPath: path) {
|
|
if let handle = try? FileHandle(forWritingTo: URL(fileURLWithPath: path)) {
|
|
try? handle.seekToEnd()
|
|
try? handle.write(contentsOf: data)
|
|
try? handle.close()
|
|
}
|
|
} else {
|
|
try? data.write(to: URL(fileURLWithPath: path))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|