User-configurable log filename date formatting (When using "Append date to log filename")

The old defaults remain the same, so no worries for old users of this feature
Modify LogFileLocalChatDateFormat and LogFileIMsDateFormat in debug settings, use strftime's format specifiers.
The above mentioned settings are per account.

Inspired by irssi
This commit is contained in:
Inusaito Sayori
2013-08-15 23:25:00 -04:00
parent a5287ee975
commit 6910a2feca
2 changed files with 28 additions and 4 deletions

View File

@@ -588,7 +588,7 @@
<key>LogFileNamewithDate</key>
<map>
<key>Comment</key>
<string>Add Date Stamp to chat and IM Logs with format chat-YYYY-MM-DD and 'IM file name'-YYYY-MM. To view old logs goto ..\Second Life\[login name]</string>
<string>Add Date Stamp to local chat log as specified by LogFileLocalChatDateFormat and IM logs as specified by LogFileIMsDateFormat. To view old logs goto ..\Second Life\[login name]</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@@ -596,6 +596,28 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>LogFileLocalChatDateFormat</key>
<map>
<key>Comment</key>
<string>When LogFileNamewithDate is true, this is the format used append the date to the log name for Local Chat (Default is -%Y-%m-%d resulting in chat-YYYY-MM-DD)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string>-%Y-%m-%d</string>
</map>
<key>LogFileIMsDateFormat</key>
<map>
<key>Comment</key>
<string>When LogFileNamewithDate is true, this is the format used append the date to the log names for IMs (Default is -%Y-%m resulting in 'IM file name'-YYYY-MM)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string>-%Y-%m</string>
</map>
<key>KeywordsChangeColor</key>
<map>

View File

@@ -47,14 +47,16 @@ std::string LLLogChat::makeLogFileName(std::string filename)
{
time_t now;
time(&now);
char dbuffer[20]; /* Flawfinder: ignore */
char dbuffer[100]; /* Flawfinder: ignore */
if (filename == "chat")
{
strftime(dbuffer, 20, "-%Y-%m-%d", localtime(&now));
static const LLCachedControl<std::string> local_chat_date_format(gSavedPerAccountSettings, "LogFileLocalChatDateFormat", "-%Y-%m-%d");
strftime(dbuffer, 100, local_chat_date_format().c_str(), localtime(&now));
}
else
{
strftime(dbuffer, 20, "-%Y-%m", localtime(&now));
static const LLCachedControl<std::string> ims_date_format(gSavedPerAccountSettings, "LogFileIMsDateFormat", "-%Y-%m");
strftime(dbuffer, 100, ims_date_format().c_str(), localtime(&now));
}
filename += dbuffer;
}