samp.directory
← Scripts and libraries

maddinat0r/samp-log

plugin which utilizes the log core utility to provide a fast and efficient log mechanism

Plugin★ 27updated Mar 2021MITC++sampctl
Open on GitHub

Install with sampctl

sampctl package install maddinat0r/samp-log

Run this in your project folder. sampctl downloads the package and what it depends on.

Try it in the Pawn compiler →

Adds its include files, with the libraries it depends on, to the Pawn compiler in your browser, ready to include in a script.

README.md

samp-log

Installation

Simply install to your project:

sampctl package install maddinat0r/samp-log

Include in your code and begin using the library:

#include <log-plugin>

Usage

gamemode.pwn:

#include <a_samp>
#include <log-plugin>


new
    Logger:mainlog,
    Logger:playerlog,
    Logger:playermoneylog,
    Logger:systemlog;

public OnGameModeInit()
{
    mainlog = CreateLog("main");
    playerlog = CreateLog("player/main");
    playermoneylog = CreateLog("player/money");
    systemlog = CreateLog("system");
    
    Log(mainlog, INFO, "created all loggers");
    Log(playerlog, WARNING, "playerid %d is moving too %s", 1234, "fast");
    Log(playermoneylog, ERROR, "invalid amount %f", 3.14532);
    Log(systemlog, DEBUG, "update took %d seconds", 4321);
    return 1;
}


public OnGameModeExit()
{
    DestroyLog(mainlog);
    DestroyLog(playerlog);
    DestroyLog(playermoneylog);
    DestroyLog(systemlog);
    return 1;
}

log-config.yml:

Logger:
  plugins/log-plugin:
    Append: false # deletes the plugin log file on server startup
  main:
    LogLevel:
      - Fatal
      - Error
      - Warning
      - Info
  player/main:
    LogLevel: All
  player/money:
    LogLevel:
      - Error
      - Warning
  system:
    LogLevel: None
  samp-server: # see "Server console redirection" down below
    LogLevel: All
LogLevel:
  Fatal:
    PrintToConsole: true
  Error:
    PrintToConsole: true
  Warning:
    PrintToConsole: true
EnableColors: true
LogTimeFormat: '%F %H:%M:%S'

Server console redirection

When adding logplugin_capture_serverlog 1 to the server.cfg file, the plugin will redirect all console output (starting at the time of the plugin being loaded and ending when it's unloaded) to a logger named samp-server. This logger is configurable like every other logger. Almost all console messages are logged with the INFO log level (run time errors are logged as FATAL), so make sure to at least enable this log level to see any output in the log file.

cpploggersa-mp

This page is built from what GitHub publishes about the repository. samp.directory does not host the code. Report a problem with this listing

maddinat0r/samp-log: SA-MP Plugin | samp.directory