diff --git a/gns3server/main.py b/gns3server/main.py index 85b752f7..ab5dc816 100644 --- a/gns3server/main.py +++ b/gns3server/main.py @@ -97,25 +97,25 @@ def main(): raise SystemExit current_year = datetime.date.today().year - if options.quiet: - log.info("GNS3 server version {}".format(__version__)) - log.info("Copyright (c) 2007-{} GNS3 Technologies Inc.".format(current_year)) - else: - print("GNS3 server version {}".format(__version__)) - print("Copyright (c) 2007-{} GNS3 Technologies Inc.".format(current_year)) + + user_log = logging.getLogger('user_facing') + if not options.quiet: + # Send user facing messages to stdout. + stream_handler = logging.StreamHandler(sys.stdout) + stream_handler.addFilter(logging.Filter(name='user_facing')) + user_log.addHandler(stream_handler) + user_log.propagate = False + + user_log.info("GNS3 server version {}".format(__version__)) + user_log.info("Copyright (c) 2007-{} GNS3 Technologies Inc.".format(current_year)) # we only support Python 3 version >= 3.3 if sys.version_info < (3, 3): raise RuntimeError("Python 3.3 or higher is required") - if options.quiet: - log.info("Running with Python {major}.{minor}.{micro} and has PID {pid}".format( - major=sys.version_info[0], minor=sys.version_info[1], - micro=sys.version_info[2], pid=os.getpid())) - else: - print("Running with Python {major}.{minor}.{micro} and has PID {pid}".format( - major=sys.version_info[0], minor=sys.version_info[1], - micro=sys.version_info[2], pid=os.getpid())) + user_log.info("Running with Python {major}.{minor}.{micro} and has PID {pid}".format( + major=sys.version_info[0], minor=sys.version_info[1], + micro=sys.version_info[2], pid=os.getpid())) # check for the correct locale # (UNIX/Linux only) diff --git a/gns3server/server.py b/gns3server/server.py index 8452f085..f8af00db 100644 --- a/gns3server/server.py +++ b/gns3server/server.py @@ -50,6 +50,7 @@ from .modules import MODULES import logging log = logging.getLogger(__name__) + class Server(object): # built-in handlers @@ -189,12 +190,9 @@ class Server(object): **settings) # FIXME: debug mode! try: - if self._quiet: - log.info("Starting server on {}:{} (Tornado v{}, PyZMQ v{}, ZMQ v{})".format( - self._host, self._port, tornado.version, zmq.__version__, zmq.zmq_version())) - else: - print("Starting server on {}:{} (Tornado v{}, PyZMQ v{}, ZMQ v{})".format( - self._host, self._port, tornado.version, zmq.__version__, zmq.zmq_version())) + user_log = logging.getLogger('user_facing') + user_log.info("Starting server on {}:{} (Tornado v{}, PyZMQ v{}, ZMQ v{})".format( + self._host, self._port, tornado.version, zmq.__version__, zmq.zmq_version())) kwargs = {"address": self._host} @@ -233,10 +231,7 @@ class Server(object): try: ioloop.start() except (KeyboardInterrupt, SystemExit): - if self._quiet: - log.info("\nExiting...") - else: - print("\nExiting...") + log.info("\nExiting...") self._cleanup() def _create_zmq_router(self): diff --git a/gns3server/version.py b/gns3server/version.py index c206840a..86927195 100644 --- a/gns3server/version.py +++ b/gns3server/version.py @@ -23,5 +23,5 @@ # or negative for a release candidate or beta (after the base version # number has been incremented) -__version__ = "1.0beta1" +__version__ = "dev-gns-108-ca9d" __version_info__ = (1, 0, 0, -99)