πŸͺ΅Logs

The TGG Banking system includes a comprehensive logging mechanism that tracks and reports various banking activities including account operations, transactions, card management, and loan activities.

Overview

The TGG Banking system automatically logs all important banking activities to your database. These logs can be used for auditing, debugging, and tracking player actions. The logging system is built-in and requires no additional configuration - logs are automatically created when banking operations occur.

Features

  • Automatic Logging: All banking operations are automatically logged

  • Database Storage: Logs are stored in the tgg_banking_logs database table

  • Event Integration: Logs trigger server events for external integrations

  • Discord Webhook Support: Built-in Discord webhook integration via custom file

  • Comprehensive Coverage: Tracks accounts, cards, transactions, and loans

  • Player Tracking: All logs include player identifiers and IBANs

  • Batch Processing: Logs are queued and sent in batches for efficiency

Configuration

Discord Webhook Setup

The banking system includes a built-in Discord webhook integration. To enable it:

  1. Create a Discord Webhook:

    • Go to your Discord server settings

    • Navigate to Integrations β†’ Webhooks

    • Create a new webhook and copy the webhook URL

  2. Add the Convar to server.cfg:

    set bankingLogs "YOUR_DISCORD_WEBHOOK_URL_HERE"
  3. Restart the Resource:

    restart tgg-banking

Custom Logs Configuration

The logging system uses server/custom/logs.lua for Discord webhook integration. You can customize this file:

Excluding Log Types

To prevent certain log types from being sent to Discord, edit server/custom/logs.lua:

Adjusting Batch Timeout

By default, logs are sent every 10 seconds if the queue hasn't reached 10 logs. To change this:

Batch Size

Logs are automatically sent when 10 logs are queued for the same IBAN. This is hardcoded in the file but can be modified:

Log Types

The banking system uses predefined log types. Here are all available log types:

Account Operations

Log Type
Description

account_created

Account was created

account_name_updated

Account name was changed

account_freeze

Account was frozen

account_freeze_failed

Account freeze attempt failed

account_unfreeze

Account was unfrozen

account_unfreeze_failed

Account unfreeze attempt failed

account_terminate

Account was terminated

account_terminate_failed

Account termination attempt failed

account_transfer_ownership

Account ownership was transferred

account_transfer_ownership_failed

Account ownership transfer failed

Account Members

Log Type
Description

account_member_added

Member was added to an account

account_member_removed

Member was removed from an account

account_member_modified

Member permissions were modified

Transactions

Log Type
Description

deposit

Money was deposited to an account

withdraw

Money was withdrawn from an account

transfer

Money was transferred between accounts

Card Operations

Log Type
Description

card_created

A new card was created

card_item_given

Card item was given to player

card_frozen

Card was frozen

card_unfrozen

Card was unfrozen

card_terminated

Card was terminated

card_name_updated

Card name was updated

card_limits_updated

Card limits were updated

pin_changed_successfully

PIN was successfully changed

pin_change_failed

PIN change attempt failed

card_frozen_due_to_too_many_attempts

Card was frozen due to too many failed PIN attempts

Loan Operations

Log Type
Description

loan

Loan was created

loan_application

Loan application was submitted

loan_approved

Loan was approved

loan_rejected

Loan was rejected

loan_created

Loan was created and approved

loan_payment

Loan payment was made

loan_payoff

Loan was paid off

loan_overdue

Loan payment became overdue

Savings Accounts

Log Type
Description

interest_earned

Interest was earned on a savings account

early_withdrawal_penalty

Early withdrawal penalty was applied to a savings account

Custom Logs

Log Type
Description

custom

Custom log type for special cases

Server Event Integration

When a log is created, the system automatically triggers a server event that can be used for external integrations (Discord webhooks, logging systems, etc.):

Event Parameters

  • iban (string): The IBAN of the account related to the log

  • playerId (string): The identifier of the player who performed the action

  • logType (string): The type of log (from LogType enum)

  • logMessage (string): A descriptive message about what happened

Custom Event Handler

If you want to create your own logging system instead of using the built-in server/custom/logs.lua, you can listen to the event:

Note: The built-in server/custom/logs.lua file already handles Discord webhook integration. You only need to create a custom handler if you want different behavior or integration with other services.

Last updated