Track version info, and make available for logging.

This commit is contained in:
Todd Willey 2011-01-06 15:08:26 -05:00
parent ada65e007e
commit 13b1374897
2 changed files with 43 additions and 10 deletions

View File

@ -34,24 +34,19 @@ import logging.handlers
import traceback
from nova import flags
# TODO(todd): fix after version.py merge
# from nova import version
from nova import version
FLAGS = flags.FLAGS
# TODO(todd): fix after version.py merge
# '(%(name)s %(nova_version)s): %(levelname)s '
flags.DEFINE_string('logging_context_format_string',
'(%(name)s): %(levelname)s '
'(%(name)s %(nova_version)s): %(levelname)s '
'[%(request_id)s %(user)s '
'%(project)s] %(message)s',
'format string to use for log messages')
# TODO(todd): fix after version.py merge
# '(%(name)s %(nova_version)s): %(levelname)s [N/A] '
flags.DEFINE_string('logging_default_format_string',
'(%(name)s): %(levelname)s [N/A] '
'(%(name)s %(nova_version)s): %(levelname)s [N/A] '
'%(message)s',
'format string to use for log messages')
@ -163,8 +158,7 @@ class NovaLogger(logging.Logger):
extra = {}
if context:
extra.update(_dictify_context(context))
# TODO(todd): fix after version.py merge
#extra.update({"nova_version": version.string_with_vcs()})
extra.update({"nova_version": version.string_with_vcs()})
logging.Logger._log(self, level, msg, args, exc_info, extra)
def addHandler(self, handler):

View File

@ -25,6 +25,45 @@ from sphinx.setup_command import BuildDoc
from nova.utils import parse_mailmap, str_dict_replace
NOVA_VERSION = ['2011', '1']
VERSIONFILE_DEFAULT_VCS_VERSION = """
version_info = {"branch_nick": "LOCALBRANCH", "revision_id": "LOCALREVISION"}
"""
VERSIONFILE_DATA = """
# below this line automatically generated by setup.py
YEAR = %r
COUNT = %r
""" % (NOVA_VERSION[0], NOVA_VERSION[1])
VERSIONFILE_DATA += """
def string():
return '.'.join([YEAR, COUNT])
def vcs_version_string():
return "%s:%s" % (version_info['branch_nick'], version_info['revision_id'])
def string_with_vcs():
return "%s-%s" % (string(), vcs_version_string())
"""
with open("nova/version.py", 'w') as version_file:
if os.path.isdir('.bzr'):
vcs_cmd = subprocess.Popen(["bzr", "version-info", "--python"],
stdout=subprocess.PIPE)
vcsversion = vcs_cmd.communicate()[0]
version_file.write(vcsversion)
else:
version_file.write(VERSIONFILE_DEFAULT_VCS_VERSION)
version_file.write(VERSIONFILE_DATA)
class local_BuildDoc(BuildDoc):
def run(self):
for builder in ['html', 'man']: