<commit_before>//
//  NLogEntry.swift
//  KnackerTemplate
//
//  Created by <NAME> on 2/11/16.
//  Copyright © 2016 misfit. All rights reserved.
//

import RealmSwift

class NLogEntry: Object {
    dynamic var id = ""
    dynamic var createdAt: Double = 0
    dynamic var level = ""
    dynamic var message = ""
    dynamic var tag: String = ""
    dynamic var color: Int = 0
    dynamic var file: String = ""
    dynamic var function: String = ""
    dynamic var stackTrace: String = ""
    dynamic var line: Int = 0
    
    private var desc: String {
        var displayMessage = ""
        
        if let lv = NLog.Level(rawValue: level) {
            switch lv {
            case .Debug:
                displayMessage += "|Debug|"
            case .Error:
                displayMessage += "|Error|"
            case .Info:
                displayMessage += "|Info|"
            case .Warning:
                displayMessage += "|Warning|"
            case .Server:
                displayMessage += "|Server|"
            }
        }
        
        displayMessage += tag == "" ? " " : (" #" + tag + ": ")
        
        displayMessage += message
        return displayMessage
    }
    
    private func descLog(desc: String) -> String {
        let currentThreadNumber = NSThread.currentThread().number
        var log = NLog.dateFormat.stringFromDate(NSDate(timeIntervalSince1970: self.createdAt))
        log += " \(AppName)[\(currentThreadNumber == 1 ? "MainThread" : "\(currentThreadNumber)")] "
        
        return "\(log) \((file as NSString).lastPathComponent) - \(line) - \(function)\n\(desc)\n"
    }
    
    var fullDesc: String {
        return descLog(self.desc)
    }
    
    var fullDescWithStackTrace: String {
        return self.fullDesc + "=====================================\n" + self.stackTrace + "=====================================\n"
    }
    
    var shortDesc: String {
        return descLog(self.desc[0..<NLog.limitDisplayedCharacters])
    }
    
    convenience init(level: String, message: String, tag: String, color: Int, file: String, function: String, line: Int, stackTrace: String) {
        self.init()
        let now = NSDate().timeIntervalSince1970
        self.id = "\(now)"<commit_msg>no comment<commit_after>//
//  NLogEntry.swift
//  KnackerTemplate
//
//  Created by <NAME> on 2/11/16.
//  Copyright © 2016 misfit. All rights reserved.
//

import RealmSwift

class NLogEntry: Object {
    dynamic var id = ""
    dynamic var createdAt: Double = 0
    dynamic var level = ""
    dynamic var message = ""
    dynamic var tag: String = ""
    dynamic var color: Int = 0
    dynamic var file: String = ""
    dynamic var function: String = ""
    dynamic var stackTrace: String = ""
    dynamic var line: Int = 0
    
    private var desc: String {
        var displayMessage = ""
        
        if let lv = NLog.Level(rawValue: level) {
            switch lv {
            case .Debug:
                displayMessage += "|Debug|"
            case .Error:
                displayMessage += "|Error|"
            case .Info:
                displayMessage += "|Info|"
            case .Warning:
                displayMessage += "|Warning|"
            case .Server:
                displayMessage += "|Server|"
            }
        }
        
        displayMessage += tag == "" ? " " : (" #" + tag + ": ")
        
        displayMessage += message
        return displayMessage
    }
    
    private func descLog(desc: String) -> String {
        let currentThreadNumber = NSThread.currentThread().number
        var log = NLog.kDateFormat.stringFromDate(NSDate(timeIntervalSince1970: self.createdAt))
        log += " \(AppName)[\(currentThreadNumber == 1 ? "MainThread" : "\(currentThreadNumber)")] "
        
        return "\(log) \((file as NSString).lastPathComponent) - \(line) - \(function)\n\(desc)\n"
    }
    
    var fullDesc: String {
        return descLog(self.desc)
    }
    
    var fullDescWithStackTrace: String {
        return self.fullDesc + "=====================================\n" + self.stackTrace + "=====================================\n"
    }
    
    var shortDesc: String {
        return descLog(self.desc[0..<NLog.limitDisplayedCharacters])
    }
    
    convenience init(level: String, message: String, tag: String, color: Int, file: String, function: String, line: Int, stackTrace: String) {
        self.init()
        let now = NSDate().timeIntervalSince1970
        self.id = "\(now)"
{'fraction_non_alphanumeric': 0.152135231316726, 'fraction_numerical': 0.009786476868327402, 'mean_word_length': 2.0060160427807485, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, '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': '943293', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1238, 'n_words': 330}