Skip to content

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

License

Notifications You must be signed in to change notification settings

maddinat0r/samp-log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

samp-log Build status

sampctl

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published