That's because you're doing it only in
OnPluginStart which is called only once after server start or when you (re)load the plugin manually.
You should rebuild the path at least in
OnMapStart which is called after every map change.
The better way is to create a repeating timer (for example, with interval of 1 minute) and rebuild path in timer's callback.
And the best way is to rebuild path before every
LogToFile call which is slightly unoptimized but still fast enough.
Code:
stock void LogToDateFile(const char[] message, any ...) {
char sMessage[512];
VFormat( sMessage, sizeof sMessage, message, 2 );
char sTime[12], sPath[PLATFORM_MAX_PATH];
FormatTime( sTime, sizeof sTime, "%F", GetTime() );
BuildPath( Path_SM, sPath, sizeof sPath, "logs/test/custom_%s.log", sTime );
LogToFile( sPath, "%s", sMessage );
}
In this case you don't need
g_sPath and can just call
LogToDateFile every time.
__________________