<commit_before>import simplejson 

from booki.editor import models

# logBookHistory

def logBookHistory(book = None, version = None, chapter = None, chapter_history = None, args = {}, user=None, kind = 'unknown'):
    history = models.BookHistory(book = book,
                                 version = version,
                                 chapter = chapter,
                                 chapter_history = chapter_history,
                                 args = simplejson.dumps(args),
                                 user = user,
                                 kind = models.HISTORY_CHOICES.get(kind, 0))
    history.save()

# logChapterHistory

def logChapterHistory(chapter = None, content = None, user = None, comment = '', revision = None):
    history = models.ChapterHistory(chapter = chapter,
                                    content = content,
                                    user = user,
                                    revision = revision,
                                    comment = comment)
    history.save()

    return history



def logError(msg, *args):
    import logging
    logging.getLogger("booki").error(msg, *args)

def logWarning(msg, *args):
    import logging
    logging.getLogger("booki").warning(msg, *args)

    
def printStack(*extra):
    import traceback
    logError(traceback.format_exc())
    for e in extra:
        logError(e)
                            <commit_msg>fuck you<commit_after>import simplejson 

from booki.editor import models

# logBookHistory

def logBookHistory(book = None, version = None, chapter = None, chapter_history = None, args = {}, user=None, kind = 'unknown'):
    history = models.BookHistory(book = book,
                                 version = version,
                                 chapter = chapter,
                                 chapter_history = chapter_history,
                                 args = simplejson.dumps(args),
                                 user = user,
                                 kind = models.HISTORY_CHOICES.get(kind, 0))
    history.save()

# logChapterHistory

def logChapterHistory(chapter = None, content = None, user = None, comment = '', revision = None):
    history = models.ChapterHistory(chapter = chapter,
                                    content = content,
                                    user = user,
                                    revision = revision,
                                    comment = comment)
    history.save()

    return history



def logError(msg, *args):
    import logging
    logging.getLogger("booki").error(msg, *args)

def logWarning(msg, *args):
    import logging
    logging.getLogger("booki").warning(msg, *args)

def printStack(*extra):
    import traceback
    logError(traceback.format_exc())
    for e in extra:
        logError(e)
{'fraction_non_alphanumeric': 0.08907741251325557, 'fraction_numerical': 0.0007069635913750442, 'mean_word_length': 1.5495495495495495, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4000730', 'n_tokens_mistral': 704, 'n_tokens_neox': 674, 'n_words': 173}