 	private var sessionsBeingRestored: [WorkspaceIdentifier: (NSWindow?, Error?) -> Void] = [:]
 	private var workspacesBeingOpened = Set<WorkspaceIdentifier>()
 	private var logConfig: Rc2LogConfig?
+	private var logBuffer = NSTextStorage()
 
 	fileprivate let _statusQueue = DispatchQueue(label: "io.rc2.statusQueue", qos: .userInitiated)
 

	private func initializeLogging() {
		let config = Rc2LogConfig()
		logConfig = config
		let tformatter = TokenizedLogFormatter(formatString: " (%level) (%category) (%date) [(%function):(%file):(%line)] (%message)", dateFormatter: config.dateFormatter)
		let logger = StdErrLogger(config: config, formatter: tformatter)
		config.categoryLevels[.session] = .debug
		config.categoryLevels[.app] = .debug
		Log.enableLogging(logger)

	let dateFormatter: DateFormatterProtocol
	var categoryLevels = [LogCategory: LogLevel]()
	var globalLevel: LogLevel = .warn
	let levelDescriptions: [LogLevel: NSAttributedString]
	init() {
		let dformatter = DateFormatter()
		dformatter.locale = Locale(identifier: "en_US_POSIX")
		dformatter.dateFormat = "HH:mm:ss.SSS"
		dateFormatter = dformatter
		levelDescriptions = [.debug: NSAttributedString(string: "🐞")]
	}
	
	func loggingEnabled(level: LogLevel, category: LogCategory) -> Bool {
		if let catLevel = categoryLevels[category] { return level <= catLevel }
		return level <= globalLevel
	}

	func description(logLevel: LogLevel) -> NSAttributedString {
		if let desc = levelDescriptions[logLevel] { return desc }
		return NSAttributedString(string: logLevel.description)
	}
	
}

