Skip to content

Commit 31372b4

Browse files
Remove store_time.log
With the introduction of the async store feature, it is no longer necessary to log store times in the workspace directory, as this information is now saved in the database.
1 parent a8330f0 commit 31372b4

File tree

4 files changed

+12
-53
lines changed

4 files changed

+12
-53
lines changed

codechecker_common/logger.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import json
1212
import logging
1313
from logging import config
14-
from pathlib import Path
1514
import os
1615
import sys
1716
from typing import Optional
@@ -162,10 +161,10 @@ class LogCfgServer:
162161
'CC_LOG_CONFIG_PORT' environment variable is set.
163162
"""
164163

165-
def __init__(self, log_level='INFO', workspace=None):
164+
def __init__(self, log_level='INFO'):
166165

167166
# Configure the logging with the default config.
168-
setup_logger(log_level, workspace=workspace)
167+
setup_logger(log_level)
169168

170169
self.log_server = None
171170

@@ -184,7 +183,7 @@ def __exit__(self, *args):
184183
self.log_server.join()
185184

186185

187-
def setup_logger(log_level=None, stream=None, workspace=None):
186+
def setup_logger(log_level=None, stream=None):
188187
"""
189188
Modifies the log configuration.
190189
Overwrites the log levels for the loggers and handlers in the
@@ -219,26 +218,4 @@ def setup_logger(log_level=None, stream=None, workspace=None):
219218
if 'stream' in handler:
220219
handler['stream'] = stream
221220

222-
# If workspace is set, we will log to a file in the workspace.
223-
# This is added dynamically because the declarative config
224-
# (config/logger.conf) is not flexible enough, and will always
225-
# create a log file in weird locations, before we can initialize
226-
# the filename attribute, to the workspace directories.
227-
if workspace:
228-
# Add file_handler to store_time logger,
229-
# and add the handler to the config
230-
loggers = log_config.get("loggers", {})
231-
loggers["store_time"]["handlers"].append('store_time_file_handler')
232-
233-
handlers = log_config.get("handlers", {})
234-
log_path = Path(workspace, "store_time.log")
235-
handlers["store_time_file_handler"] = {}
236-
store_time_handler = {
237-
'backupCount': 8,
238-
'class': 'logging.handlers.TimedRotatingFileHandler',
239-
"filename": log_path,
240-
'formatter': 'store_time_formatter',
241-
'interval': 7}
242-
handlers["store_time_file_handler"] = store_time_handler
243-
244221
config.dictConfig(log_config)

config/logger.conf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
"version": 1,
33
"disable_existing_loggers": true,
44
"formatters": {
5-
"store_time_formatter": {
6-
"format": "[%(levelname)s] - %(message)s"
7-
},
85
"brief": {
96
"format": "[%(levelname)s %(asctime)s] - %(message)s",
107
"datefmt": "%Y-%m-%d %H:%M"
@@ -43,10 +40,6 @@
4340
"level": "INFO",
4441
"handlers": ["console"]
4542
},
46-
"store_time": {
47-
"level": "INFO",
48-
"handlers": ["console"]
49-
},
5043
"system": {
5144
"level": "INFO",
5245
"handlers": ["console"]

web/server/codechecker_server/api/mass_store_run.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363

6464

6565
LOG = get_logger('server')
66-
STORE_TIME_LOG = get_logger('store_time')
6766

6867

6968
class StepLog:
@@ -1705,24 +1704,14 @@ def store(self,
17051704
time_spent_on_task_preparation
17061705
zip_size_kib: float = original_zip_size / 1024
17071706

1708-
LOG.info("'%s' stored results (decompressed size: %.2f KiB) "
1709-
"to run '%s' (ID: %d%s) in %.2f seconds.",
1710-
self._user_name, zip_size_kib, self._name, run_id,
1711-
f", under tag '{self._tag}'" if self._tag else "",
1712-
run_time)
1713-
1714-
iso_start_time = datetime.fromtimestamp(start_time) \
1715-
.isoformat()
1716-
1717-
log_msg = f"{iso_start_time}, " \
1718-
f"{round(run_time, 2)}s, " \
1719-
f'"{self.__product.name}", ' \
1720-
f'"{self._name}", ' \
1721-
f"{round(zip_size_kib)}KiB, " \
1722-
f"{self.__report_count}, " \
1723-
f"{run_id}"
1724-
1725-
STORE_TIME_LOG.info(log_msg)
1707+
LOG.info("User '%s' stored results "
1708+
"to product '%s', run '%s' in %.2f seconds "
1709+
"(run id: %d%s, report count: %d, "
1710+
"decompressed size: %.2f KiB).",
1711+
self._user_name, self.__product.name, self._name,
1712+
run_time, run_id,
1713+
f", under tag: '{self._tag}'" if self._tag else "",
1714+
self.__report_count, zip_size_kib)
17261715
except (sqlalchemy.exc.OperationalError,
17271716
sqlalchemy.exc.ProgrammingError) as ex:
17281717
LOG.error("Database error! Storing reports to the "

web/server/codechecker_server/cli/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ def main(args):
10771077
os.makedirs(args.config_directory)
10781078

10791079
with logger.LogCfgServer(
1080-
args.verbose if "verbose" in args else None, workspace=workspace
1080+
args.verbose if "verbose" in args else None
10811081
):
10821082
try:
10831083
cmd_config.check_config_file(args)

0 commit comments

Comments
 (0)