from apscheduler.scheduler import Scheduler, logger as apslogger
from wander.app import app
import logging as log

log_handler= log.FileHandler('worker.log')
apslogger.addHandler(log_handler)

class WanderJob(object):
    def __init__(self, verbose = False):
        self.verbose = verbose
        self.name = self.__class__.__name__
        self.logger = log.getLogger(__name__)
        self.logger.addHandler(log_handler)
        #self.logger.basicConfig(filename='%s.log'%(self.name), level =log.DEBUG)

    def info(self, msg):
        self.logger.info("%s: %s" %(self.name, msg))

    def debug(self, msg):
        self.logger.debug("%s: %s" %(self.name, msg))

    def start(self):
        self.info("Running..")
        self._run()
        self.info("Finished")

    def _run():
        pass

sched = Scheduler()


@sched.interval_schedule(seconds=5)
def job_cartosync():
    job = CartoSyncJob(verbose = True)
    job.start()

@sched.interval_schedule(seconds=5)
def job_spotfetch():
    json = app.config['SPOT_DATA']
    archive = "sqlite:///:memory:"
    job = SpotFetchJob(json_file = json, archive_db = archive, verbose = True)
    job.start()


def start():
    sched.configure()
    sched.start()


from wander.worker.spotfetch import SpotFetchJob
from wander.worker.cartosync import CartoSyncJob



@@ -417,16 +417,56 @@
 andler)%0A
+        self.logger.setLevel(log.DEBUG)%0A
         

add missing log level to workers