diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 19d054606..b91b24665 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -7133,7 +7133,7 @@ This should be as low as possible, but too low may break functionality Type Boolean Value - 0 + 1 FloaterAboutRect diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index 029a2c4df..fdc576a79 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -76,30 +76,41 @@ std::string LLLogChat::cleanFileName(std::string filename) return filename; } +static void time_format(std::string& out, const char* fmt, const std::tm* time) +{ + typedef typename std::vector> vec_t; + static thread_local vec_t charvector(1024); // Evolves into charveleon + #define format_the_time() std::strftime(charvector.data(), charvector.capacity(), fmt, time) + const auto smallsize(charvector.capacity()); + const auto size = format_the_time(); + if (size < 0) + { + LL_ERRS() << "Formatting time failed, code " << size << ". String hint: " << out << '/' << fmt << LL_ENDL; + } + else if (static_cast(size) >= smallsize) // Resize if we need more space + { + charvector.resize(1+size); // Use the String Stone + format_the_time(); + } + out.assign(charvector.data()); +} + + std::string LLLogChat::timestamp(bool withdate) { - time_t utc_time; - utc_time = time_corrected(); - - // There's only one internal tm buffer. - struct tm* timep; - // Convert to Pacific, based on server's opinion of whether // it's daylight savings time there. - timep = utc_to_pacific_time(utc_time, gPacificDaylightTime); + auto time = utc_to_pacific_time(time_corrected(), gPacificDaylightTime); - static LLCachedControl withseconds("SecondsInLog"); - std::string text; - if (withdate) - if (withseconds) - text = llformat("[%d/%02d/%02d %02d:%02d:%02d] ", (timep->tm_year-100)+2000, timep->tm_mon+1, timep->tm_mday, timep->tm_hour, timep->tm_min, timep->tm_sec); - else - text = llformat("[%d/%02d/%02d %02d:%02d] ", (timep->tm_year-100)+2000, timep->tm_mon+1, timep->tm_mday, timep->tm_hour, timep->tm_min); - else - if (withseconds) - text = llformat("[%02d:%02d:%02d] ", timep->tm_hour, timep->tm_min, timep->tm_sec); - else - text = llformat("[%02d:%02d] ", timep->tm_hour, timep->tm_min); + static const LLCachedControl withseconds("SecondsInLog"); + static const LLCachedControl date("ShortDateFormat"); + static const LLCachedControl shorttime("ShortTimeFormat"); + static const LLCachedControl longtime("LongTimeFormat"); + std::string text = "["; + if (withdate) text += date() + ' '; + text += (withseconds ? longtime : shorttime)() + "] "; + + time_format(text, text.data(), time); return text; }