Ejemplo n.º 1
0
 def __init__(self):
     self.sm_logger = logging.getLogger("simple_debug")
Ejemplo n.º 2
0
    def get_cur_info(self):
        try:
            raise Exception
        except:
            f = sys._getframe(2)

        moduleName = f.f_code.co_filename
        funcName = f.f_code.co_name
        lineNo = f.f_lineno  #行号

        return ("[%s.%s-%s]" % (moduleName, funcName, lineNo))

    def debug(self, msg):
        self.sm_logger.debug("%s:%s" % (self.get_cur_info(), msg))


if isBAE:
    sm_logger = BAElogger()
else:
    sm_logger = logging.getLogger("simple_debug")
    sm_logger.setLevel(logging.DEBUG)

    ch = logging.StreamHandler()
    formatter = logging.Formatter(
        '[%(asctime)s - %(module)s.%(funcName)s-%(lineno)d](%(levelname)s): %(message)s'
    )
    ch.setFormatter(formatter)

    sm_logger.addHandler(ch)
Ejemplo n.º 3
0
	def __init__(self):
		self.sm_logger = logging.getLogger("simple_debug")
Ejemplo n.º 4
0
	def __init__(self):
		self.sm_logger = logging.getLogger("simple_debug")

	def get_cur_info(self):
		try:
			raise Exception
		except:
			f =  sys._getframe( 2 )

		moduleName = f.f_code.co_filename
		funcName = f.f_code.co_name
		lineNo = f.f_lineno #行号

		return ("[%s.%s-%s]" % (moduleName,funcName,lineNo))

	def debug(self,msg):
		self.sm_logger.debug("%s:%s" % (self.get_cur_info(),msg))

if isBAE:
	sm_logger = BAElogger()
else:
	sm_logger = logging.getLogger("simple_debug")
	sm_logger.setLevel(logging.DEBUG)

	ch = logging.StreamHandler()
	formatter = logging.Formatter('[%(asctime)s - %(module)s.%(funcName)s-%(lineno)d](%(levelname)s): %(message)s')
	ch.setFormatter(formatter)

	sm_logger.addHandler(ch)
Ejemplo n.º 5
0
from flask import Flask
from werkzeug import Local, LocalProxy

import os
if 'SERVER_SOFTWARE' in os.environ:
    from app.conf import baidu as conf
    from bae.api import logging
else:
    from app.conf import mysql as conf
    import logging

    
app = Flask(__name__)
app.debug = True
app.config.from_object(conf)
l = Local()
baelogger = logging.getLogger(__name__)
from models.database import db_session, Base

l.session = db_session

if 'SERVER_SOFTWARE' in os.environ:
    from app import views
   
else:
    from app.views.api import *
    



Ejemplo n.º 6
0
#coding=utf-8
#-*- coding: utf-8 -*-

from bae.api import logging
from xml.etree import ElementTree as ET
from flask import request, jsonify, make_response
from NoLove.configs import settings
run_log = logging.getLogger('run_loggin')


def parse_msg():
    #"parse the command sent from wechat"
    recvmsg = request.data
    root = ET.fromstring(recvmsg)
    msg = {}
    for child in root:
        msg[child.tag] = child.text
    return msg


def set_content(msg=None):
    try:
        run_log.debug('msg_content:' + msg)
        content = settings.MSG[msg]
    except Exception, e:
        if msg:
            content = settings.MSG['__error__msg__'] % (msg)
        else:
            content = settings.MSG['__system__msg__']
    return content