Skip to content

Commit

Permalink
tools: write offline_log_viewer kvstore/controller output to stdout
Browse files Browse the repository at this point in the history
On stderr it gets mixed with logs.  On stdout it is
straightforward to capture and decode json for use in tests.
  • Loading branch information
jcsp committed Dec 15, 2022
1 parent ef54142 commit e168164
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tools/offline_log_viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,32 @@


def print_kv_store(store):
# Map of partition ID to list of kvstore items
result = {}

for ntp in store.ntps:
if ntp.nspace == "redpanda" and ntp.topic == "kvstore":
logger.info(f"inspecting {ntp}")
kv = KvStore(ntp)
kv.decode()
items = kv.items()
logger.info(json.dumps(items, indent=2))

result[ntp.partition] = items

# Send JSON output to stdout in case caller wants to parse it, other
# CLI output goes to stderr via logger
print(json.dumps(result, indent=2))


def print_controller(store, bin_dump: bool):
for ntp in store.ntps:
if ntp.nspace == "redpanda" and ntp.topic == "controller":
ctrl = ControllerLog(ntp)
ctrl.decode(bin_dump)
logger.info(json.dumps(ctrl.records, indent=2))

# Send JSON output to stdout in case caller wants to parse it, other
# CLI output goes to stderr via logger
print(json.dumps(ctrl.records, indent=2))


def print_kafka(store, topic, headers_only):
Expand Down

0 comments on commit e168164

Please sign in to comment.