Is there a way to stop UT from adding null bytes in logfiles? Basically, if a webserver and a UT server are on the same machine, my idea was to write a log to the webserver directory, and then use the HTTP functions to read whatever is written. Basically, as an 'external config' of sorts. Of course, when it reads these logs it stops after the first character because of the null bytes.
tl;dr Can you stop nullbytes being added to the logs?
Nullbytes in logs
-
JackGriffin
- Godlike
- Posts: 3829
- Joined: Fri Jan 14, 2011 1:53 pm
- Personal rank: -Retired-
Re: Nullbytes in logs
You could script something external that parses the logs, removing the nulls. The way they are written from the engine though you are stuck with.
So long, and thanks for all the fish
-
anth
- Adept
- Posts: 257
- Joined: Thu May 13, 2010 2:23 am
Re: Nullbytes in logs
If you buffer all the stuff you want to write to the log and then use some bit shifting while dumping the buffer, you can log in plain ansi as well (but there might be a double NULL at the end).
-
anth
- Adept
- Posts: 257
- Joined: Thu May 13, 2010 2:23 am
Re: Nullbytes in logs
You could try this (untested!)
Code: Select all
class BufferedFileWriter extends StatLogFile;
var string LogBuffer;
// =============================================================================
// PostBeginPlay - Test!
// =============================================================================
function PostBeginPlay()
{
local int i;
InitWriter("test.log", "../Logs");
for (i = 0; i < 2048; ++i)
LogLine("This is a pointless test" @ i);
CloseWriter();
}
// =============================================================================
// InitWriter
// =============================================================================
function InitWriter(string FileName, string FilePath)
{
StatLogFile = FilePath $ "/" $ FileName $ ".tmp";
StatLogFinal = FilePath $ "/" $ FileName;
OpenLog();
}
// =============================================================================
// LogLine - Use this function to dump into the buffer
// =============================================================================
function LogLine (string Line)
{
LogBuffer = LogBuffer $ Line $ chr(13) $ chr(10); // append CR, LF
}
// =============================================================================
// CloseWriter - Dumps the buffer in ANSI format, then closes the log
// Technically this still logs in UTF-16LE but the output looks like ANSI oO
// =============================================================================
function CloseWriter()
{
local int i, outChar;
local string tmpChar, outBuffer;
for (i = 0; i < Len(LogBuffer); ++i)
{
tmpChar = Mid(LogBuffer, i, 1);
if (i % 2 == 0)
{
outChar = Asc(tmpChar);
}
else
{
outChar = outChar + (Asc(tmpChar) << 8);
outBuffer = outBuffer $ chr(outChar);
outChar = 0;
}
}
// buffer contained an odd number of chars
// => append a trailing space
if (outChar != 0)
{
outChar = outChar + (32 << 8);
outBuffer = outBuffer $ chr(outChar);
}
Log("Logging " $ Len(outBuffer) $ " bytes.");
FileLog(outBuffer);
FlushLog();
CloseLog();
}
// =============================================================================
// Timer - Don't log connection info
// =============================================================================
function Timer() {}
-
Meindratheal
- Average
- Posts: 61
- Joined: Thu Jun 03, 2010 3:53 pm
-
FraGnBraG
- Inhuman
- Posts: 930
- Joined: Sun Jun 13, 2010 5:13 pm
- Personal rank: Good news everyone!
- Location: Canada
Re: Nullbytes in logs
do you guys think a specific actor can be scripted to essentially write a specified text message into the log for purposes of testing path usage - for example, you have three routes in a ctf map, so you place one actor per path (between two pathnodes) with each actor having a different assigned message - like "path 1 bot <botname>". This would be useful when adjusting alt-paths etc when balancing pathes... not sure but maybe a new trigger type that contains log-writing code similar to what you've described...
-
JackGriffin
- Godlike
- Posts: 3829
- Joined: Fri Jan 14, 2011 1:53 pm
- Personal rank: -Retired-
Re: Nullbytes in logs
Sure that would be easily done. You could even use the same actor in all and have it log like:
<Actor/Actor Tag> was triggered/touched by <instigator> and their state is <instigator.state> (Roaming, attacking, defending...this could be germane to why a path is ignored more)
I did a redo of the mod Mindreader and made it work with Scripted Pawn. I was simply amazed watching the monsters decision making and how much is going on ALL the time.
<Actor/Actor Tag> was triggered/touched by <instigator> and their state is <instigator.state> (Roaming, attacking, defending...this could be germane to why a path is ignored more)
I did a redo of the mod Mindreader and made it work with Scripted Pawn. I was simply amazed watching the monsters decision making and how much is going on ALL the time.
So long, and thanks for all the fish