<commit_before>//
//  Copyright (c) 2017 <NAME>
//
//  Apache License, v2.0
//

import Foundation

/// Writes a log entry.

public func logInfo(_ item: @autoclosure () -> Any, tag: String? = nil, file: StaticString = #file, line: UInt = #line, function: StaticString = #function) {

    struct MyDateFormatter {
        static let shared = { () -> DateFormatter in
            let formatter = DateFormatter()
            formatter.locale = Locale(identifier: "en_US_POSIX")
            formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
            formatter.timeZone = TimeZone(secondsFromGMT: 0)
            return formatter
        }()
    }

    let date = Date()
    let formattedDate = MyDateFormatter.shared.string(from: date)
    let fileName = (String(describing: file) as NSString).lastPathComponent

    let message = "\(formattedDate) \(fileName):\(line) \(function) \(item())"
    let taggedMessage: String
    if let tag = tag {
        taggedMessage = "\(tag) " + message
    } else {
        taggedMessage = message
    }

    //NSLog(taggedMessage)
    print(taggedMessage)
}

/// Writes a log entry only during execution of debug builds.

public func logDebug(_ item: @autoclosure () -> Any, file: StaticString = #file, line: UInt = #line, function: StaticString = #function) {
    #if DEBUG
        logInfo(item, tag: "DEBUG", file: file, line: line, function: function)
    #endif
}

/// Writes a log entry (always) and terminates execution of debug builds.

public func logWarning(_ item: @autoclosure () -> Any = String(), file: StaticString = #file, line: UInt = #line, function: StaticString = #function) {
    let message = "\(item())"
    logInfo(message, tag: "WARNING", file: file, line: line, function: function)
    assertionFailure("\(function) \(message)", file: file, line: line)
}

/// Invokes `logWarning` when `condition` is `true`.

public func logWarningIf(_ condition: Bool, _ item: @autoclosure () -> Any = String(), file: StaticString = #file, line: UInt = #line, function: StaticString = #function) {
    if condition {
        logWarning(item, file: file, line: line, function: function)
    }
}<commit_msg>Remove preemptive thunking<commit_after>//
//  Copyright (c) 2017 <NAME>
//
//  Apache License, v2.0
//

import Foundation

/// Writes a log entry.

public func logInfo(_ item: Any, tag: String? = nil, file: StaticString = #file, line: UInt = #line, function: StaticString = #function) {

    struct MyDateFormatter {
        static let shared = { () -> DateFormatter in
            let formatter = DateFormatter()
            formatter.locale = Locale(identifier: "en_US_POSIX")
            formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
            formatter.timeZone = TimeZone(secondsFromGMT: 0)
            return formatter
        }()
    }

    let date = Date()
    let formattedDate = MyDateFormatter.shared.string(from: date)
    let fileName = (String(describing: file) as NSString).lastPathComponent

    let message = "\(formattedDate) \(fileName):\(line) \(function) \(item)"
    let taggedMessage: String
    if let tag = tag {
        taggedMessage = "\(tag) " + message
    } else {
        taggedMessage = message
    }

    //NSLog(taggedMessage)
    print(taggedMessage)
}

/// Writes a log entry only during execution of debug builds.

public func logDebug(_ item: @autoclosure () -> Any, file: StaticString = #file, line: UInt = #line, function: StaticString = #function) {
    #if DEBUG
        logInfo(item(), tag: "DEBUG", file: file, line: line, function: function)
    #endif
}

/// Writes a log entry (always) and terminates execution of debug builds.

public func logWarning(_ item: Any = String(), file: StaticString = #file, line: UInt = #line, function: StaticString = #function) {
    let message = "\(item)"
    logInfo(message, tag: "WARNING", file: file, line: line, function: function)
    assertionFailure("\(function) \(message)", file: file, line: line)
}

/// Invokes `logWarning` when `condition` is `true`.

public func logWarningIf(_ condition: Bool, _ item: @autoclosure () -> Any = String(), file: StaticString = #file, line: UInt = #line, function: StaticString = #function) {
    if condition {
        logWarning(item, file: file, line: line, function: function)
    }
}
{'fraction_non_alphanumeric': 0.13445771843523074, 'fraction_numerical': 0.0032794565472007496, 'mean_word_length': 3.133591481122943, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '321990', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1252, 'n_words': 404}