From 9469c47f86e08e7eb8f8f526f289f081c700ba8f Mon Sep 17 00:00:00 2001 From: Ahmed Muawia Khan Date: Thu, 20 Sep 2018 12:19:13 +0200 Subject: [PATCH] Problem: BigchainDB benchmark logs are not needed --- bigchaindb/core.py | 10 ++---- bigchaindb/log.py | 31 +------------------ docs/server/source/appendices/log-rotation.md | 1 - .../source/server-reference/configuration.md | 4 +-- setup.py | 6 +--- tests/conftest.py | 4 --- 6 files changed, 7 insertions(+), 49 deletions(-) diff --git a/bigchaindb/core.py b/bigchaindb/core.py index 8be3cdaf..d7b98183 100644 --- a/bigchaindb/core.py +++ b/bigchaindb/core.py @@ -146,16 +146,13 @@ class App(BaseApplication): self.abort_if_abci_chain_is_not_synced() - logger.benchmark('CHECK_TX_INIT') logger.debug('check_tx: %s', raw_transaction) transaction = decode_transaction(raw_transaction) if self.bigchaindb.is_valid_transaction(transaction): logger.debug('check_tx: VALID') - logger.benchmark('CHECK_TX_END, tx_id:%s', transaction['id']) return ResponseCheckTx(code=CodeTypeOk) else: logger.debug('check_tx: INVALID') - logger.benchmark('CHECK_TX_END, tx_id:%s', transaction['id']) return ResponseCheckTx(code=CodeTypeError) def begin_block(self, req_begin_block): @@ -167,9 +164,9 @@ class App(BaseApplication): self.abort_if_abci_chain_is_not_synced() chain_shift = 0 if self.chain is None else self.chain['height'] - logger.benchmark('BEGIN BLOCK, height:%s, num_txs:%s', - req_begin_block.header.height + chain_shift, - req_begin_block.header.num_txs) + logger.debug('BEGIN BLOCK, height:%s, num_txs:%s', + req_begin_block.header.height + chain_shift, + req_begin_block.header.num_txs) self.block_txn_ids = [] self.block_transactions = [] @@ -253,7 +250,6 @@ class App(BaseApplication): logger.debug('Commit-ing new block with hash: apphash=%s ,' 'height=%s, txn ids=%s', data, self.new_height, self.block_txn_ids) - logger.benchmark('COMMIT_BLOCK, height:%s', self.new_height) if self.events_queue: event = Event(EventTypes.BLOCK_VALID, { diff --git a/bigchaindb/log.py b/bigchaindb/log.py index 6b6ba931..7650c37b 100644 --- a/bigchaindb/log.py +++ b/bigchaindb/log.py @@ -11,8 +11,6 @@ import os DEFAULT_LOG_DIR = os.getcwd() -BENCHMARK_LOG_LEVEL = 15 - DEFAULT_LOGGING_CONFIG = { 'version': 1, @@ -29,11 +27,6 @@ DEFAULT_LOGGING_CONFIG = { 'format': ('[%(asctime)s] [%(levelname)s] (%(name)s) ' '%(message)s (%(processName)-10s - pid: %(process)d)'), 'datefmt': '%Y-%m-%d %H:%M:%S', - }, - 'benchmark': { - 'class': 'logging.Formatter', - 'format': ('%(asctime)s, %(levelname)s, %(message)s'), - 'datefmt': '%Y-%m-%d %H:%M:%S', } }, 'handlers': { @@ -59,31 +52,15 @@ DEFAULT_LOGGING_CONFIG = { 'backupCount': 5, 'formatter': 'file', 'level': logging.ERROR, - }, - 'benchmark': { - 'class': 'logging.handlers.RotatingFileHandler', - 'filename': os.path.join(DEFAULT_LOG_DIR, 'bigchaindb-benchmark.log'), - 'mode': 'w', - 'maxBytes': 209715200, - 'backupCount': 5, - 'formatter': 'benchmark', - 'level': BENCHMARK_LOG_LEVEL, } }, 'loggers': {}, 'root': { 'level': logging.DEBUG, - 'handlers': ['console', 'file', 'errors', 'benchmark'], + 'handlers': ['console', 'file', 'errors'], }, } - -def benchmark(self, message, *args, **kws): - # Yes, logger takes its '*args' as 'args'. - if self.isEnabledFor(BENCHMARK_LOG_LEVEL): - self._log(BENCHMARK_LOG_LEVEL, message, args, **kws) - - def _normalize_log_level(level): try: return level.upper() @@ -104,11 +81,6 @@ def setup_logging(): """ - # Add a new logging level for logging benchmark - logging.addLevelName(BENCHMARK_LOG_LEVEL, 'BENCHMARK') - logging.BENCHMARK = BENCHMARK_LOG_LEVEL - logging.Logger.benchmark = benchmark - logging_configs = DEFAULT_LOGGING_CONFIG new_logging_configs = bigchaindb.config['log'] @@ -127,7 +99,6 @@ def setup_logging(): if 'level_logfile' in new_logging_configs: level = _normalize_log_level(new_logging_configs['level_logfile']) logging_configs['handlers']['file']['level'] = level - logging_configs['handlers']['benchmark']['level'] = level if 'fmt_console' in new_logging_configs: fmt = new_logging_configs['fmt_console'] diff --git a/docs/server/source/appendices/log-rotation.md b/docs/server/source/appendices/log-rotation.md index 25c0cd6e..95d52115 100644 --- a/docs/server/source/appendices/log-rotation.md +++ b/docs/server/source/appendices/log-rotation.md @@ -25,7 +25,6 @@ please refer to [MongoDB docs](https://docs.mongodb.com/v3.6/tutorial/rotate-log Log rotation is baked into BigchainDB server using the `logging` module. BigchainDB server logs information into the following files: - `bigchaindb.log` - `bigchaindb-errors.log` - - `bigchaindb-benchmark.log` These log files are created by default in the directory from where you run `bigchaindb start`, if you are using `monit`, from [How to Set Up a BigchainDB Network](../simple-deployment-template/network-setup.md) guide, the default directory is: `$HOME/.bigchaindb-monit/logs` diff --git a/docs/server/source/server-reference/configuration.md b/docs/server/source/server-reference/configuration.md index 47d06de8..66d9f23f 100644 --- a/docs/server/source/server-reference/configuration.md +++ b/docs/server/source/server-reference/configuration.md @@ -292,7 +292,7 @@ defined by [Python](https://docs.python.org/3.6/library/logging.html#levels), but case-insensitive for the sake of convenience: ```text -"critical", "error", "warning", "info", "benchmark", "debug", "notset" +"critical", "error", "warning", "info", "debug", "notset" ``` ### log.level_logfile @@ -302,7 +302,7 @@ defined by [Python](https://docs.python.org/3.6/library/logging.html#levels), but case-insensitive for the sake of convenience: ```text -"critical", "error", "warning", "info", "benchmark", "debug", "notset" +"critical", "error", "warning", "info", "debug", "notset" ``` ### log.datefmt_console diff --git a/setup.py b/setup.py index 4181bddf..3bb2151c 100644 --- a/setup.py +++ b/setup.py @@ -71,10 +71,6 @@ tests_require = [ 'tox', ] + docs_require -benchmarks_require = [ - 'line-profiler==1.0', -] - install_requires = [ # TODO Consider not installing the db drivers, or putting them in extras. 'pymongo~=3.6', @@ -144,7 +140,7 @@ setup( tests_require=tests_require, extras_require={ 'test': tests_require, - 'dev': dev_require + tests_require + docs_require + benchmarks_require, + 'dev': dev_require + tests_require + docs_require, 'docs': docs_require, }, package_data={'bigchaindb.common.schema': ['*.yaml']}, diff --git a/tests/conftest.py b/tests/conftest.py index 90d54dea..ebbcc110 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -108,10 +108,6 @@ def _configure_bigchaindb(request): config = config_utils.env_config(config) config_utils.set_config(config) - # NOTE: since we use a custom log level - # for benchmark logging we need to setup logging - setup_logging() - @pytest.fixture(scope='session') def _setup_database(_configure_bigchaindb):