More control over logging + added extra DEBUG level
This commit is contained in:
@@ -19,10 +19,13 @@
|
||||
# ***** END GPL LICENCE BLOCK *****
|
||||
|
||||
import os
|
||||
import logging
|
||||
|
||||
from . import blendfile
|
||||
|
||||
# gives problems with scripts that use stdout, for testing 'bam deps' for eg.
|
||||
VERBOSE = False # os.environ.get('BAM_VERBOSE', False)
|
||||
DEBUG = False
|
||||
VERBOSE = DEBUG or False # os.environ.get('BAM_VERBOSE', False)
|
||||
TIMEIT = False
|
||||
|
||||
USE_ALEMBIC_BRANCH = True
|
||||
@@ -63,12 +66,14 @@ class C_defs:
|
||||
if USE_ALEMBIC_BRANCH:
|
||||
CACHE_LIBRARY_SOURCE_CACHE = 1
|
||||
|
||||
log_deps = logging.getLogger("path_walker")
|
||||
log_deps.setLevel({
|
||||
(True, True): logging.DEBUG,
|
||||
(False, True): logging.INFO,
|
||||
(False, False): logging.WARNING
|
||||
}[DEBUG, VERBOSE])
|
||||
|
||||
if VERBOSE:
|
||||
import logging
|
||||
log_deps = logging.getLogger("path_walker")
|
||||
del logging
|
||||
|
||||
def set_as_str(s):
|
||||
if s is None:
|
||||
return "None"
|
||||
@@ -257,14 +262,15 @@ class FilePath:
|
||||
|
||||
filepath = os.path.abspath(filepath)
|
||||
|
||||
if VERBOSE:
|
||||
indent_str = " " * level
|
||||
# print(indent_str + "Opening:", filepath)
|
||||
# print(indent_str + "... blocks:", block_codes)
|
||||
|
||||
log_deps.info("~")
|
||||
log_deps.info("%s%s" % (indent_str, filepath.decode('utf-8')))
|
||||
log_deps.info("%s%s" % (indent_str, set_as_str(block_codes)))
|
||||
log = log_deps.getChild('visit_from_blend')
|
||||
log.info("~")
|
||||
log.info("%sOpening: %s", indent_str, filepath)
|
||||
if VERBOSE:
|
||||
log.info("%s blocks: %s", indent_str, set_as_str(block_codes))
|
||||
|
||||
blendfile_level_cb_enter, blendfile_level_cb_exit = blendfile_level_cb
|
||||
|
||||
@@ -421,7 +427,7 @@ class FilePath:
|
||||
# print("A:", expand_addr_visit)
|
||||
# print("B:", block_codes)
|
||||
if VERBOSE:
|
||||
log_deps.info("%s%s" % (indent_str, set_as_str(expand_addr_visit)))
|
||||
log.info("%s expand_addr_visit=%s", indent_str, set_as_str(expand_addr_visit))
|
||||
|
||||
if recursive:
|
||||
|
||||
@@ -511,7 +517,9 @@ class FilePath:
|
||||
def from_block(block: blendfile.BlendFileBlock, basedir, extra_info, level):
|
||||
assert(block.code != b'DATA')
|
||||
fn = FilePath._from_block_dict.get(block.code)
|
||||
if fn is not None:
|
||||
if fn is None:
|
||||
return
|
||||
|
||||
yield from fn(block, basedir, extra_info, level)
|
||||
|
||||
@staticmethod
|
||||
|
Reference in New Issue
Block a user