# 📝 Logger

## Logger

The logger writes down what happens on your lobby. Every event is written to `logs/latest.log` and can be sent to Discord at the same time.

Each event is turned on or off on its own and has its own message, webhook and embed, so joins can go to one channel and chat to another.

Everything is set up in `logger.yml`.

### Events

| Event                    | Logged when                                            |
| ------------------------ | ------------------------------------------------------ |
| player-join              | A player joins the lobby                               |
| player-leave             | A player disconnects, not when they change server      |
| player-switch-server     | A player is sent to another server of the proxy        |
| player-anti-vpn          | A player is denied by the anti vpn                     |
| player-anti-wdl          | A player tries to use a world downloader               |
| player-pvp-join          | A player enters pvp mode                               |
| player-pvp-leave         | A player leaves pvp mode                               |
| server-anti-botting      | The anti bot starts a lockdown                         |
| player-anti-swear        | A message is blocked or censored by the chat filter    |
| player-command-execution | A player runs a command                                |
| player-chat-message      | A player sends a message                               |

### Message

The message of an event is written in **log-format**. It is the line that goes to the log file, and it is also what `%message%` gives you inside the webhook.

Every event has its own placeholders.

| Event                    | Placeholders                                                              |
| ------------------------ | ------------------------------------------------------------------------- |
| player-join              | %player%, %uuid%, %address%, %world%, %online%                             |
| player-leave             | %player%, %uuid%, %address%, %world%, %online%                             |
| player-switch-server     | %player%, %uuid%, %server%, %world%                                        |
| player-anti-vpn          | %player%, %uuid%, %address%                                                |
| player-anti-wdl          | %player%, %uuid%, %world%                                                  |
| player-pvp-join          | %player%, %uuid%, %world%                                                  |
| player-pvp-leave         | %player%, %uuid%, %world%                                                  |
| server-anti-botting      | %attempts%, %seconds%, %lockdown\_seconds%                                 |
| player-anti-swear        | %player%, %uuid%, %world%, %message\_content%, %action%                    |
| player-command-execution | %player%, %uuid%, %world%, %command%                                       |
| player-chat-message      | %player%, %uuid%, %world%, %message\_content%                              |

%action% returns blocked or censored. On the chat filter event %message\_content% is what the player typed, before it was censored.

### Webhook

Paste the address of your Discord webhook in **url** and that event starts posting. An empty url means nothing is sent, so you only fill in the events you care about.

**username** and **avatar-url** change how the bot shows up, and **content** is a plain message sent above the embed.

The embed is yours to shape with a title, a description, a colour, a footer, a thumbnail, an image and as many fields as you want. The placeholders of the event work in all of them.

<details>

<summary>Logger logger.yml</summary>

```yaml
enabled: true
file-logging:
  enabled: true
events:
  player-join:
    enabled: true
    log-format: '%player% joined the lobby from %address%. (%online% online)'
    webhook:
      enabled: true
      url: ''
      username: Phoenix Lobby - Logger
      avatar-url: ''
      content: ''
      embed:
        enabled: true
        title: Player Join
        description: '%message%'
        color: '#43b581'
        url: ''
        thumbnail-url: ''
        image-url: ''
        footer:
          text: ''
          icon-url: ''
        fields:
        - name: Player
          value: '%player%'
          inline: true
        - name: Address
          value: '%address%'
          inline: true
        - name: Online
          value: '%online%'
          inline: true
```

</details>

> **Info:**
The other events follow the same shape, each one with its own message, colour and fields.

> **Info:**
Telling a disconnect apart from a server change is done by the proxy, so `player-switch-server` needs PhoenixLobby installed on the proxy as well. Without it, a player changing server is logged as a leave.

Source: https://www.phoenixplugins.com/docs/phoenix-lobby/featues/logger