# Path: lib/utils.py
# LOG = logging.getLogger(__name__)
# def base_directory_not_found_error(err):
# def retry_on_error(f, error=Exception, failure_handler=None,
#                    max_retries=2, seconds_between_retries=5):
#     def _reraise_exception(exc):
# def retry_on_timeout(f, is_timeout_error_f,
#                      max_retries=2,
#                      seconds_between_retries=5,
#                      initial_timeout=120,
#                      timeout_incr_f=lambda t: t * 2):
# def set_http_proxy_env(proxy):
# def run_command(cmd, **kwargs):
# def create_directory(directory):
# def is_package_installed(package_name):
# def recursive_glob(directory, pattern):
# def replace_str_in_file(file_path, search, replacement):
# def force_symlink(target_path, link_path):


import logging
import logging.handlers
import os
import sys
from lib import utils
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.




class LogHelper(object):
    def __init__(self, log_file_path=None, verbose=False, rotate_size=0):
        logger = logging.getLogger()
        logger.setLevel(logging.DEBUG)

        sh = logging.StreamHandler(sys.stdout)
        if verbose:
            sh.setLevel(logging.DEBUG)
        else:
            sh.setLevel(logging.INFO)
        sh.setFormatter(logging.Formatter('%(message)s'))
        logger.addHandler(sh)

        if log_file_path:
            log_dir = os.path.dirname(log_file_path)
            utils.create_directory(log_dir)

            logger.info("Logs available at %s" % log_file_path)

            rfh = logging.handlers.RotatingFileHandler(
                log_file_path, maxBytes=rotate_size, backupCount=1)
            rfh.setLevel(logging.DEBUG)

# Path: lib/utils.py
# LOG = logging.getLogger(__name__)
# def base_directory_not_found_error(err):
# def retry_on_error(f, error=Exception, failure_handler=None,
#                    max_retries=2, seconds_between_retries=5):
#     def _reraise_exception(exc):
# def retry_on_timeout(f, is_timeout_error_f,
#                      max_retries=2,
#                      seconds_between_retries=5,
#                      initial_timeout=120,
#                      timeout_incr_f=lambda t: t * 2):
# def set_http_proxy_env(proxy):
# def run_command(cmd, **kwargs):
# def create_directory(directory):
# def is_package_installed(package_name):
# def recursive_glob(directory, pattern):
# def replace_str_in_file(file_path, search, replacement):
# def force_symlink(target_path, link_path):


# Path: lib/log_helper.py
import logging
import logging.handlers
import os
import sys
from lib import utils

# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.




class LogHelper(object):
    def __init__(self, log_file_path=None, verbose=False, rotate_size=0):
        logger = logging.getLogger()
        logger.setLevel(logging.DEBUG)

        sh = logging.StreamHandler(sys.stdout)
        if verbose:
            sh.setLevel(logging.DEBUG)
        else:
            sh.setLevel(logging.INFO)
        sh.setFormatter(logging.Formatter('%(message)s'))
        logger.addHandler(sh)

        if log_file_path:
            log_dir = os.path.dirname(log_file_path)
            utils.create_directory(log_dir)

            logger.info("Logs available at %s" % log_file_path)

            rfh = logging.handlers.RotatingFileHandler(
                log_file_path, maxBytes=rotate_size, backupCount=1)
            rfh.setLevel(logging.DEBUG)

            rfh.setFormatter(logging.Formatter(