Skip to content

Latest commit

 

History

History
95 lines (72 loc) · 2.15 KB

File metadata and controls

95 lines (72 loc) · 2.15 KB

Chat Logger Plugin

Logs all chat messages to a file in various formats.

Features

  • Multiple output formats (JSON, CSV, plain text)
  • Configurable log file location
  • Optional system message logging
  • File rotation support
  • Statistics and management commands

Configuration

config:
  enabled: true
  log_file: "~/.socialpie/logs/chat.log"
  format: "json"  # json, text, or csv
  include_system_messages: false
  rotate_size: "10MB"

Options

  • enabled (boolean): Enable or disable logging
  • log_file (string): Path to log file (supports ~ for home directory)
  • format (string): Log format - json, text, or csv
  • include_system_messages (boolean): Whether to log system messages
  • rotate_size (string): Maximum log file size before rotation

Commands

  • /logstats - Show logging statistics
  • /clearlog confirm - Clear the chat log (requires confirmation)

Permissions Required

  • filesystem.write - To write log files
  • messages.read - To read messages for logging

Example Output

JSON Format

{"timestamp": "2026-01-25T10:30:45.123456", "type": "chat", "user": "Alice", "content": "Hello!", "metadata": {}}
{"timestamp": "2026-01-25T10:30:47.654321", "type": "chat", "user": "Bob", "content": "Hi Alice!", "metadata": {}}

CSV Format

timestamp,type,user,content
"2026-01-25T10:30:45.123456","chat","Alice","Hello!"
"2026-01-25T10:30:47.654321","chat","Bob","Hi Alice!"

Text Format

--- Chat Log Started: 2026-01-25T10:30:00.000000 ---
[2026-01-25 10:30:45] Alice: Hello!
[2026-01-25 10:30:47] Bob: Hi Alice!

Usage Example

# Start server with chat logger enabled
socialpie server

# Check logging stats
/logstats
# Chat Logger Statistics:
#   Messages logged: 42
#   Log file: /home/user/.socialpie/logs/chat.log
#   File size: 0.15 MB
#   Format: json

# Clear log (careful!)
/clearlog confirm
# Chat log cleared. 42 messages removed.

Development

This plugin demonstrates:

  • Hooks (@hook) for message interception
  • Async file I/O with aiofiles
  • Commands with confirmation
  • Configuration handling
  • File system operations
  • Error handling

License

GPL-3.0-or-later