mirror of
https://github.com/paradoxxxzero/butterfly.git
synced 2026-05-26 15:13:36 +00:00
Add a --more option to log handled exception
This commit is contained in:
@@ -23,6 +23,8 @@ import tornado.httpserver
|
||||
import ssl
|
||||
|
||||
tornado.options.define("debug", default=False, help="Debug mode")
|
||||
tornado.options.define("more", default=False,
|
||||
help="Debug mode with more verbosity")
|
||||
tornado.options.define("host", default='127.0.0.1', help="Server host")
|
||||
tornado.options.define("port", default=57575, type=int, help="Server port")
|
||||
tornado.options.define("shell", help="Shell to execute at login")
|
||||
@@ -36,11 +38,15 @@ tornado.options.parse_command_line()
|
||||
import logging
|
||||
for logger in ('tornado.access', 'tornado.application',
|
||||
'tornado.general', 'butterfly'):
|
||||
logging.getLogger(logger).setLevel(
|
||||
logging.DEBUG if tornado.options.options.debug else logging.WARNING)
|
||||
level = logging.WARNING
|
||||
if tornado.options.options.debug:
|
||||
level = logging.INFO
|
||||
if tornado.options.options.more:
|
||||
level = logging.DEBUG
|
||||
logging.getLogger(logger).setLevel(level)
|
||||
|
||||
log = logging.getLogger('butterfly')
|
||||
log.debug('Starting server')
|
||||
log.info('Starting server')
|
||||
ioloop = tornado.ioloop.IOLoop.instance()
|
||||
|
||||
|
||||
@@ -78,5 +84,5 @@ else:
|
||||
'butterfly/templates/']
|
||||
watch({'url': url}, files, unwatch_at_exit=True)
|
||||
|
||||
log.debug('Starting loop')
|
||||
log.info('Starting loop')
|
||||
ioloop.start()
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
__version__ = '1.2.8'
|
||||
__version__ = '1.2.9'
|
||||
|
||||
|
||||
import os
|
||||
|
||||
@@ -162,7 +162,7 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
|
||||
os.execvpe(args[0], args, env)
|
||||
|
||||
def communicate(self):
|
||||
self.log.debug('Adding handler')
|
||||
self.log.info('Adding handler')
|
||||
fcntl.fcntl(self.fd, fcntl.F_SETFL, os.O_NONBLOCK)
|
||||
|
||||
def utf8_error(e):
|
||||
@@ -261,25 +261,27 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
|
||||
|
||||
def on_close(self):
|
||||
if getattr(self, 'pid', 0) == 0:
|
||||
self.log.warning('pid is 0')
|
||||
self.log.info('pid is 0')
|
||||
return
|
||||
try:
|
||||
self.writer.write(u('\x04'))
|
||||
self.writer.flush()
|
||||
except Exception:
|
||||
self.log.warning('closing term fail', exc_info=True)
|
||||
self.log.debug('closing term fail', exc_info=True)
|
||||
|
||||
try:
|
||||
os.close(self.fd)
|
||||
except Exception:
|
||||
self.log.warning('closing fd fail', exc_info=True)
|
||||
self.log.debug('closing fd fail', exc_info=True)
|
||||
|
||||
try:
|
||||
os.waitpid(self.pid, 0)
|
||||
except Exception:
|
||||
self.log.warning('waitpid fail', exc_info=True)
|
||||
self.log.debug('waitpid fail', exc_info=True)
|
||||
|
||||
try:
|
||||
ioloop.remove_handler(self.fd)
|
||||
except Exception:
|
||||
self.log.warning('handler removal fail', exc_info=True)
|
||||
self.log.debug('handler removal fail', exc_info=True)
|
||||
|
||||
self.log.info('Websocket closed')
|
||||
|
||||
Reference in New Issue
Block a user