# Logs

## Features

* **Dual Provider Support**: Send logs to Discord Webhooks or Fivemanage
* **Batch Processing**: Efficient log queuing and batch sending
* **Multi-App Support**: Dedicated logging for different phone apps
* **Customizable Formatting**: Rich embeds and custom metadata

## Configuration

Configure logging in `config/config.logs.lua`:

```lua
Config.Logs = {}
Config.Logs.Provider = 'discord' -- Options: 'discord', 'fivemanage'
Config.Logs.Timeout = 30 -- Time in seconds before queued logs are sent

-- Color Configuration
Config.Logs.Colors = {
    ['instashots'] = 15884387,
    ['phone'] = 009966,
    -- ... other apps
}
```

### 1. Discord Webhooks (Default)

Add the webhooks to your `server.cfg`:

```cfg
# Social Media
set yseriesInstashotsPostsLogs "WEBHOOK_URL"
set yseriesInstashotsMessagesLogs "WEBHOOK_URL"
set yseriesYPostsLogs "WEBHOOK_URL"
set yseriesYMessagesLogs "WEBHOOK_URL"

# Communications
set yseriesPhoneLogs "WEBHOOK_URL"
set yseriesMessagesLogs "WEBHOOK_URL"
set yseriesDarkChatLogs "WEBHOOK_URL"

# Commerce & Companies
set yseriesYPayLogs "WEBHOOK_URL"
set yseriesYBuyLogs "WEBHOOK_URL"
set yseriesCompaniesLogs "WEBHOOK_URL"
set yseriesPromoHubLogs "WEBHOOK_URL"
```

### 2. Fivemanage Integration

1. **Enable Fivemanage**: Set `Config.Logs.Provider = 'fivemanage'` in `config/config.logs.lua`.
2. **Set API Key**: Add your Fivemanage Logs API Key to your `server.cfg`. (Obtain from Fivemanage Dashboard)

```cfg
set yseriesApiKeyLogs "YOUR_FIVEMANAGE_LOGS_API_KEY"
```

3. **View Logs**: Logs will appear in your Fivemanage Dashboard with rich metadata filtering (Author, App, Resource, etc.).

## Supported Log Types

* **Social Media**: InstaShots (Posts/Messages), Y (Posts/Messages)
* **Communications**: Phone Calls, SMS, DarkChat
* **E-Commerce**: YBuy (Listings/Sales), YPay (Transfers), PromoHub
* **Jobs**: Company Duty & Activities

### Batch Processing

Logs are automatically batched for efficiency:

* **Queue Size**: Sends immediately when 10 logs are queued
* **Timeout**: Sends all queued logs after configured timeout (default 30 seconds)
* **Memory Management**: Automatic queue cleanup after sending

## Security Considerations

### Webhook Protection

1. **Secure Storage**: Store webhook URLs in `server.cfg` using convars (as shown above)
2. **Access Control**: Restrict access to your `server.cfg` file - only server administrators should have access

## Troubleshooting

### Common Issues

1. **Logs not appearing in Discord**:
   * Check webhook URLs are correct and active
   * Verify Discord channel permissions
   * Check server console for HTTP errors
2. **Partial log information**:
   * Ensure all required fields are provided
   * Check specialized formatter implementations
   * Verify additionalData structure
3. **Rate limiting issues**:
   * Increase timeout value to batch more logs
   * Check Discord rate limit responses

***
