From a22cc4e410957726f24e72c3d4ab872e9b7410fa Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Thu, 23 Oct 2025 20:26:35 +0300 Subject: [PATCH] add ext logging --- Common/base.pri | 1 + DesktopEditor/common/SystemUtils.h | 5 ++-- OOXML/Binary/Sheets/Reader/BinaryWriterS.cpp | 4 ++++ OOXML/XlsxFormat/Worksheets/Worksheet.cpp | 6 +++++ OOXML/XlsxFormat/Xlsx.cpp | 3 +++ OdfFile/Common/logging.h | 24 ++++++++++++++------ OdfFile/Reader/Converter/ConvertOO2OOX.cpp | 4 +++- 7 files changed, 36 insertions(+), 11 deletions(-) diff --git a/Common/base.pri b/Common/base.pri index 6b4e17e2d5..fa07b78249 100644 --- a/Common/base.pri +++ b/Common/base.pri @@ -45,6 +45,7 @@ win32 { } DEFINES += COPYRIGHT_YEAR=$${CURRENT_YEAR} +#DEFINES += _LOGOUT_ALWAYS QMAKE_TARGET_COMPANY = $$PUBLISHER_NAME QMAKE_TARGET_COPYRIGHT = © $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved. diff --git a/DesktopEditor/common/SystemUtils.h b/DesktopEditor/common/SystemUtils.h index 2e72ba572b..8cf6e66207 100644 --- a/DesktopEditor/common/SystemUtils.h +++ b/DesktopEditor/common/SystemUtils.h @@ -29,11 +29,11 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ -#ifndef _SYSTEMUTILS_H -#define _SYSTEMUTILS_H +#pragma once #include #include "../../Common/kernel_config.h" +#include "../../OdfFile/Common/logging.h" #define VALUE_STRINGIFY(d) L##d #define VALUE_TO_STR(v) VALUE_STRINGIFY(v) @@ -76,4 +76,3 @@ namespace NSSystemUtils }; KERNEL_DECL std::wstring GetSystemDirectory(const SystemDirectoryType& type); } -#endif // _SYSTEMUTILS_H diff --git a/OOXML/Binary/Sheets/Reader/BinaryWriterS.cpp b/OOXML/Binary/Sheets/Reader/BinaryWriterS.cpp index ad1e8c2d10..ec6e0a198e 100644 --- a/OOXML/Binary/Sheets/Reader/BinaryWriterS.cpp +++ b/OOXML/Binary/Sheets/Reader/BinaryWriterS.cpp @@ -36,6 +36,7 @@ #include "../../../../Common/OfficeFileFormats.h" #include "../../../../Common/Base64.h" #include "../../../../Common/OfficeFileErrorDescription.h" +#include "../../../../OdfFile/Common/logging.h" #include "../../Presentation/FontCutter.h" #include "../../../PPTXFormat/Logic/HeadingVariant.h" @@ -8975,6 +8976,7 @@ _UINT32 BinaryFileWriter::Open(const std::wstring& sInputDir, const std::wstring } else { + _CP_LOG << L"start binary" << std::endl; if (bIsNoBase64) { oBufferedStream.WriteStringUtf8(WriteFileHeader(0, g_nFormatVersionNoBase64)); @@ -9026,6 +9028,8 @@ _UINT32 BinaryFileWriter::Open(const std::wstring& sInputDir, const std::wstring } RELEASEARRAYOBJECTS(pbBase64Buffer); } + + _CP_LOG << L"end binary" << std::endl; } RELEASEOBJECT(pXlsx); diff --git a/OOXML/XlsxFormat/Worksheets/Worksheet.cpp b/OOXML/XlsxFormat/Worksheets/Worksheet.cpp index 1685943a56..2e27f269b1 100644 --- a/OOXML/XlsxFormat/Worksheets/Worksheet.cpp +++ b/OOXML/XlsxFormat/Worksheets/Worksheet.cpp @@ -52,6 +52,8 @@ #include "../../Binary/XlsbFormat/FileTypes_SpreadsheetBin.h" #include "../../../MsBinaryFile/XlsFile/Format/Binary/CFStreamCacheWriter.h" +#include "../../../OdfFile/Common/logging.h" + namespace OOX { namespace Spreadsheet @@ -487,17 +489,21 @@ namespace OOX } else { + _CP_LOG << L"\tstart read xml sheet: " << oPath.GetFilename() << std::endl; XmlUtils::CXmlLiteReader oReader; if (!oReader.FromFile(oPath.GetPath())) return; if (!oReader.ReadNextNode()) return; + _CP_LOG << L"\tend read xml, start parsing: " << oPath.GetFilename() << std::endl; + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); if (L"worksheet" == sName || L"chartsheet" == sName) { fromXML(oReader); } + _CP_LOG << L"\tend parsing sheet: " << oPath.GetFilename() << std::endl; } } void CWorksheet::PrepareAfterRead() diff --git a/OOXML/XlsxFormat/Xlsx.cpp b/OOXML/XlsxFormat/Xlsx.cpp index dfaac70855..d07540fc8e 100644 --- a/OOXML/XlsxFormat/Xlsx.cpp +++ b/OOXML/XlsxFormat/Xlsx.cpp @@ -132,8 +132,11 @@ bool OOX::Spreadsheet::CXlsx::ReadNative(const CPath& oFilePath) } bool OOX::Spreadsheet::CXlsx::Read(const CPath& oFilePath) { + _CP_LOG << L"start read and parsing: " << oFilePath.GetFilename() << std::endl; ReadNative(oFilePath); + _CP_LOG << L"end read ... " << std::endl; + if (!m_pWorkbook) return false; for (size_t i = 0; i < m_arWorksheets.size(); ++i) diff --git a/OdfFile/Common/logging.h b/OdfFile/Common/logging.h index 52e79f9281..894f94d6fb 100644 --- a/OdfFile/Common/logging.h +++ b/OdfFile/Common/logging.h @@ -32,7 +32,10 @@ #pragma once #include - +#include +#include +#include +#include namespace cpdoccore { @@ -46,7 +49,14 @@ namespace cpdoccore template Ostream & operator << (const T & t) { - ostream_ << t; + std::chrono::system_clock::time_point now{ std::chrono::system_clock::now() }; + std::time_t now_c = std::chrono::system_clock::to_time_t(now); + std::tm tm = *std::localtime(&now_c); + + auto duration_since_epoch = now.time_since_epoch(); + auto milliseconds = std::chrono::duration_cast(duration_since_epoch) % 1000; + + ostream_ << std::put_time(&tm, L"%H:%M:%S") << L"." << milliseconds.count() << L"\t" << t; return ostream_; } @@ -54,12 +64,12 @@ namespace cpdoccore Ostream & ostream_; }; - extern logging< std::wostream > logging_cout; - extern logging< std::wstringstream >logging_log; + extern logging logging_cout; + extern logginglogging_log; } -#ifdef _DEBUG - #define _CP_LOG cpdoccore::logging_cout +#if defined( _DEBUG) || defined(_LOGOUT_ALWAYS) + #define _CP_LOG cpdoccore::logging_cout #else - #define _CP_LOG cpdoccore::logging_log + #define _CP_LOG cpdoccore::logging_log #endif diff --git a/OdfFile/Reader/Converter/ConvertOO2OOX.cpp b/OdfFile/Reader/Converter/ConvertOO2OOX.cpp index d51c204dcc..16cdd65b23 100644 --- a/OdfFile/Reader/Converter/ConvertOO2OOX.cpp +++ b/OdfFile/Reader/Converter/ConvertOO2OOX.cpp @@ -87,7 +87,8 @@ _UINT32 ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstP { _UINT32 nResult = 0; - try + _CP_LOG << L"start odf to ..." << std::endl; + try { cpdoccore::odf_reader::odf_document inputOdf(srcPath, tempPath, password); @@ -129,6 +130,7 @@ _UINT32 ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstP { return AVS_ERROR_UNEXPECTED; } + _CP_LOG << L"... finish" << std::endl; return nResult; }