Zainstaluj za pomocą sampctl
sampctl package install Southclaws/samp-logger
Uruchom to w folderze swojego projektu. sampctl pobiera pakiet i to, od czego zależy.
Dodaje jej pliki include, razem z bibliotekami, od których zależy, do kompilatora Pawn w twojej przeglądarce, gotowe do dołączenia w skrypcie.
Zależy od 2 pakietów
- pawn-lang/samp-stdlib★ 53
- amyrahmady/samp-plugin-crashdetectnie ma go w tym katalogu
Używany przez 33 pakiety
- Southclaws/ScavengeSurvive★ 115
- Southclaws/progress2★ 72
- MatheusAgL/BrasilNewStart-samp★ 18
- Southclaws/samp-geoip★ 14
- Southclaws/samp-zipline★ 10
- Southclaws/modio★ 9
- ScavengeSurvive/item★ 7
- ScavengeSurvive/inventory★ 7
- Southclaws/samp-attachedit★ 6
- Southclaws/samp-ini★ 6
- ScavengeSurvive/button★ 5
- ScavengeSurvive/personal-space★ 5
- ScavengeSurvive/weapons★ 4
- TradeWars/gamemode★ 4
- ScavengeSurvive/container★ 3
- blefverse/bmsa-stdlib★ 3
- blefverse/bmsa-public★ 3
- play-verse/playverse★ 3
- ScavengeSurvive/settings★ 3
- ScavengeSurvive/fireworks★ 2
- ScavengeSurvive/language★ 2
- boxg-lv/mtb3-base★ 2
- ScavengeSurvive/health★ 2
- ScavengeSurvive/chat★ 2
- ScavengeSurvive/item-dictionary★ 2
- ScavengeSurvive/itemtype-bag★ 2
- boxg-lv/mtb3-demo★ 2
- jizzydotb/AttDef★ 1
- ScavengeSurvive/item-array-data★ 1
- emmett-white/samp-conquest-dm★ 1
i jeszcze 3
README.md
samp-logger
This is a simple structured logger which provides a simple set of functions for logging and debugging.
Installation
Simply install to your project:
sampctl package install Southclaws/samp-logger
Include in your code and begin using the library:
#include <logger>
Usage
To log an event:
Logger_Log("something happened!");
To log an event with values to give the event more context:
Logger_Log("player changed world",
Logger_S("name", playerName),
Logger_I("worldid", 4));
This would be printed as:
text="player changed world" name="Southclaws" worldid=4
Which means you can easily read the log. The description of the event is isolated from the parameters instead of being mixed up in a sentence such as player Southclaws changed to world id 4. This also means the log is now very easy to parse automatically and process in some way.
Debugging
The library also includes a basic debug mechanism which uses the SVar system to facilitate named debug handlers which can be turned on and off at runtime.
The syntax is the same for Logger_Dbg as Logger_Log but with one extra parameter which describes the debug handler name:
Logger_ToggleDebug("weapons", true); // activate the "weapons" debug handler
Logger_Dbg("weapons", "player changed weapon",
Logger_I("weaponid", 31));
Extending
The logging functions are just string concatenation functions. All Logger_S and friends do is format the string into a key=value format and simply return the string. So it's easy to write your own field converters:
stock Logger_W(const field[], weaponid) {
new result[MAX_FIELD_NAME + 1 + MAX_FIELD_VALUE];
new weaponName[32];
GetWeaponName(weaponid, weaponName, 32);
formatex(result, sizeof(result), "%s=\"%s\"", field, weaponName);
return LOGGER_FIELD:result;
}
Development
To run tests, simply build and run the package:
sampctl package run --forceBuild --forceEnsure
Ta strona jest zbudowana z tego, co GitHub publikuje o repozytorium. samp.directory nie hostuje kodu. Zgłoś problem z tym wpisem