LogFormatter

public class LogFormatter

Generates a log message formatted in accordance with the specified LogFormat

  • The log format to be used

    Declaration

    Swift

    public let logFormat: LogFormat
  • The current log level

    Declaration

    Swift

    public let logLevel: Logger.LogLevel
  • The filePath of the initial log caller

    Declaration

    Swift

    public let filePath: String
  • Determines the line in the source code of the caller.

    Declaration

    Swift

    public let line: Int
  • Determines the column in the source code of the caller.

    Declaration

    Swift

    public let column: Int
  • Determines the function that triggered the call.

    Declaration

    Swift

    public let function: String
  • The log message as a string

    Declaration

    Swift

    public let message: String
  • Sets the terminator of a log line in the console.

    Declaration

    Swift

    public let terminator: String
  • The date/time of that the log request was made at

    Declaration

    Swift

    public let date: NSDate = NSDate()
  • Initialises an instance of LogFormatter - Parameter format: The log format to be used - Parameter logLevel: The log level of the log message - Parameter filePath: The filePath of the initial log caller - Parameter line: The line in the source code of the caller. - Parameter column: The column in the source code of the caller. - Parameter function: The function that triggered the call. - Parameter message: The log message as a string - Parameter separator: The separator for consecutive statements - Parameter terminator: The terminator for each log line

    Declaration

    Swift

    public init(format: LogFormat, logLevel: Logger.LogLevel, filePath: String, line: Int, column: Int, function: String, message: String, terminator: String)

    Parameters

    format

    The log format to be used

    logLevel

    The log level of the log message

    filePath

    The filePath of the initial log caller

    line

    The line in the source code of the caller.

    column

    The column in the source code of the caller.

    function

    The function that triggered the call.

    message

    The log message as a string

    separator

    The separator for consecutive statements

    terminator

    The terminator for each log line

  • Concatenates the specified attributes in the LogFormat and generates the final log message - Returns: The final log message that will appear in the console/log file

    Declaration

    Swift

    public func formattedLogMessage() -> String

    Return Value

    The final log message that will appear in the console/log file

  • Generates the string equivalent of the Log Level that will be used in the log message - Parameter logLevel: The log level that’s going to be logged - Returns: A readable equivalent of the supplied log level

    Declaration

    Swift

    public func readableLogLevel(logLevel: Logger.LogLevel) -> String

    Parameters

    logLevel

    The log level that’s going to be logged

    Return Value

    A readable equivalent of the supplied log level

  • Generates the readable file path/name that will be used in the log message - Parameter filePath: The full file path - Parameter showFullPath: Whether or not the full path should be shown - Parameter showFileExtension: Whether or not the file extension should be shown - Returns: A formatted version of the file path

    Declaration

    Swift

    public func readableFileName(filePath: String, showFullPath: Bool, showFileExtension: Bool) -> String

    Parameters

    filePath

    The full file path

    showFullPath

    Whether or not the full path should be shown

    showFileExtension

    Whether or not the file extension should be shown

    Return Value

    A formatted version of the file path

  • Generates the string equivalent of the line that will be used in the log message - Parameter line: The line that’s going to be logged - Returns: A readable equivalent of the supplied line

    Declaration

    Swift

    public func readableLine(line: Int) -> String

    Parameters

    line

    The line that’s going to be logged

    Return Value

    A readable equivalent of the supplied line

  • Generates the string equivalent of the column that will be used in the log message - Parameter column: The column that’s going to be logged - Returns: A readable equivalent of the supplied column

    Declaration

    Swift

    public func readableColumn(column: Int) -> String

    Parameters

    column

    The column that’s going to be logged

    Return Value

    A readable equivalent of the supplied column

  • Generates the string equivalent of the function that will be used in the log message - Parameter function: The function that’s going to be logged - Returns: A readable equivalent of the supplied function

    Declaration

    Swift

    public func readableFunction(function: String) -> String

    Parameters

    function

    The function that’s going to be logged

    Return Value

    A readable equivalent of the supplied function

  • Generates the string equivalent of the message that will be used in the log message - Parameter message: The message that’s going to be logged - Returns: A formatted version of the supplied message

    Declaration

    Swift

    public func readableMessage(message: String) -> String

    Parameters

    message

    The message that’s going to be logged

    Return Value

    A formatted version of the supplied message

  • Generates the formatted equivalent of the date that will be used in the log message - Parameter date: The date that’s going to be logged - Returns: A readable & formatted equivalent of the supplied date

    Declaration

    Swift

    public func readableDate(date: NSDate, format: String) -> String

    Parameters

    date

    The date that’s going to be logged

    Return Value

    A readable & formatted equivalent of the supplied date

  • LogFormat construction attributes.

  • Level: The log level of the message
  • FileName: The file name of the file that triggered the log. fullPath: Should the full path of the file be logged? fileExtension: Should the file extension be logged?
  • Line: The line in the source code of the caller.
  • Column: The column in the source code of the caller.
  • Function: The function that triggered the call.
  • Message: The log message as a string
  • Date

    The date & time that the log was triggered at. Format: the format of the date. See http://waracle.net/iphone-nsdateformatter-date-formatting-table/ for more info.

    See more

    Declaration

    Swift

    public enum Attributes