full inline sourcecode documentation

This commit is contained in:
John Rommel Estropia
2015-05-22 02:26:28 +09:00
parent 637829ec32
commit 8374c552f0
37 changed files with 1514 additions and 287 deletions
+7
View File
@@ -28,6 +28,13 @@ import Foundation
// MARK: - DefaultLogger
/**
The `DefaultLogger` is a basic implementation of the `HardcoreDataLogger` protocol.
- The `log(...)` method calls `println(...)` to print the level, source file name, line number, function name, and the log message.
- The `handleError(...)` method calls `println(...)` to print the source file name, line number, function name, and the error message.
- The `assert(...)` method calls `assert(...)` on the arguments.
*/
public final class DefaultLogger: HardcoreDataLogger {
public func log(#level: LogLevel, message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
@@ -33,7 +33,7 @@ public extension HardcoreData {
// MARK: Public
/**
The HardcoreDataLogger instance to be used. The default logger is an instance of a DefaultLogger.
The `HardcoreDataLogger` instance to be used. The default logger is an instance of a `DefaultLogger`.
*/
public static var logger: HardcoreDataLogger = DefaultLogger()
@@ -28,6 +28,9 @@ import Foundation
// MARK: - LogLevel
/**
The `LogLevel` indicates the severity of a log message.
*/
public enum LogLevel {
case Trace
@@ -39,12 +42,42 @@ public enum LogLevel {
// MARK: - HardcoreDataLogger
/**
Custom loggers should implement the `HardcoreDataLogger` protocol and pass its instance to `HardcoreData.logger`. Calls to `log(...)`, `handleError(...)`, and `assert(...)` are not tied to a specific queue/thread, so it is the implementer's job to handle thread-safety.
*/
public protocol HardcoreDataLogger {
/**
Handles log messages sent by the `HardcoreData` framework.
:level: the severity of the log message
:message: the log message
:fileName: the source file name
:lineNumber: the source line number
:functionName: the source function name
*/
func log(#level: LogLevel, message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString)
/**
Handles errors sent by the `HardcoreData` framework.
:error: the error
:message: the error message
:fileName: the source file name
:lineNumber: the source line number
:functionName: the source function name
*/
func handleError(#error: NSError, message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString)
/**
Handles assertions made throughout the `HardcoreData` framework.
:condition: the assertion condition
:message: the assertion message
:fileName: the source file name
:lineNumber: the source line number
:functionName: the source function name
*/
func assert(@autoclosure condition: () -> Bool, message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString)
}