Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v6
- name: Setup SourcePawn Compiler
uses: rumblefrog/setup-sp@v1.2.4
uses: rumblefrog/setup-sp@v1.3.1
with:
version: "1.12.x"

- name: Prepare publish
run: |
pwsh prepare-publish.ps1
- name: Upload artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
# Artifact name
name: ftp-files
Expand All @@ -40,20 +40,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download files
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
# Artifact name
name: ftp-files
# Destination path
path: ftp/
- name: Set up node
uses: actions/setup-node@v2
uses: actions/setup-node@v6
with:
node-version: 16
node-version: 24
- name: Install npm packages
run: npm install fs path
- name: Create release
uses: actions/github-script@v6
uses: actions/github-script@v9
with:
script: |
const fs = require('fs');
Expand Down
69 changes: 38 additions & 31 deletions logstf/logstf.sp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ Release notes:
- Fixed unnecessary tournament restart when server is almost empty


---- 2.8.0 (23/05/2026) ----
- Reduced lag during mid-round log upload - by Arie


TODO:
- Some people run multiple instances of the same server (located in the same directory). This is a problem, because they all write to the same logstf.log file. Make the logstf.log and -partial files have dynamic names, and don't forget to clean them up.
- Sanitize names for < and >, since logs.tf doesn't like those
Expand All @@ -154,7 +158,7 @@ TODO:
#undef REQUIRE_PLUGIN
#include <updater>

#define PLUGIN_VERSION "2.7.1"
#define PLUGIN_VERSION "2.8.0"
#define UPDATE_URL "https://sourcemod.krus.dk/logstf/update.txt"

#define LOG_PATH "logstf.log"
Expand Down Expand Up @@ -701,47 +705,50 @@ void UploadLog(bool partial) {
g_bIsUploading = true;
g_bIsPartialUpload = partial;

// Note: If you are making changes related to title generation, also update supstats2.
char title[128];
g_hCvarTitle.GetString(title, sizeof(title));
ReplaceString(title, sizeof(title), "{server}", g_sCachedHostname, false);
ReplaceString(title, sizeof(title), "{blu}", g_sCachedBluTeamName, false);
ReplaceString(title, sizeof(title), "{blue}", g_sCachedBluTeamName, false);
ReplaceString(title, sizeof(title), "{red}", g_sCachedRedTeamName, false);

char path[64], partialpath[64];
char path[64];
GetLogPath(LOG_PATH, path, sizeof(path));
GetLogPath(PLOG_PATH, partialpath, sizeof(partialpath));

if (partial) {
char partialpath[64];
GetLogPath(PLOG_PATH, partialpath, sizeof(partialpath));
DeleteFile(partialpath);
if (!CopyFile(path, partialpath)) {
LogError("Failed to create partial log file");
g_bIsUploading = false;
if (g_bReuploadASAP) {
g_bReuploadASAP = false;
UploadLog(false);
}
return;
AnyHttp_CopyFile(path, partialpath, UploadLog_CopyComplete);
} else {
MC_PrintToChatAll("%s", "{lightgreen}[LogsTF] {blue}Uploading logs...");
UploadLog_Send(path);
}
}

void UploadLog_CopyComplete(bool success, any metadata) {
if (!success) {
LogError("Failed to create partial log file");
g_bIsUploading = false;
if (g_bReuploadASAP) {
g_bReuploadASAP = false;
UploadLog(false);
}
return;
}

// We should NOT add a Round_Stalemate just after a round has ended (logs.tf will not understand it)
//char buffer[128];
//char time[32];
//FormatTime(time, sizeof(time), "%m/%d/%Y - %H:%M:%S");
//FormatEx(buffer, sizeof(buffer), "\nL %s: %s\n", time, "World triggered \"Round_Stalemate\"");
char partialpath[64];
GetLogPath(PLOG_PATH, partialpath, sizeof(partialpath));
UploadLog_Send(partialpath);
}

//Handle file = OpenFile(partialpath, "a");
//WriteFileString(file, buffer, false);
//delete file;
}
void UploadLog_Send(const char[] logpath) {
char title[128];
g_hCvarTitle.GetString(title, sizeof(title));
ReplaceString(title, sizeof(title), "{server}", g_sCachedHostname, false);
ReplaceString(title, sizeof(title), "{blu}", g_sCachedBluTeamName, false);
ReplaceString(title, sizeof(title), "{blue}", g_sCachedBluTeamName, false);
ReplaceString(title, sizeof(title), "{red}", g_sCachedRedTeamName, false);

if (!partial)
MC_PrintToChatAll("%s", "{lightgreen}[LogsTF] {blue}Uploading logs...");
char apiKey[64];
g_hCvarApikey.GetString(apiKey, sizeof(apiKey));

AnyHttpRequest req = AnyHttp.CreatePost("http://logs.tf/upload");

req.PutFile("logfile", partial ? partialpath : path);
req.PutFile("logfile", logpath);
req.PutString("title", title);
req.PutString("map", g_sCachedMap);
req.PutString("key", apiKey);
Expand Down
6 changes: 3 additions & 3 deletions logstf/update.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
{
"Version"
{
"Latest" "2.7.1"
"Latest" "2.8.0"
}

"Notes" "Changes in 2.7.1:"
"Notes" "- Fixed unnecessary tournament restart when server is almost empty"
"Notes" "Changes in 2.8.0:"
"Notes" "- Reduced lag during mid-round log upload - by Arie"
}

"Files"
Expand Down