Skip to content

Commit

Permalink
fix: 修复日志格式时间戳显示异常问题
Browse files Browse the repository at this point in the history
适配qt的日志格式
%{time yyyy-MM-ddTHH:mm:ss.zzz} ==> %{time}{yyyy-MM-ddTHH:mm:ss.zzz}

Log: 修复日志格式时间戳显示异常问题
Bug: https://pms.uniontech.com/bug-view-236239.html
Influence: 使用DLogManager的应用日志输出格式
  • Loading branch information
Whale107 authored and kegechen committed May 14, 2024
1 parent 9af4631 commit 711270d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/log/AbstractStringAppender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ QString AbstractStringAppender::formattedString(const QDateTime &time, Logger::L
bool withcolor) const
{
QString f = format();

// dtkcore无法正确解析Qt的日志格式,dtk默认的日志格式并未和Qt统一,解析方式需要兼容两种不同的格式。
if (f.contains(QLatin1String("time ")))
f.replace(f.indexOf(' ', f.indexOf(QLatin1String("time")) + QLatin1String("time").size()), 1, QLatin1String("}{"));

const int size = f.size();

QString result;
Expand Down
2 changes: 1 addition & 1 deletion src/log/ConsoleAppender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ DCORE_BEGIN_NAMESPACE

ConsoleAppender::ConsoleAppender()
: AbstractStringAppender()
,m_ignoreEnvPattern(false)
, m_ignoreEnvPattern(false)
{
if (!spdlog::get("console")) {
auto clogger = spdlog::stdout_color_mt("console");
Expand Down

0 comments on commit 711270d

Please sign in to comment.