samp.directory
← Scripts et bibliothèques

maddinat0r/samp-log

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

Plugin★ 27mis à jour mars 2021MITC++sampctl
Ouvrir sur GitHub

Installer avec sampctl

sampctl package install maddinat0r/samp-log

Lance ceci dans le dossier de ton projet. sampctl télécharge le paquet et ce dont il dépend.

L’essayer dans le compilateur Pawn →

Ajoute ses fichiers include, avec les bibliothèques dont il dépend, au compilateur Pawn de ton navigateur, prêts à être inclus dans un 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

Cette page est construite à partir de ce que GitHub publie sur le dépôt. samp.directory n’héberge pas le code. Signaler un problème avec cette fiche

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