Skip to content

Commit

Permalink
Rename LogData
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii committed Jan 12, 2019
1 parent 70511b4 commit 1935cdd
Show file tree
Hide file tree
Showing 22 changed files with 68 additions and 68 deletions.
20 changes: 10 additions & 10 deletions Bulk-Carthage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
4B7BFC681EBAE9F400CB9027 /* NoBuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B7BFC651EBAE9F400CB9027 /* NoBuffer.swift */; };
4B7BFC691EBAE9F400CB9027 /* NoBuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B7BFC651EBAE9F400CB9027 /* NoBuffer.swift */; };
4B80E7A31EB9F40700C9BE63 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_9 /* Logger.swift */; };
4B80E7A41EB9F40700C9BE63 /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35EF1EB9E8EB00B93628 /* Log.swift */; };
4B80E7A41EB9F40700C9BE63 /* LogData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35EF1EB9E8EB00B93628 /* LogData.swift */; };
4B80E7A51EB9F40700C9BE63 /* Pipeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35EB1EB9E58E00B93628 /* Pipeline.swift */; };
4B80E7A61EB9F40700C9BE63 /* AsyncPipeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35F11EB9EDC600B93628 /* AsyncPipeline.swift */; };
4B80E7A71EB9F40700C9BE63 /* Formatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35ED1EB9E72E00B93628 /* Formatter.swift */; };
Expand All @@ -50,7 +50,7 @@
4B80E7AA1EB9F40700C9BE63 /* FileTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35E51EB9ACD500B93628 /* FileTarget.swift */; };
4B80E7AB1EB9F40700C9BE63 /* Plugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35E71EB9ADA800B93628 /* Plugin.swift */; };
4B80E7AC1EB9F40700C9BE63 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_9 /* Logger.swift */; };
4B80E7AD1EB9F40700C9BE63 /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35EF1EB9E8EB00B93628 /* Log.swift */; };
4B80E7AD1EB9F40700C9BE63 /* LogData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35EF1EB9E8EB00B93628 /* LogData.swift */; };
4B80E7AE1EB9F40700C9BE63 /* Pipeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35EB1EB9E58E00B93628 /* Pipeline.swift */; };
4B80E7AF1EB9F40700C9BE63 /* AsyncPipeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35F11EB9EDC600B93628 /* AsyncPipeline.swift */; };
4B80E7B01EB9F40700C9BE63 /* Formatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35ED1EB9E72E00B93628 /* Formatter.swift */; };
Expand All @@ -59,7 +59,7 @@
4B80E7B31EB9F40700C9BE63 /* FileTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35E51EB9ACD500B93628 /* FileTarget.swift */; };
4B80E7B41EB9F40700C9BE63 /* Plugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35E71EB9ADA800B93628 /* Plugin.swift */; };
4B80E7B51EB9F40700C9BE63 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_9 /* Logger.swift */; };
4B80E7B61EB9F40700C9BE63 /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35EF1EB9E8EB00B93628 /* Log.swift */; };
4B80E7B61EB9F40700C9BE63 /* LogData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35EF1EB9E8EB00B93628 /* LogData.swift */; };
4B80E7B71EB9F40700C9BE63 /* Pipeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35EB1EB9E58E00B93628 /* Pipeline.swift */; };
4B80E7B81EB9F40700C9BE63 /* AsyncPipeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35F11EB9EDC600B93628 /* AsyncPipeline.swift */; };
4B80E7B91EB9F40700C9BE63 /* Formatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35ED1EB9E72E00B93628 /* Formatter.swift */; };
Expand Down Expand Up @@ -95,7 +95,7 @@
4BDA35E81EB9ADA800B93628 /* Plugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35E71EB9ADA800B93628 /* Plugin.swift */; };
4BDA35EC1EB9E58E00B93628 /* Pipeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35EB1EB9E58E00B93628 /* Pipeline.swift */; };
4BDA35EE1EB9E72E00B93628 /* Formatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35ED1EB9E72E00B93628 /* Formatter.swift */; };
4BDA35F01EB9E8EB00B93628 /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35EF1EB9E8EB00B93628 /* Log.swift */; };
4BDA35F01EB9E8EB00B93628 /* LogData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35EF1EB9E8EB00B93628 /* LogData.swift */; };
4BDA35F21EB9EDC600B93628 /* AsyncPipeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA35F11EB9EDC600B93628 /* AsyncPipeline.swift */; };
4BE5D6961EBE158200D1282F /* NSLogTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5D6951EBE158200D1282F /* NSLogTarget.swift */; };
4BE5D6971EBE158200D1282F /* NSLogTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5D6951EBE158200D1282F /* NSLogTarget.swift */; };
Expand Down Expand Up @@ -154,7 +154,7 @@
4BDA35E71EB9ADA800B93628 /* Plugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Plugin.swift; sourceTree = "<group>"; };
4BDA35EB1EB9E58E00B93628 /* Pipeline.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Pipeline.swift; sourceTree = "<group>"; };
4BDA35ED1EB9E72E00B93628 /* Formatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Formatter.swift; sourceTree = "<group>"; };
4BDA35EF1EB9E8EB00B93628 /* Log.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Log.swift; sourceTree = "<group>"; };
4BDA35EF1EB9E8EB00B93628 /* LogData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogData.swift; sourceTree = "<group>"; };
4BDA35F11EB9EDC600B93628 /* AsyncPipeline.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AsyncPipeline.swift; sourceTree = "<group>"; };
4BE5D6951EBE158200D1282F /* NSLogTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSLogTarget.swift; sourceTree = "<group>"; };
OBJ_11 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -232,7 +232,7 @@
4BDA35F11EB9EDC600B93628 /* AsyncPipeline.swift */,
4B7BFC561EBA50DA00CB9027 /* Buffer.swift */,
4BDA35ED1EB9E72E00B93628 /* Formatter.swift */,
4BDA35EF1EB9E8EB00B93628 /* Log.swift */,
4BDA35EF1EB9E8EB00B93628 /* LogData.swift */,
OBJ_9 /* Logger.swift */,
4BDA35EB1EB9E58E00B93628 /* Pipeline.swift */,
4BDA35E71EB9ADA800B93628 /* Plugin.swift */,
Expand Down Expand Up @@ -562,7 +562,7 @@
4B80E7A51EB9F40700C9BE63 /* Pipeline.swift in Sources */,
4B7BFC581EBA50DA00CB9027 /* Buffer.swift in Sources */,
4B80E7AA1EB9F40700C9BE63 /* FileTarget.swift in Sources */,
4B80E7A41EB9F40700C9BE63 /* Log.swift in Sources */,
4B80E7A41EB9F40700C9BE63 /* LogData.swift in Sources */,
4BC62ED71EBCC01600F68DFC /* AnyFormatter.swift in Sources */,
4B7BFC5D1EBA590200CB9027 /* MemoryBuffer.swift in Sources */,
4B1C721E1EBBA1B6008AA3FC /* Timer.swift in Sources */,
Expand Down Expand Up @@ -591,7 +591,7 @@
4B80E7AE1EB9F40700C9BE63 /* Pipeline.swift in Sources */,
4B7BFC591EBA50DA00CB9027 /* Buffer.swift in Sources */,
4B80E7B31EB9F40700C9BE63 /* FileTarget.swift in Sources */,
4B80E7AD1EB9F40700C9BE63 /* Log.swift in Sources */,
4B80E7AD1EB9F40700C9BE63 /* LogData.swift in Sources */,
4BC62ED81EBCC01600F68DFC /* AnyFormatter.swift in Sources */,
4B7BFC5E1EBA590200CB9027 /* MemoryBuffer.swift in Sources */,
4B1C721F1EBBA1B6008AA3FC /* Timer.swift in Sources */,
Expand Down Expand Up @@ -620,7 +620,7 @@
4B80E7B71EB9F40700C9BE63 /* Pipeline.swift in Sources */,
4B7BFC5A1EBA50DA00CB9027 /* Buffer.swift in Sources */,
4B80E7BC1EB9F40700C9BE63 /* FileTarget.swift in Sources */,
4B80E7B61EB9F40700C9BE63 /* Log.swift in Sources */,
4B80E7B61EB9F40700C9BE63 /* LogData.swift in Sources */,
4BC62ED91EBCC01600F68DFC /* AnyFormatter.swift in Sources */,
4B7BFC5F1EBA590200CB9027 /* MemoryBuffer.swift in Sources */,
4B1C72201EBBA1B6008AA3FC /* Timer.swift in Sources */,
Expand All @@ -639,7 +639,7 @@
files = (
4B6618831EBE1A350052F4A5 /* LogSerializer.swift in Sources */,
4BE5D6961EBE158200D1282F /* NSLogTarget.swift in Sources */,
4BDA35F01EB9E8EB00B93628 /* Log.swift in Sources */,
4BDA35F01EB9E8EB00B93628 /* LogData.swift in Sources */,
4B4DB98B1F9E174500B5E803 /* ContextLogger.swift in Sources */,
4B9FD1C01EBCDCA40012FEBF /* LevelFilterPlugin.swift in Sources */,
4BC62ED11EBCC00700F68DFC /* BasicFormatter.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bulk/Core/AsyncPipeline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class AsyncPipeline: Pipeline {
)
}

override func write(log: Log) {
override func write(log: LogData) {

queue.async(flags: .barrier) {
super.write(log: log)
Expand Down
6 changes: 3 additions & 3 deletions Sources/Bulk/Core/Buffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Foundation

public enum BufferResult {
case stored
case flowed([Log])
case flowed([LogData])
}

public protocol Buffer {
Expand All @@ -37,10 +37,10 @@ public protocol Buffer {
///
/// - Parameter string:
/// - Returns:
func write(log: Log) -> BufferResult
func write(log: LogData) -> BufferResult

/// Purge buffered items
///
/// - Returns: purged items
func purge() -> [Log]
func purge() -> [LogData]
}
2 changes: 1 addition & 1 deletion Sources/Bulk/Core/Formatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ public protocol Formatter {

associatedtype FormatType

func format(log: Log) -> FormatType
func format(log: LogData) -> FormatType
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import Foundation

public struct Log {
public struct LogData {

/// Logging Level
///
Expand All @@ -40,7 +40,7 @@ public struct Log {
case error
}

public var level: Log.Level
public var level: LogData.Level
public var date: Date
public var body: String
public var file: String
Expand Down
6 changes: 3 additions & 3 deletions Sources/Bulk/Core/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ public final class Logger {
// MARK: - Functions

@inline(__always)
func _write(level: Log.Level, _ items: [Any], file: StaticString = #file, function: StaticString = #function, line: UInt = #line) {
func _write(level: LogData.Level, _ items: [Any], file: StaticString = #file, function: StaticString = #function, line: UInt = #line) {

let now = Date()

let body = items.map { String(describing: $0) }.joined(separator: " ")

let log = Log(level: level, date: now, body: body, file: file.description, function: function.description, line: line, isActive: true)
let log = LogData(level: level, date: now, body: body, file: file.description, function: function.description, line: line, isActive: true)

pipelines.forEach { target in
target.write(log: log)
}
}

public func write(level: Log.Level, _ items: [Any], file: StaticString = #file, function: StaticString = #function, line: UInt = #line) {
public func write(level: LogData.Level, _ items: [Any], file: StaticString = #file, function: StaticString = #function, line: UInt = #line) {
_write(level: level, items, file: file, function: function, line: line)
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/Bulk/Core/Pipeline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class Pipeline {

public var isWritingTarget: Bool = false

private var writeProcess: (([Log]) -> Void)!
private var writeProcess: (([LogData]) -> Void)!

public init<F, T>(
plugins: [Plugin],
Expand Down Expand Up @@ -142,7 +142,7 @@ public class Pipeline {
__write(bulkBuffer.purge())
}

func write(log: Log) {
func write(log: LogData) {

lock.lock(); defer { lock.unlock() }

Expand All @@ -164,7 +164,7 @@ public class Pipeline {
}

@inline(__always)
private func __write(_ r: [Log]) {
private func __write(_ r: [LogData]) {
lock.lock(); defer { lock.unlock() }
timer?.tap()
writeProcess(r)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bulk/Core/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ import Foundation

public protocol Plugin {

func apply(log: Log) -> Log
func apply(log: LogData) -> LogData
}
6 changes: 3 additions & 3 deletions Sources/Bulk/Library/AnyFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import Foundation

public struct AnyFormatter: Formatter {

let format: (Log) -> String
let format: (LogData) -> String

public init(format: @escaping (Log) -> String) {
public init(format: @escaping (LogData) -> String) {
self.format = format
}

public func format(log: Log) -> String {
public func format(log: LogData) -> String {
return format(log)
}
}
2 changes: 1 addition & 1 deletion Sources/Bulk/Library/BasicFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public struct BasicFormatter: Formatter {

}

public func format(log: Log) -> FormatType {
public func format(log: LogData) -> FormatType {

let level: String = {
switch log.level {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Bulk/Library/ContextLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public final class ContextLogger {
}

@inline(__always)
private func _write(level: Log.Level, _ items: [Any], file: StaticString = #file, function: StaticString = #function, line: UInt = #line) {
private func _write(level: LogData.Level, _ items: [Any], file: StaticString = #file, function: StaticString = #function, line: UInt = #line) {

logger._write(level: level, prefixItemsClosure() + items, file: file, function: function, line: line)
}

public func write(level: Log.Level, _ items: [Any], file: StaticString = #file, function: StaticString = #function, line: UInt = #line) {
public func write(level: LogData.Level, _ items: [Any], file: StaticString = #file, function: StaticString = #function, line: UInt = #line) {
_write(level: level, items, file: file, function: function, line: line)
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Bulk/Library/FileBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public final class FileBuffer: Buffer {
fileHandle?.closeFile()
}

public func write(log: Log) -> BufferResult {
public func write(log: LogData) -> BufferResult {

do {

Expand Down Expand Up @@ -84,7 +84,7 @@ public final class FileBuffer: Buffer {
}
}

public func purge() -> [Log] {
public func purge() -> [LogData] {

var cursor = 0
var serializedLines = [String].init(repeating: "", count: lineCount())
Expand Down
6 changes: 3 additions & 3 deletions Sources/Bulk/Library/LevelFilterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import Foundation
/// Filter for Log.Level
public struct LevelFilterPlugin: Plugin {

public let ignoreLevels: [Log.Level]
public let ignoreLevels: [LogData.Level]

public init(ignoreLevels: [Log.Level]) {
public init(ignoreLevels: [LogData.Level]) {
self.ignoreLevels = ignoreLevels
}

public func apply(log: Log) -> Log {
public func apply(log: LogData) -> LogData {
if ignoreLevels.contains(log.level) {
var log = log
log.isActive = false
Expand Down
4 changes: 2 additions & 2 deletions Sources/Bulk/Library/LogSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public protocol LogSerializer {

associatedtype SerializedType

func serialize(log: Log) throws -> SerializedType
func deserialize(source: SerializedType) throws -> Log
func serialize(log: LogData) throws -> SerializedType
func deserialize(source: SerializedType) throws -> LogData
}
8 changes: 4 additions & 4 deletions Sources/Bulk/Library/MemoryBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ public final class MemoryBuffer: Buffer {
return cursor < size
}

var buffer: [Log?]
var buffer: [LogData?]
let size: Int
var cursor: Int = 0

public init(size: Int) {
self.size = size
self.buffer = [Log?].init(repeating: nil, count: size)
self.buffer = [LogData?].init(repeating: nil, count: size)
}

public func write(log: Log) -> BufferResult {
public func write(log: LogData) -> BufferResult {

buffer[cursor] = .some(log)

Expand All @@ -51,7 +51,7 @@ public final class MemoryBuffer: Buffer {
}
}

public func purge() -> [Log] {
public func purge() -> [LogData] {
let _buffer = buffer
for i in 0..<size {
buffer[i] = nil
Expand Down
4 changes: 2 additions & 2 deletions Sources/Bulk/Library/NoBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public struct NoBuffer: Buffer {

public init() { }

public func write(log: Log) -> BufferResult {
public func write(log: LogData) -> BufferResult {
return .flowed([log])
}

public func purge() -> [Log] {
public func purge() -> [LogData] {
return []
}
}
4 changes: 2 additions & 2 deletions Sources/Bulk/Library/RawFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import Foundation
/// For using raw `Log` `Target`
public struct RawFormatter : Formatter {

public typealias FormatType = Log
public typealias FormatType = LogData

public init() {
}

public func format(log: Log) -> FormatType {
public func format(log: LogData) -> FormatType {
return log
}
}
10 changes: 5 additions & 5 deletions Sources/Bulk/Library/SeparatorBasedLogSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public struct SeparatorBasedLogSerializer: LogSerializer {
self.separator = separator
}

public func deserialize(source: String) throws -> Log {
public func deserialize(source: String) throws -> LogData {

let s = source.split(separator: separator, omittingEmptySubsequences: false).map { String($0) }

guard s.count == 7 else {
throw Error.serializedDataIsBroken
}

guard let level = Int(s[Position.level.rawValue]).map(Log.Level.init(__int: )) else {
guard let level = Int(s[Position.level.rawValue]).map(LogData.Level.init(__int: )) else {
throw Error.serializedDataIsBroken
}
guard let date = UInt64(s[Position.date.rawValue]).map(TimeInterval.init(bitPattern: )).map(Date.init(timeIntervalSinceReferenceDate: )) else {
Expand All @@ -73,7 +73,7 @@ public struct SeparatorBasedLogSerializer: LogSerializer {
throw Error.serializedDataIsBroken
}

return Log(
return LogData(
level: level,
date: date,
body: body,
Expand All @@ -84,7 +84,7 @@ public struct SeparatorBasedLogSerializer: LogSerializer {
)
}

public func serialize(log: Log) throws -> String {
public func serialize(log: LogData) throws -> String {

let level = log.level.__int.description
let date = log.date.timeIntervalSinceReferenceDate.bitPattern.description
Expand Down Expand Up @@ -122,7 +122,7 @@ fileprivate extension Bool {
}
}

fileprivate extension Log.Level {
fileprivate extension LogData.Level {

fileprivate var __int: Int {
switch self {
Expand Down
Loading

0 comments on commit 1935cdd

Please sign in to comment.