Merge "added process pid to the end of storage node log lines"
This commit is contained in:
commit
3a723e2c22
@ -131,4 +131,5 @@ user_agent The value of the HTTP User-Agent header. Swift's proxy
|
||||
``"proxy-server <pid of the proxy>".``
|
||||
request_time The duration of the request.
|
||||
additional_info Additional useful information.
|
||||
server_pid The process id of the server
|
||||
=================== ==========================================================
|
||||
|
@ -324,13 +324,14 @@ def get_log_line(req, res, trans_time, additional_info):
|
||||
:returns: a properly formated line for logging.
|
||||
"""
|
||||
|
||||
return '%s - - [%s] "%s %s" %s %s "%s" "%s" "%s" %.4f "%s"' % (
|
||||
return '%s - - [%s] "%s %s" %s %s "%s" "%s" "%s" %.4f "%s" %d' % (
|
||||
req.remote_addr,
|
||||
time.strftime('%d/%b/%Y:%H:%M:%S +0000', time.gmtime()),
|
||||
req.method, req.path, res.status.split()[0],
|
||||
res.content_length or '-', req.referer or '-',
|
||||
req.headers.get('x-trans-id', '-'),
|
||||
req.user_agent or '-', trans_time, additional_info or '-')
|
||||
req.user_agent or '-', trans_time, additional_info or '-',
|
||||
os.getpid())
|
||||
|
||||
|
||||
def get_trans_id_time(trans_id):
|
||||
|
@ -1669,11 +1669,13 @@ class TestAccountController(unittest.TestCase):
|
||||
with mock.patch(
|
||||
'time.time',
|
||||
mock.MagicMock(side_effect=[10000.0, 10001.0, 10002.0])):
|
||||
req.get_response(self.controller)
|
||||
with mock.patch(
|
||||
'os.getpid', mock.MagicMock(return_value=1234)):
|
||||
req.get_response(self.controller)
|
||||
self.assertEqual(
|
||||
self.controller.logger.log_dict['info'],
|
||||
[(('1.2.3.4 - - [01/Jan/1970:02:46:41 +0000] "HEAD /sda1/p/a" 404 '
|
||||
'- "-" "-" "-" 2.0000 "-"',), {})])
|
||||
'- "-" "-" "-" 2.0000 "-" 1234',), {})])
|
||||
|
||||
def test_policy_stats_with_legacy(self):
|
||||
ts = itertools.count()
|
||||
|
@ -2574,14 +2574,17 @@ cluster_dfw1 = http://dfw1.host/v1/
|
||||
res = Response()
|
||||
trans_time = 1.2
|
||||
additional_info = 'some information'
|
||||
server_pid = 1234
|
||||
exp_line = '1.2.3.4 - - [01/Jan/1970:02:46:41 +0000] "HEAD ' \
|
||||
'/sda1/p/a/c/o" 200 - "-" "-" "-" 1.2000 "some information"'
|
||||
'/sda1/p/a/c/o" 200 - "-" "-" "-" 1.2000 "some information" 1234'
|
||||
with mock.patch(
|
||||
'time.gmtime',
|
||||
mock.MagicMock(side_effect=[time.gmtime(10001.0)])):
|
||||
self.assertEquals(
|
||||
exp_line,
|
||||
utils.get_log_line(req, res, trans_time, additional_info))
|
||||
with mock.patch(
|
||||
'os.getpid', mock.MagicMock(return_value=server_pid)):
|
||||
self.assertEquals(
|
||||
exp_line,
|
||||
utils.get_log_line(req, res, trans_time, additional_info))
|
||||
|
||||
def test_cache_from_env(self):
|
||||
# should never get logging when swift.cache is found
|
||||
|
@ -2542,11 +2542,13 @@ class TestContainerController(unittest.TestCase):
|
||||
with mock.patch(
|
||||
'time.time',
|
||||
mock.MagicMock(side_effect=[10000.0, 10001.0, 10002.0])):
|
||||
req.get_response(self.controller)
|
||||
with mock.patch(
|
||||
'os.getpid', mock.MagicMock(return_value=1234)):
|
||||
req.get_response(self.controller)
|
||||
self.assertEqual(
|
||||
self.controller.logger.log_dict['info'],
|
||||
[(('1.2.3.4 - - [01/Jan/1970:02:46:41 +0000] "HEAD /sda1/p/a/c" '
|
||||
'404 - "-" "-" "-" 2.0000 "-"',), {})])
|
||||
'404 - "-" "-" "-" 2.0000 "-" 1234',), {})])
|
||||
|
||||
|
||||
@patch_policies([
|
||||
|
@ -3909,14 +3909,17 @@ class TestObjectController(unittest.TestCase):
|
||||
with mock.patch('time.time',
|
||||
mock.MagicMock(side_effect=[10000.0,
|
||||
10001.0])):
|
||||
response = self.object_controller.__call__(
|
||||
env, start_response)
|
||||
self.assertEqual(response, answer)
|
||||
self.assertEqual(
|
||||
self.object_controller.logger.log_dict['info'],
|
||||
[(('None - - [01/Jan/1970:02:46:41 +0000] "PUT'
|
||||
' /sda1/p/a/c/o" 405 - "-" "-" "-" 1.0000 "-"',),
|
||||
{})])
|
||||
with mock.patch('os.getpid',
|
||||
mock.MagicMock(return_value=1234)):
|
||||
response = self.object_controller.__call__(
|
||||
env, start_response)
|
||||
self.assertEqual(response, answer)
|
||||
self.assertEqual(
|
||||
self.object_controller.logger.log_dict['info'],
|
||||
[(('None - - [01/Jan/1970:02:46:41 +0000] "PUT'
|
||||
' /sda1/p/a/c/o" 405 - "-" "-" "-" 1.0000 "-"'
|
||||
' 1234',),
|
||||
{})])
|
||||
|
||||
def test_not_utf8_and_not_logging_requests(self):
|
||||
inbuf = StringIO()
|
||||
@ -4059,11 +4062,13 @@ class TestObjectController(unittest.TestCase):
|
||||
with mock.patch(
|
||||
'time.time',
|
||||
mock.MagicMock(side_effect=[10000.0, 10001.0, 10002.0])):
|
||||
req.get_response(self.object_controller)
|
||||
with mock.patch(
|
||||
'os.getpid', mock.MagicMock(return_value=1234)):
|
||||
req.get_response(self.object_controller)
|
||||
self.assertEqual(
|
||||
self.object_controller.logger.log_dict['info'],
|
||||
[(('1.2.3.4 - - [01/Jan/1970:02:46:41 +0000] "HEAD /sda1/p/a/c/o" '
|
||||
'404 - "-" "-" "-" 2.0000 "-"',), {})])
|
||||
'404 - "-" "-" "-" 2.0000 "-" 1234',), {})])
|
||||
|
||||
@patch_policies([storage_policy.StoragePolicy(0, 'zero', True),
|
||||
storage_policy.StoragePolicy(1, 'one', False)])
|
||||
|
Loading…
x
Reference in New Issue
Block a user