# Path: airtest/base.py
# def getLogger(name='root'):
# def makedirs(dirname):
# def dirname(name):
# def exec_cmd(*cmds, **kwargs):
# def check_output(cmd):
# def random_name(name):
# def wait_until(fn, interval=0.5, max_retry=10, args=(), kwargs={}):


import json
import threading
import time
from airtest import base
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
simple json log
'''


class Lock(object):
    def __init__(self, tlock):
        self.lock = tlock
    
    def __enter__(self):
        self.lock.acquire()

    def __exit__(self, *args):
        self.lock.release()

class JSONLog(object):
    def __init__(self, filename):
        self._filename = filename
        self._fd = None
        self._lock = threading.Lock()

    def writeline(self, d, *args):
        '''
        @param d (dict or string): content needed write to file
        @param args(array): only when d is string, support writeline('hello %s', 'world')
        '''
        with Lock(self._lock) as _:

# Path: airtest/base.py
# def getLogger(name='root'):
# def makedirs(dirname):
# def dirname(name):
# def exec_cmd(*cmds, **kwargs):
# def check_output(cmd):
# def random_name(name):
# def wait_until(fn, interval=0.5, max_retry=10, args=(), kwargs={}):


# Path: airtest/jsonlog.py
import json
import threading
import time
from airtest import base

#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
simple json log
'''


class Lock(object):
    def __init__(self, tlock):
        self.lock = tlock
    
    def __enter__(self):
        self.lock.acquire()

    def __exit__(self, *args):
        self.lock.release()

class JSONLog(object):
    def __init__(self, filename):
        self._filename = filename
        self._fd = None
        self._lock = threading.Lock()

    def writeline(self, d, *args):
        '''
        @param d (dict or string): content needed write to file
        @param args(array): only when d is string, support writeline('hello %s', 'world')
        '''
        with Lock(self._lock) as _:

            base.makedirs(base.dirname(self._filename))