old_contents: #-*- coding:utf-8 -*-
  import logging
  
  def get_logger():
      logger = logging.getLogger()
      ## logger
      level = logging.DEBUG
      logger.setLevel(level)
      # create console handler with a higher log level
      ch = logging.StreamHandler()
      ch.setLevel(level)
      # create formatter and add it to the handlers
      formatter = logging.Formatter('%(asctime)s:%(levelname)s:%(name)s:%(message)s')
      ch.setFormatter(formatter)
      # add the handlers to the logger
      logger.addHandler(ch)
      return logger
  
new_contents: #-*- coding:utf-8 -*-
  import logging
  import sys
  
  def get_logger(level=logging.DEBUG):
      logger = logging.getLogger("gsensors")
      ## logger
      logger.setLevel(level)
      # create console handler with a higher log level
      ch = logging.StreamHandler()
      ch.setLevel(level)
      # create formatter and add it to the handlers
      formatter = logging.Formatter('%(asctime)s:%(levelname)s:%(name)s:%(message)s')
      ch.setFormatter(formatter)
      # add the handlers to the logger
      logger.addHandler(ch)
      return logger
  
  
  # see http://stackoverflow.com/questions/13210436/get-full-traceback/13210518#13210518
  
  class FauxTb(object):
      def __init__(self, tb_frame, tb_lineno, tb_next):
          self.tb_frame = tb_frame
          self.tb_lineno = tb_lineno
          self.tb_next = tb_next
  
  def current_stack(skip=0):
      try: 1/0
      except ZeroDivisionError:
          f = sys.exc_info()[2].tb_frame
      for i in xrange(skip + 2):
          f = f.f_back
      lst = []
      while f is not None:
          lst.append((f, f.f_lineno))
          f = f.f_back
      return lst
  
  def extend_traceback(tb, stack):
      """Extend traceback with stack info."""
      head = tb
      for tb_frame, tb_lineno in stack:
          head = FauxTb(tb_frame, tb_lineno, head)
      return head
  
  def full_exc_info():
      """Like sys.exc_info, but includes the full traceback."""
      t, v, tb = sys.exc_info()
      full_tb = extend_traceback(tb, current_stack(1))
      return t, v, full_tb
  
subject: add utils to log traceback