1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Use logging config to set destination of copyright info

This commit is contained in:
Jerry Seutter 2014-09-29 15:56:01 -06:00
parent 23686215fe
commit 91fba4aca4
3 changed files with 20 additions and 25 deletions

View File

@ -97,23 +97,23 @@ def main():
raise SystemExit raise SystemExit
current_year = datetime.date.today().year current_year = datetime.date.today().year
if options.quiet:
log.info("GNS3 server version {}".format(__version__)) user_log = logging.getLogger('user_facing')
log.info("Copyright (c) 2007-{} GNS3 Technologies Inc.".format(current_year)) if not options.quiet:
else: # Send user facing messages to stdout.
print("GNS3 server version {}".format(__version__)) stream_handler = logging.StreamHandler(sys.stdout)
print("Copyright (c) 2007-{} GNS3 Technologies Inc.".format(current_year)) 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 # we only support Python 3 version >= 3.3
if sys.version_info < (3, 3): if sys.version_info < (3, 3):
raise RuntimeError("Python 3.3 or higher is required") raise RuntimeError("Python 3.3 or higher is required")
if options.quiet: user_log.info("Running with Python {major}.{minor}.{micro} and has PID {pid}".format(
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], major=sys.version_info[0], minor=sys.version_info[1],
micro=sys.version_info[2], pid=os.getpid())) micro=sys.version_info[2], pid=os.getpid()))

View File

@ -50,6 +50,7 @@ from .modules import MODULES
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class Server(object): class Server(object):
# built-in handlers # built-in handlers
@ -189,11 +190,8 @@ class Server(object):
**settings) # FIXME: debug mode! **settings) # FIXME: debug mode!
try: try:
if self._quiet: user_log = logging.getLogger('user_facing')
log.info("Starting server on {}:{} (Tornado v{}, PyZMQ v{}, ZMQ v{})".format( user_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())) self._host, self._port, tornado.version, zmq.__version__, zmq.zmq_version()))
kwargs = {"address": self._host} kwargs = {"address": self._host}
@ -233,10 +231,7 @@ class Server(object):
try: try:
ioloop.start() ioloop.start()
except (KeyboardInterrupt, SystemExit): except (KeyboardInterrupt, SystemExit):
if self._quiet:
log.info("\nExiting...") log.info("\nExiting...")
else:
print("\nExiting...")
self._cleanup() self._cleanup()
def _create_zmq_router(self): def _create_zmq_router(self):

View File

@ -23,5 +23,5 @@
# or negative for a release candidate or beta (after the base version # or negative for a release candidate or beta (after the base version
# number has been incremented) # number has been incremented)
__version__ = "1.0beta1" __version__ = "dev-gns-108-ca9d"
__version_info__ = (1, 0, 0, -99) __version_info__ = (1, 0, 0, -99)