Feature Request: Add a debug setting for how many lines of history to show when LogShowHistory

LogShowHistoryLines is the setting
This change cleans up some very C code in lllogchat.cpp
This commit is contained in:
Inusaito Sayori
2013-09-14 20:55:19 -04:00
parent 9b984d425d
commit 0b20babd35
2 changed files with 19 additions and 36 deletions

View File

@@ -846,6 +846,19 @@ Found in Advanced->Rendering->Info Displays</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>LogShowHistoryLines</key>
<map>
<key>Comment</key>
<string>Lines of history to load from log file if LogShowHistory is true.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>32</integer>
<key>IsCOA</key>
<integer>1</integer>
</map>
<key>ContactsUseHorizontalButtons</key>
<map>
<key>Comment</key>

View File

@@ -36,9 +36,7 @@
#include "lllogchat.h"
#include "llappviewer.h"
#include "llfloaterchat.h"
#include "llviewercontrol.h"
const S32 LOG_RECALL_SIZE = 2048;
//static
std::string LLLogChat::makeLogFileName(std::string filename)
@@ -137,47 +135,19 @@ void LLLogChat::loadHistory(std::string const& filename , void (*callback)(ELogL
return ;
}
LLFILE* fptr = LLFile::fopen(makeLogFileName(filename), "r"); /*Flawfinder: ignore*/
if (!fptr)
llifstream ifstr(makeLogFileName(filename));
if (!ifstr.is_open())
{
//LLUIString message = LLFloaterChat::getInstance()->getString("IM_logging_string");
//callback(LOG_EMPTY,"IM_logging_string",userdata);
callback(LOG_EMPTY,LLStringUtil::null,userdata);
return; //No previous conversation with this name.
}
else
{
char buffer[LOG_RECALL_SIZE]; /*Flawfinder: ignore*/
char *bptr;
S32 len;
bool firstline=TRUE;
if ( fseek(fptr, (LOG_RECALL_SIZE - 1) * -1 , SEEK_END) )
{ //File is smaller than recall size. Get it all.
firstline = FALSE;
if ( fseek(fptr, 0, SEEK_SET) )
{
fclose(fptr);
return;
}
}
while ( fgets(buffer, LOG_RECALL_SIZE, fptr) && !feof(fptr) )
static const LLCachedControl<U32> lines("LogShowHistoryLines", 32);
std::string line;
for (U32 i = 0; i < lines && getline(ifstr, line); ++i)
{
len = strlen(buffer) - 1; /*Flawfinder: ignore*/
for ( bptr = (buffer + len); (*bptr == '\n' || *bptr == '\r') && bptr>buffer; bptr--) *bptr='\0';
if (!firstline)
{
callback(LOG_LINE,std::string(buffer),userdata);
}
else
{
firstline = FALSE;
}
callback(LOG_LINE, line, userdata);
}
callback(LOG_END,LLStringUtil::null,userdata);
fclose(fptr);
}
}