Esempio n. 1
0
def init(reqId = "NA"):

    if reqId is None:
        reqId = "NA"

    userName = "******"

    global tcacheObj

    if tcacheObj is None:
        tcacheObj = threadCache.threadCache()

    tcacheObj.setSessionId(reqId)
    tcacheObj.setUserId(userName)
    tcacheObj.setLogger(customLogger.getApiLogger())
    return tcacheObj
Esempio n. 2
0
from piston.utils import Mimer
from src.utils import pbutils
Mimer.register(pbutils.loadPb, ('application/octet-stream'))
from src.utils import customLogger
apiLogger = customLogger.getApiLogger('api_trace.log')

Esempio n. 3
0
from src.utils import threadCache
from src.utils import customLogger
import json
import time
import log_analytics_proto
from piston.utils import rc
from src.utils import customLogger
apiLogger = customLogger.getApiLogger()

tcacheObj = None


def badRequest(code = None, detail = None, description = None):

    global tcacheObj
    
    if not detail:
        detail = "Invalid request"
    if not description:
        description = detail
        
    if tcacheObj is not None:
      if tcacheObj.logger is not None or len(tcacheObj.logger) > 0:
        tcacheObj.error("Error Code: " + str(code) + " " + detail)
      else:
        apiLogger.error("Error Code: " + str(code) + " " + detail)
    else:
      apiLogger.error("Error Code: " + str(code) + " " + detail)

    resp = rc.BAD_REQUEST
    resp['Content-Type'] = 'application/json; charset=utf-8'