began using logging module
This commit is contained in:
parent
efdce2b5fa
commit
2bdda6f09c
18
mce.py
18
mce.py
@ -2,6 +2,7 @@ import mclevel
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from box import BoundingBox
|
from box import BoundingBox
|
||||||
|
import logging
|
||||||
|
|
||||||
class UsageError(RuntimeError): pass
|
class UsageError(RuntimeError): pass
|
||||||
class BlockMatchError(RuntimeError): pass
|
class BlockMatchError(RuntimeError): pass
|
||||||
@ -94,6 +95,7 @@ class mce(object):
|
|||||||
"help",
|
"help",
|
||||||
"blocks",
|
"blocks",
|
||||||
"debug",
|
"debug",
|
||||||
|
"log",
|
||||||
]
|
]
|
||||||
debug = False
|
debug = False
|
||||||
needsSave = False;
|
needsSave = False;
|
||||||
@ -187,6 +189,20 @@ class mce(object):
|
|||||||
def _debug(self, command):
|
def _debug(self, command):
|
||||||
self.debug = not self.debug
|
self.debug = not self.debug
|
||||||
print "Debug", ("disabled", "enabled")[self.debug]
|
print "Debug", ("disabled", "enabled")[self.debug]
|
||||||
|
def _log(self, command):
|
||||||
|
"""
|
||||||
|
log [ <number> ]
|
||||||
|
|
||||||
|
Get or set the log threshold. 0 logs everything; 50 only logs major errors.
|
||||||
|
"""
|
||||||
|
if len(command):
|
||||||
|
try:
|
||||||
|
logging.getLogger().level = int(command[0]);
|
||||||
|
except ValueError:
|
||||||
|
raise UsageError
|
||||||
|
else:
|
||||||
|
print "Log level: {0}".format(logging.getLogger().level)
|
||||||
|
|
||||||
|
|
||||||
def _clone(self, command):
|
def _clone(self, command):
|
||||||
"""
|
"""
|
||||||
@ -684,6 +700,8 @@ class mce(object):
|
|||||||
batchMode = False;
|
batchMode = False;
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
logging.basicConfig(format='%(levelname)s:%(message)s')
|
||||||
|
logging.getLogger().level = logging.INFO
|
||||||
|
|
||||||
appPath = sys.argv.pop(0)
|
appPath = sys.argv.pop(0)
|
||||||
if len(sys.argv):
|
if len(sys.argv):
|
||||||
|
Reference in New Issue
Block a user