24 lines
806 B
Python
24 lines
806 B
Python
# .agent/tools/append_log.py
|
|
import sys
|
|
import datetime
|
|
|
|
def append_to_log(filename, content):
|
|
"""Adiciona conteúdo ao final de um arquivo MD com Timestamp."""
|
|
|
|
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
formatted_entry = f"\n\n### 📝 Registro: {timestamp}\n{content}\n"
|
|
|
|
try:
|
|
with open(filename, 'a', encoding='utf-8') as f:
|
|
f.write(formatted_entry)
|
|
return f"✅ Registro adicionado em {filename} com sucesso."
|
|
except Exception as e:
|
|
return f"❌ Erro ao escrever log: {e}"
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 3:
|
|
print("Uso: python append_log.py log.md \"Texto a ser salvo\"")
|
|
else:
|
|
file = sys.argv[1]
|
|
text = " ".join(sys.argv[2:])
|
|
print(append_to_log(file, text)) |