Ejemplo n.º 1
0
def after_request(response):
    writeInstanceLog(
        getUserId(),
        'Request url: ' + request.url + ', request data: ' + request.data,
        LOG_LVL_INFO)
    response.headers.add('Access-Control-Allow-Origin', '*')
    response.headers.add('Access-Control-Allow-Headers',
                         'Content-Type, Authorization')
    response.headers.add('Access-Control-Allow-Methods',
                         'GET, POST, PUT, DELETE')
    writeInstanceLog(
        getUserId(), 'Status_code: ' + unicode(response.status_code) + ', '
        'response: ' + unicode(response.response)[:2000], LOG_LVL_INFO)
    return response
Ejemplo n.º 2
0
def after_request(response):
    writeInstanceLog(getUserId(), 'Request url: ' + request.url +
                                  ', request data: ' + request.data,
                                  LOG_LVL_INFO)
    response.headers.add('Access-Control-Allow-Origin', '*')
    response.headers.add('Access-Control-Allow-Headers',
                         'Content-Type, Authorization')
    response.headers.add('Access-Control-Allow-Methods',
                         'GET, POST, PUT, DELETE')
    writeInstanceLog(getUserId(),
                     'Status_code: ' + unicode(response.status_code) + ', '
                     'response: ' + unicode(response.response)[:2000],
                     LOG_LVL_INFO)
    return response
Ejemplo n.º 3
0
 def testLogLvlIstanceLog(self):
     writeInstanceLog(TEST_USER_ID, TEST_MSG, LOG_LVL_INFO)
     obj = list(glog.find().sort('_id', DESCENDING).limit(1))[0]
     self.assertEqual(obj[TEST_LEVEL_FIELD], LOG_LVL_INFO)
     writeInstanceLog(TEST_USER_ID, TEST_MSG, LOG_LVL_WARNING)
     obj = list(glog.find().sort('_id', DESCENDING).limit(1))[0]
     self.assertEqual(obj[TEST_LEVEL_FIELD], LOG_LVL_WARNING)
     writeInstanceLog(TEST_USER_ID, TEST_MSG, LOG_LVL_ERROR)
     obj = list(glog.find().sort('_id', DESCENDING).limit(1))[0]
     self.assertEqual(obj[TEST_LEVEL_FIELD], LOG_LVL_ERROR)
     writeInstanceLog(TEST_USER_ID, TEST_MSG, LOG_LVL_CRITICAL)
     obj = list(glog.find().sort('_id', DESCENDING).limit(1))[0]
     self.assertEqual(obj[TEST_LEVEL_FIELD], LOG_LVL_CRITICAL)
 def testLogLvlIstanceLog(self):
     writeInstanceLog(TEST_USER_ID, TEST_MSG, LOG_LVL_INFO)
     obj = list(glog.find().sort('_id', DESCENDING).limit(1))[0]
     self.assertEqual(obj[TEST_LEVEL_FIELD], LOG_LVL_INFO)
     writeInstanceLog(TEST_USER_ID, TEST_MSG, LOG_LVL_WARNING)
     obj = list(glog.find().sort('_id', DESCENDING).limit(1))[0]
     self.assertEqual(obj[TEST_LEVEL_FIELD], LOG_LVL_WARNING)
     writeInstanceLog(TEST_USER_ID, TEST_MSG, LOG_LVL_ERROR)
     obj = list(glog.find().sort('_id', DESCENDING).limit(1))[0]
     self.assertEqual(obj[TEST_LEVEL_FIELD], LOG_LVL_ERROR)
     writeInstanceLog(TEST_USER_ID, TEST_MSG, LOG_LVL_CRITICAL)
     obj = list(glog.find().sort('_id', DESCENDING).limit(1))[0]
     self.assertEqual(obj[TEST_LEVEL_FIELD], LOG_LVL_CRITICAL)
Ejemplo n.º 5
0
def enablePlugin(api, pluginName):
    loadMain = PREFIX_LOAD_MAIN + pluginName + LOAD_MAIN_ENDING
    try:
        loadModule = __import__(loadMain, globals(), locals(), [
                                GET_PLUGIN_RESOURCES], -1)
        pluginResourcesDict = loadModule.getPluginResources()
        for pluginResource in pluginResourcesDict:
            api.add_resource(pluginResourcesDict[pluginResource], getPluginUrl(
                pluginResource, pluginName))
        writeInstanceLog(getUserId(), 'Plugin ' +
                         pluginName + ' successfully loaded',
                         LOG_LVL_INFO)
    except Exception as e:
        writeInstanceLog(getUserId(), EXCEPT_ERROR_TEXT +
                         pluginName +
                         ', ' +
                         ERROR_DISR_TEXT +
                         unicode(e) +
                         ' ' +
                         unicode(format_exc()),
                         LOG_LVL_ERROR)
Ejemplo n.º 6
0
def logUserOut():
    if USER_ID in session:
        SESSION_VALUE = session.pop(USER_ID)
        writeInstanceLog(SESSION_VALUE, LOGOUT, LOG_LVL_INFO)
Ejemplo n.º 7
0
def logUserIn(_id, user_login=None):
    session[USER_ID] = _id
    if user_login is not None:
        session[USER_LOGIN] = user_login
    writeInstanceLog(session[USER_ID], LOGIN, LOG_LVL_INFO)
Ejemplo n.º 8
0
def logUserOut():
    if USER_ID in session:
        SESSION_VALUE = session.pop(USER_ID)
        writeInstanceLog(SESSION_VALUE, LOGOUT, LOG_LVL_INFO)
Ejemplo n.º 9
0
def logUserIn(_id, user_login=None):
    session[USER_ID] = _id
    if user_login is not None:
        session[USER_LOGIN] = user_login
    writeInstanceLog(session[USER_ID], LOGIN, LOG_LVL_INFO)