Example #1
0
def configure_logging(postfix):
    """Configure logging for the Node.

    @param postfix: the postfix for the log files.
    @type postfix: str
    """
    try:
        # pylint:disable=F0401
        from node_magic import MIN_STDOUT_LOG_LEVEL as min_stdout_log_level
        # pylint:enable=F0401
    except ImportError:
        min_stdout_log_level = None

    try:
        # pylint:disable=F0401
        from node_magic import MIN_FILE_LOG_LEVEL as min_file_log_level
        # pylint:enable=F0401
    except ImportError:
        min_file_log_level = None

    common_logger.configure_logging(
        dir_path=get_log_directory(),
        prefix='node',
        postfix=postfix,
        log_level_stdout_override=min_stdout_log_level,
        log_level_file_override=min_file_log_level,
        debug_to_stdout=True,
        limit=LOG_ROTATE_MAX_BYTES,
        backup_count=LOG_ROTATE_MAX_BACKUPS)
Example #2
0
def configure_logging(postfix):
    """Configure logging for the Node.

    @param postfix: the postfix for the log files.
    @type postfix: str
    """
    try:
        # pylint:disable=F0401
        from node_magic import MIN_STDOUT_LOG_LEVEL as min_stdout_log_level
        # pylint:enable=F0401
    except ImportError:
        min_stdout_log_level = None

    try:
        # pylint:disable=F0401
        from node_magic import MIN_FILE_LOG_LEVEL as min_file_log_level
        # pylint:enable=F0401
    except ImportError:
        min_file_log_level = None

    common_logger.configure_logging(
        dir_path=get_log_directory(),
        prefix='node',
        postfix=postfix,
        log_level_stdout_override=min_stdout_log_level,
        log_level_file_override=min_file_log_level,
        debug_to_stdout=True,
        limit=LOG_ROTATE_MAX_BYTES,
        backup_count=LOG_ROTATE_MAX_BACKUPS)
Example #3
0
    def main():
        from twisted.internet import reactor
        from common.twisted_utils import callLaterInThread
        print reactor
        if len(sys.argv) < 2:
            print('Pass the directory to watch!')
        else:
            _dir = sys.argv[1]
            manager = FSNotifyManager()
            print('Watching {!r}'.format(_dir))
            manager.watch(_dir, on_event_received)
            #callLaterInThread(1, create_test_file, _dir)
            reactor.run()  # pylint:disable=E1101


    if __name__ == '__main__':
        import sys
        sys.path.insert(0, '.')
        from common.system import install_reactor; 'OPTIONAL'  # snakefood
        import logging
        logging.basicConfig(level=logging.INFO)
        from common.logger import configure_logging
        configure_logging('./', 'test_notify')
        logger = logging.getLogger(__name__)
        install_reactor(force_reactor_name='qt4')
        from uhost import fs_notify; 'OPTIONAL'  # snakefood
        fs_notify.main()


__all__ = ('enable',)
Example #4
0
    def main():
        from twisted.internet import reactor
        from common.twisted_utils import callLaterInThread
        print reactor
        if len(sys.argv) < 2:
            print('Pass the directory to watch!')
        else:
            _dir = sys.argv[1]
            manager = FSNotifyManager()
            print('Watching {!r}'.format(_dir))
            manager.watch(_dir, on_event_received)
            #callLaterInThread(1, create_test_file, _dir)
            reactor.run()  # pylint:disable=E1101

    if __name__ == '__main__':
        import sys
        sys.path.insert(0, '.')
        from common.system import install_reactor
        'OPTIONAL'  # snakefood
        import logging
        logging.basicConfig(level=logging.INFO)
        from common.logger import configure_logging
        configure_logging('./', 'test_notify')
        logger = logging.getLogger(__name__)
        install_reactor(force_reactor_name='qt4')
        from uhost import fs_notify
        'OPTIONAL'  # snakefood
        fs_notify.main()

__all__ = ('enable', )