DRY: Use magic instead of code to get a string for the correct log
    level when calling ``print_log_msg``. Because writing the same
    boilerplate code in each log_XXX def was too painful to commit.

def log_wrap(origfunc):
    """
    DRY: Use magic instead of code to get a string for the correct log
    level when calling ``print_log_msg``. Because writing the same
    boilerplate code in each log_XXX def was too painful to commit.
    """
    def orig_func_wraper(msg, *args):
        # Take the callers name and snap it in two, result is log
        # level, e.g.: log_debug is DEBUG level.
        log_level = origfunc.__name__.split("_")[1]

        import Log
        if getattr(Log, "LOG_%s" % log_level.upper()) <= \
                Log.LOG_LEVEL_CURRENT:
            # flatten and stringify the positional params so we don't
            # tuple() a tuple or an array and end up with
            # weirdness.
            a = map(str, juicer.utils.flatten(args))
            print_log_msg(log_level, str(msg) % tuple(a))
    return orig_func_wraper