system/flakes/tensorflow/tf.py

24 lines
694 B
Python
Raw Normal View History

2025-05-03 12:34:07 -04:00
import tensorflow as tf
import re
# Create a summary writer
logdir = "logs/"
writer = tf.summary.create_file_writer(logdir)
# Read the journalctl logs
with open("ollama.log", "r") as f:
for line in f:
# Example: Parse the log line (you may need to adjust this regex)
match = re.search(r'(\d+-\d+-\d+ \d+:\d+:\d+).*?(\w+): (.*)', line)
if match:
timestamp = match.group(1)
log_level = match.group(2)
message = match.group(3)
# Write to TensorBoard
with writer.as_default():
tf.summary.text("log_message", f"{timestamp} [{log_level}] {message}", step=0)
# Close the writer
writer.close()