How to use the logzero.logfile function in logzero

To help you get started, we’ve selected a few logzero examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ddi-lab / generion-middleware / neo / Settings.py View on Github external
def set_logfile(self, fn, max_bytes=0, backup_count=0):
        """
        Setup logging to a (rotating) logfile.

        Args:
            fn (str): Logfile. If fn is None, disable file logging
            max_bytes (int): Maximum number of bytes per logfile. If used together with backup_count,
                             logfile will be rotated when it reaches this amount of bytes.
            backup_count (int): Number of rotated logfiles to keep
        """
        logzero.logfile(fn, maxBytes=max_bytes, backupCount=backup_count)
github CityOfZion / neo-python / neo / bin / api_server.py View on Github external
syslog_facility = SysLogHandler.LOG_LOCAL0 + args.syslog_local
        else:
            print("Logging to syslog user facility")
            syslog_facility = SysLogHandler.LOG_USER

        # Setup logzero to only use the syslog handler
        logzero.syslog(facility=syslog_facility)
    else:
        # Setup file logging
        if args.logfile:
            logfile = os.path.abspath(args.logfile)
            if args.disable_stderr:
                print("Logging to logfile: %s" % logfile)
            else:
                print("Logging to stderr and logfile: %s" % logfile)
            logzero.logfile(logfile, maxBytes=LOGFILE_MAX_BYTES, backupCount=LOGFILE_BACKUP_COUNT, disableStderrLogger=args.disable_stderr)

        else:
            print("Logging to stdout and stderr")

    if args.wallet:
        if not os.path.exists(args.wallet):
            print("Wallet file not found")
            return

        passwd = os.environ.get('NEO_PYTHON_JSONRPC_WALLET_PASSWORD', None)
        if not passwd:
            passwd = PromptSession().prompt("[password]> ", is_password=True)

        password_key = to_aes_key(passwd)
        try:
            wallet = UserWallet.Open(args.wallet, password_key)
github chaostoolkit / chaostoolkit / chaostoolkit / logging.py View on Github external
fmt, json_default=encoder, timestamp=True)

    # sadly, no other way to specify the name of the default logger publicly
    LOGZERO_DEFAULT_LOGGER = logger_name
    logger = setup_default_logger(level=log_level, formatter=formatter)
    if context_id:
        logger.addFilter(ChaosToolkitContextFilter(logger_name, context_id))

    if log_file:
        # always everything as strings in the log file
        logger.setLevel(logging.DEBUG)
        fmt = "%(color)s[%(asctime)s %(levelname)s] "\
              "[%(module)s:%(lineno)d]%(end_color)s %(message)s"
        formatter = LogFormatter(fmt=fmt, datefmt="%Y-%m-%d %H:%M:%S",
                                 colors=colors)
        logzero.logfile(log_file, formatter=formatter, mode='a',
                        loglevel=logging.DEBUG)
github joeyac / crazyWx / config.py View on Github external
# path where received image, file ... saved to
DATA_PATH = os.path.join(os.getcwd(), 'data')

if DEBUG:
    logzero.loglevel(logging.DEBUG)
else:
    logzero.loglevel(logging.WARNING)


fmt = '%(color)s[%(asctime)s <%(module)s:%(funcName)s>:%(lineno)d] [%(levelname)s]%(end_color)s - %(message)s'
formatter = logzero.LogFormatter(color=True, datefmt='%Y%m%d %H:%M:%S', fmt=fmt)
file_formatter = logzero.LogFormatter(color=False, datefmt='%Y%m%d %H:%M:%S', fmt=fmt)

logzero.formatter(formatter)

logzero.logfile(filename='crazyWx.log', formatter=file_formatter,
                maxBytes=1000000, backupCount=3)

# logzero.logfile(filename='warning.log', formatter=file_formatter,
#                 maxBytes=1000000, backupCount=3, loglevel=logging.WARNING)


logzero.logger.debug("crazyWx init")


if __name__ == '__main__':
    pass
    # import time
github bennuttall / meme-overflow / example.py View on Github external
from memeoverflow import MemeOverflow
from logzero import logfile

logfile('/var/log/memeoverflow/example.log')  # optional

stackexchange = {
    'site': '',
    'key': '',
}

twitter = {
    'con_key': '',
    'con_sec': '',
    'acc_tok': '',
    'acc_sec': '',
}

imgflip = {
    'user': '',
    'pass': '',
github kpj / Vydia / vydia / core / controller.py View on Github external
def _setup_logging(self) -> None:
        # init logzero
        logzero.loglevel(logging.WARNING)
        logzero.logfile(
            self.model.LOG_FILE,
            maxBytes=1e6, backupCount=3)

        # enforce logging of unhandled exceptions
        def handle_exception(exc_type, exc_value, exc_traceback):
            logger.error(
                'Uncaught exception',
                exc_info=(exc_type, exc_value, exc_traceback))
        sys.excepthook = handle_exception
github SumoLogic / sumologic-content / sumologictoolbox / sumotoolbox.py View on Github external
from modules.field_extration_rule import field_extraction_rule_tab
from modules.content import content_tab
from modules.collector import collector_tab

#local imports
from modules.sumologic import SumoLogic
from modules.credentials import CredentialsDB
from modules.dialogs import *

# detect if in Pyinstaller package and build appropriate base directory path
if getattr(sys, 'frozen', False):
    basedir = sys._MEIPASS
else:
    basedir = os.path.dirname(os.path.abspath(__file__))
# Setup logging
logzero.logfile("sumotoolbox.log")
logzero.loglevel(level=20)  #  Info Logging
# Log messages
logger.info("SumoLogicToolBox started.")
# This script uses Qt Designer files to define the UI elements which must be loaded
qtMainWindowUI = os.path.join(basedir, 'data/sumotoolbox.ui')
Ui_MainWindow, QtBaseClass = uic.loadUiType(qtMainWindowUI)

class sumotoolbox(QtWidgets.QMainWindow, Ui_MainWindow):



    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        # detect if we are running in a pyinstaller bundle and set the base directory for file loads"
        if getattr(sys, 'frozen', False):