# Path: turbo/log.py
# PY3 = sys.version_info >= (3,)
# def _init_file_logger(logger, level, log_path, log_size, log_count):
# def _init_stream_logger(logger, level=None):
# def _module_logger(path):
# def getLogger(currfile=None, level=None, log_path=None, log_size=500 * 1024 * 1024, log_count=3):


import inspect
import os
import sys
import time
import json
import copy
import base64
from datetime import datetime, date
from collections import Iterable
from bson.objectid import ObjectId
from turbo.log import util_log
    from base64 import decodebytes, encodebytes
    from base64 import encodestring as encodebytes, decodestring as decodebytes
    from turbo.model import BaseModel
        return encode(v)
    else:
        return default_encode(v)


def format_time(dt):
    """datetime format
    """
    return time.mktime(dt.timetuple())


def to_objectid(objid):
    """字符对象转换成objectid
    """
    if objid is None:
        return objid

    try:
        objid = ObjectId(objid)
    except:
        util_log.error('%s is invalid objectid' % objid)
        return None

    return objid


def json_encode(data, **kwargs):
    try:
        return json.dumps(data, **kwargs)
    except:

# Path: turbo/log.py
# PY3 = sys.version_info >= (3,)
# def _init_file_logger(logger, level, log_path, log_size, log_count):
# def _init_stream_logger(logger, level=None):
# def _module_logger(path):
# def getLogger(currfile=None, level=None, log_path=None, log_size=500 * 1024 * 1024, log_count=3):


# Path: turbo/util.py
import inspect
import os
import sys
import time
import json
import copy
import base64
from datetime import datetime, date
from collections import Iterable
from bson.objectid import ObjectId
from turbo.log import util_log
    from base64 import decodebytes, encodebytes
    from base64 import encodestring as encodebytes, decodestring as decodebytes
    from turbo.model import BaseModel

        return encode(v)
    else:
        return default_encode(v)


def format_time(dt):
    """datetime format
    """
    return time.mktime(dt.timetuple())


def to_objectid(objid):
    """字符对象转换成objectid
    """
    if objid is None:
        return objid

    try:
        objid = ObjectId(objid)
    except:
        util_log.error('%s is invalid objectid' % objid)
        return None

    return objid


def json_encode(data, **kwargs):
    try:
        return json.dumps(data, **kwargs)
    except:

        util_log.error('Uncaught exception in json_encode', exc_info=True)