mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-11-10 12:29:49 +03:00
add debug option to log all SQL commands (#8324)
This commit is contained in:
parent
2db9944687
commit
6d60bfd58d
@ -58,6 +58,7 @@ from chia.util.ints import uint8, uint32, uint64, uint128
|
||||
from chia.util.path import mkdir, path_from_root
|
||||
from chia.util.safe_cancel_task import cancel_task_safe
|
||||
from chia.util.profiler import profile_task
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class FullNode:
|
||||
@ -121,6 +122,17 @@ class FullNode:
|
||||
self.new_peak_sem = asyncio.Semaphore(8)
|
||||
# create the store (db) and full node instance
|
||||
self.connection = await aiosqlite.connect(self.db_path)
|
||||
if self.config.get("log_sqlite_cmds", False):
|
||||
sql_log_path = path_from_root(self.root_path, "log/sql.log")
|
||||
self.log.info(f"logging SQL commands to {sql_log_path}")
|
||||
|
||||
def sql_trace_callback(req: str):
|
||||
timestamp = datetime.now().strftime("%H:%M:%S.%f")
|
||||
log = open(sql_log_path, "a")
|
||||
log.write(timestamp + " " + req + "\n")
|
||||
log.close()
|
||||
|
||||
await self.connection.set_trace_callback(sql_trace_callback)
|
||||
self.db_wrapper = DBWrapper(self.connection)
|
||||
self.block_store = await BlockStore.create(self.db_wrapper)
|
||||
self.sync_store = await SyncStore.create()
|
||||
|
@ -304,6 +304,10 @@ full_node:
|
||||
# analyze with chia/utils/profiler.py
|
||||
enable_profiler: False
|
||||
|
||||
# this is a debug and profiling facility that logs all SQLite commands to a
|
||||
# separate log file (under logging/sql.log).
|
||||
log_sqlite_cmds: False
|
||||
|
||||
# List of trusted DNS seeders to bootstrap from.
|
||||
# If you modify this, please change the hardcode as well from FullNode.set_server()
|
||||
dns_servers:
|
||||
|
Loading…
Reference in New Issue
Block a user