Skip to content

Commit

Permalink
Avoid double logging to file handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jleaniz committed Aug 8, 2024
1 parent 644e2a1 commit 8e71247
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
10 changes: 0 additions & 10 deletions test_data/turbinia_logs.log
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
2024-08-08 16:52:48,110 [INFO] uvicorn.error | Application startup complete.
2024-08-08 16:52:48,110 [INFO] uvicorn.error | Application startup complete.
2024-08-08 16:52:48,124 [INFO] uvicorn.error | Started server process [1232189]
2024-08-08 16:52:48,124 [INFO] uvicorn.error | Started server process [1232189]
2024-08-08 16:52:48,124 [INFO] uvicorn.error | Waiting for application startup.
2024-08-08 16:52:48,124 [INFO] uvicorn.error | Waiting for application startup.
2024-08-08 16:52:48,124 [INFO] uvicorn.error | Application startup complete.
2024-08-08 16:52:48,124 [INFO] uvicorn.error | Application startup complete.
2024-08-08 16:52:48,136 [INFO] uvicorn.error | Started server process [1232191]
2024-08-08 16:52:48,136 [INFO] uvicorn.error | Started server process [1232191]
2024-08-08 16:52:48,137 [INFO] uvicorn.error | Waiting for application startup.
2024-08-08 16:52:48,137 [INFO] uvicorn.error | Waiting for application startup.
2024-08-08 16:52:48,137 [INFO] uvicorn.error | Application startup complete.
2024-08-08 16:52:48,137 [INFO] uvicorn.error | Application startup complete.
2024-08-08 16:52:50,468 [INFO] uvicorn.access | 127.0.0.1:39730 - "GET /api/logs/api_server/100 HTTP/1.1" 200
2024-08-08 16:52:50,468 [INFO] uvicorn.access | 127.0.0.1:39730 - "GET /api/logs/api_server/100 HTTP/1.1" 200
2024-08-08 16:53:26,287 [INFO] uvicorn.access | 127.0.0.1:53206 - "GET /api/logs/logs/ed6c72f82d42/100 HTTP/1.1" 200
2024-08-08 16:53:26,287 [INFO] uvicorn.access | 127.0.0.1:53206 - "GET /api/logs/logs/ed6c72f82d42/100 HTTP/1.1" 200
2024-08-08 16:53:51,856 [INFO] uvicorn.access | 127.0.0.1:33544 - "GET /openapi.yaml HTTP/1.1" 200
2024-08-08 16:53:51,856 [INFO] uvicorn.access | 127.0.0.1:33544 - "GET /openapi.yaml HTTP/1.1" 200
6 changes: 3 additions & 3 deletions turbinia/api/api_server_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,10 @@ def testGetTurbiniaLogs(self):
turbinia_config.LOG_DIR = test_data_dir
with open(f'{test_data_dir}/turbinia_logs.log', 'rb') as f:
expected = f.read()
response = self.client.get(f'/api/logs/{hostname}/20')
self.assertEqual(response.content, expected)
response = self.client.get(f'/api/logs/{hostname}/10')
self.assertEqual(response.content, expected)
response = self.client.get(f'/api/logs/{hostname}/5')
self.assertNotEqual(response.content, expected)
hostname = 'invalid_hostname'
response = self.client.get(f'/api/logs/{hostname}/20')
response = self.client.get(f'/api/logs/{hostname}/10')
self.assertEqual(response.status_code, 404)
2 changes: 0 additions & 2 deletions turbinia/config/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ def setup(need_file_handler=True, need_stream_handler=True, log_file_path=None):
for handler in root_log.handlers:
root_log.removeHandler(handler)
root_log.addHandler(console_handler)
if need_file_handler:
root_log.addHandler(file_handler)

# Set up uvicorn loggers
uvicron_error = logging.getLogger('uvicorn.error')
Expand Down

0 comments on commit 8e71247

Please sign in to comment.