Let's nearly break logging to add a highly requested feature
My keyboard has been broken for almost half a year and none of you will ever care but I care about you I care so much
This commit is contained in:
@@ -7133,7 +7133,7 @@ This should be as low as possible, but too low may break functionality</string>
|
|||||||
<key>Type</key>
|
<key>Type</key>
|
||||||
<string>Boolean</string>
|
<string>Boolean</string>
|
||||||
<key>Value</key>
|
<key>Value</key>
|
||||||
<integer>0</integer>
|
<integer>1</integer>
|
||||||
</map>
|
</map>
|
||||||
<key>FloaterAboutRect</key>
|
<key>FloaterAboutRect</key>
|
||||||
<map>
|
<map>
|
||||||
|
|||||||
@@ -76,30 +76,41 @@ std::string LLLogChat::cleanFileName(std::string filename)
|
|||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void time_format(std::string& out, const char* fmt, const std::tm* time)
|
||||||
|
{
|
||||||
|
typedef typename std::vector<char, boost::alignment::aligned_allocator<char, 1>> 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<vec_t::size_type>(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)
|
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
|
// Convert to Pacific, based on server's opinion of whether
|
||||||
// it's daylight savings time there.
|
// 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<bool> withseconds("SecondsInLog");
|
static const LLCachedControl<bool> withseconds("SecondsInLog");
|
||||||
std::string text;
|
static const LLCachedControl<std::string> date("ShortDateFormat");
|
||||||
if (withdate)
|
static const LLCachedControl<std::string> shorttime("ShortTimeFormat");
|
||||||
if (withseconds)
|
static const LLCachedControl<std::string> longtime("LongTimeFormat");
|
||||||
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);
|
std::string text = "[";
|
||||||
else
|
if (withdate) text += date() + ' ';
|
||||||
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);
|
text += (withseconds ? longtime : shorttime)() + "] ";
|
||||||
else
|
|
||||||
if (withseconds)
|
time_format(text, text.data(), time);
|
||||||
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);
|
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user