<commit_before>import os
import sys
import json


from log import logger, get_rotating_logger


class LogTweetHandler(object):

    def __init__(self, logfile, interval=60, when="M"):
        """ interval is number of minutes for each log file """
        self.logger = get_rotating_logger(logfile, interval)
        self.logfile = logfile

    def _validate(self, key, record):
        if key in record and record[key]:
            return True
        return False
   
    def validate_geotweet(self, record):
        """ check that stream record is actual tweet with coordinates """
        return self._validate('user', record) and self._validate('geo', record)

    def handle(self, record):
        """ called when a record is received from the Twitter API stream """
        if self.validate_geotweet(record):
            tweet = Tweet(record)
            self.logger.info(tweet.as_json())
           

class Tweet(object):

    def __init__(self, record):
        self.extract_user(record['user'])
        self.extract_meta(record)
        self.record = record
<commit_msg>allow making LogTweetHandler with no args<commit_after>import os
import sys
import json


from log import logger, get_rotating_logger


class LogTweetHandler(object):

    def __init__(self, logfile=None, interval=60, when="M"):
        """ interval is number of minutes for each log file """
        if logfile:
            self.logger = get_rotating_logger(logfile, interval)
            self.logfile = logfile

    def _validate(self, key, record):
        if key in record and record[key]:
            return True
        return False
   
    def validate_geotweet(self, record):
        """ check that stream record is actual tweet with coordinates """
        return self._validate('user', record) and self._validate('geo', record)

    def handle(self, record):
        """ called when a record is received from the Twitter API stream """
        if self.validate_geotweet(record):
            tweet = Tweet(record)
            self.logger.info(tweet.as_json())
           

class Tweet(object):

    def __init__(self, record):
        self.extract_user(record['user'])
        self.extract_meta(record)
        self.record = record

{'fraction_non_alphanumeric': 0.09365150832958127, 'fraction_numerical': 0.0018009905447996398, 'mean_word_length': 2.6788079470198674, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4395598', 'n_tokens_mistral': 611, 'n_tokens_neox': 596, 'n_words': 191}