0

Change logging to use the 'logging' module.

This commit is contained in:
Alex Jurkiewicz
2010-09-30 14:35:37 +10:00
parent 971f33e763
commit 9f49bf3d77
3 changed files with 44 additions and 27 deletions

17
gmap.py
View File

@@ -26,6 +26,9 @@ from optparse import OptionParser
import re
import multiprocessing
import time
import logging
logging.basicConfig(level=logging.INFO,format="%(asctime)s [%(levelname)s] %(message)s")
import world
import quadtree
@@ -46,6 +49,8 @@ def main():
parser.add_option("--cachedir", dest="cachedir", help="Sets the directory where the Overviewer will save chunk images, which is an intermediate step before the tiles are generated. You must use the same directory each time to gain any benefit from the cache. If not set, this defaults to your world directory.")
parser.add_option("--chunklist", dest="chunklist", help="A file containing, on each line, a path to a chunkfile to update. Instead of scanning the world directory for chunks, it will just use this list. Normal caching rules still apply.")
parser.add_option("--imgformat", dest="imgformat", help="The image output format to use. Currently supported: png(default), jpg. NOTE: png will always be used as the intermediate image format.")
parser.add_option("-q", "--quiet", dest="quiet", action="count", default=0, help="Print less output. You can specify this option multiple times.")
parser.add_option("-v", "--verbose", dest="verbose", action="count", default=0, help="Print more output. You can specify this option multiple times.")
options, args = parser.parse_args()
@@ -93,6 +98,14 @@ def main():
else:
imgformat = 'png'
logging.getLogger().setLevel(
logging.getLogger().level + 10*options.quiet)
logging.getLogger().setLevel(
logging.getLogger().level - 10*options.verbose)
logging.info("Welcome to Minecraft Overviewer!")
logging.debug("Current log level: {0}".format(logging.getLogger().level))
# First generate the world's chunk images
w = world.WorldRenderer(worlddir, cachedir, chunklist=chunklist)
w.go(options.procs)
@@ -110,7 +123,7 @@ def delete_all(worlddir, tiledir):
for f in filenames:
if matcher.match(f):
filepath = os.path.join(dirpath, f)
print "Deleting {0}".format(filepath)
logging.info("Deleting {0}".format(filepath))
os.unlink(filepath)
# Now delete all /hash/ files in the tile dir.
@@ -119,7 +132,7 @@ def delete_all(worlddir, tiledir):
for f in filenames:
if f.endswith(".hash"):
filepath = os.path.join(dirpath, f)
print "Deleting {0}".format(filepath)
logging.info("Deleting {0}".format(filepath))
os.unlink(filepath)
def list_worlds():