SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 02/03/2017, 10:52 PM   #1
TheRealSphinx
Little Clucker
 
TheRealSphinx's Avatar
 
Join Date: Nov 2016
Posts: 20
Reputation: 10
Post SPDLog - Fast async logging

Hello guys,

currently I'm refactoring my plugin and started moving some stuff to a new plugin.
I made this plugin before and I thought I can share it with you guys.

This plugin provides an API for gabime/spdlog.
With that plugin your logs doesnt block on write. You can easily write some stuff asynchronous.

Flush policies
By default spdlog lets the the underlying libc flush whenever it sees fit to achieve good performance. You can override this using the following options:
- Manual flush: LogFlush(const name[]) (See the example below)
- Flush on log level: LogFlushOn(const name[], SPDLOG_LEVEL:level)

Example ConsoleLogger
Code:
#include <a_spdlog>
#define Console "stdout"
public OnGameModeInit()
{
    // Enable async logging
    LoggerSetAsyncMode(4096);

    // Initialize logger
    ConsoleLogger(Console); // To console (no log)

    // Info (This text doesnt show up in server_log.txt)
    LogInfo(Console, "Gamemode initializing...");

    // Don't use these lines if it's a filterscript
    SetGameModeText("SPDLog Test");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);

    // Info (This text doesnt show up in server_log.txt)
    LogInfo(Console, "Gamemode initialized...");
    LogInfo(Console, "Server started or whateverr...");
    LogCritical(Console, "The server is burning! <- Colored console in samp 'WOW'");
    return 1;
}
Manual flush (BasicLogger)
You can manually flush the log using the LogFlush function.

Code:
#include <a_spdlog>
#define Log "stdlog"
public OnGameModeInit()
{
    // Enable async logging
    LoggerSetAsyncMode(4096);

    // Initialize logger
    BasicLogger(Log, "test.log"); // To console (no log)

    // Info (This text doesnt show up in server_log.txt)
    LogInfo(Log, "Gamemode initializing...");
    LogFlush(Log);    

    // Don't use these lines if it's a filterscript
    SetGameModeText("SPDLog Test");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);

    // Info (This text doesnt show up in server_log.txt)
    LogInfo(Log, "Gamemode initialized...");
    LogInfo(Log, "Server started or whateverr...");

    // Flush
    LogFlush(Log);
    return 1;
}
Don't use the example code, please change the defines to variables to lower the memory ussage.

The source code is hosted on github.
- Sphinxila/samp-plugin-spdlog

Download:
- Download Linux: Download v.1.0.0
- Download Windows: Download v.1.0.0

Support:
If you have some bugs, feel free to share that on github as an issue: Klick

The chance that I see some bug reports here are very low cause I'm not very active at this board (forum).

Kind regards
Sphinx (ProMetheus)

Last edited by TheRealSphinx; 09/05/2017 at 08:55 PM. Reason: New version available v0.0.3-alpha
TheRealSphinx is offline   Reply With Quote
Old 03/03/2017, 12:46 AM   #2
GhostHacker9
Big Clucker
 
GhostHacker9's Avatar
 
Join Date: Jan 2017
Location: Kernel
Posts: 53
Reputation: 47
Default Re: SPDLog - Fast async logging

Good 4 stars.
GhostHacker9 is offline   Reply With Quote
Old 06/03/2017, 08:30 PM   #3
nGen.SoNNy
Gangsta
 
nGen.SoNNy's Avatar
 
Join Date: Sep 2009
Location: Romania
Posts: 990
Reputation: 61
Default Re: SPDLog - Fast async logging

I will give it a shot.
__________________
If i've helped you, please click
nGen.SoNNy is offline   Reply With Quote
Old 11/03/2017, 04:17 AM   #4
TheRealSphinx
Little Clucker
 
TheRealSphinx's Avatar
 
Join Date: Nov 2016
Posts: 20
Reputation: 10
Default Re: SPDLog - Fast async logging

Fixed some issues, please use the latest release.
I will implement a version check in the next release to avoid plugin / header missmatches.

Kind regards
Sphinx
TheRealSphinx is offline   Reply With Quote
Old 27/04/2017, 02:50 AM   #5
TheRealSphinx
Little Clucker
 
TheRealSphinx's Avatar
 
Join Date: Nov 2016
Posts: 20
Reputation: 10
Default A new release - v.0.0.4

v.0.0.4-stable
  • A few bugfixes
  • Directory tree
  • Argument count
  • Version check added
  • Checks the logger version (Just OnGameModeInit)!

- Download Linux: Download v.0.0.4
- Download Windows: Download v.0.0.4
TheRealSphinx is offline   Reply With Quote
Old 09/05/2017, 08:54 PM   #6
TheRealSphinx
Little Clucker
 
TheRealSphinx's Avatar
 
Join Date: Nov 2016
Posts: 20
Reputation: 10
Default Re: SPDLog - Fast async logging

v.1.0.0-stable
  • Updated SPDLog to Gabime/spdlog.git@e9b82867144cbb70993ce3680bfb8c30a30ca27 3
  • Fixed LoggerSetLevel, LogFlushOn
  • Added LogLevel - Set log level for a specified logger.

- Download Linux: Download v.1.0.0
- Download Windows: Download v.1.0.0
TheRealSphinx is offline   Reply With Quote
Old 10/05/2017, 02:06 AM   #7
IlanZ
Gangsta
 
IlanZ's Avatar
 
Join Date: Jul 2016
Location: Brasil
Posts: 779
Reputation: 30
Default Re: SPDLog - Fast async logging

Very nice.

rep += 1;
__________________

MdK.
IlanZ is offline   Reply With Quote
Old 15/05/2017, 10:22 PM   #8
Dutheil
Godfather
 
Dutheil's Avatar
 
Join Date: Jul 2014
Location: France
Posts: 5,109
Reputation: 198
Default Re: SPDLog - Fast async logging

Nice +7rep.
__________________
#PrayForFrenchForum
GitHub

Code:
print({1214849097, 661463108, 1970563173, 1768697344});
Dutheil is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fast problem server got hacked fast fast fast Mijata Scripting Help 11 06/07/2015 01:15 AM
async/threaded calls to natives ikkentim Plugin Development 7 19/01/2015 12:47 AM
Fast help , easy problem , i rep !!! FAST . !!!!!! buburuzu19 Scripting Help 7 02/12/2014 08:29 PM
Fast please fast RemoveBuildingForPlayer Convert Doros Scripting Help 4 14/03/2014 06:24 AM
help in gates guys!!, come fast fast , i have a problem KJ1 Help Archive 9 19/07/2010 08:33 AM


All times are GMT. The time now is 06:55 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.