/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
namespace logging
{ using ::com::sun::star::uno::Sequence; using ::com::sun::star::logging::LogRecord;
namespace {
// formats for csv files as defined by RFC4180 class CsvFormatter : public cppu::WeakImplHelper<css::logging::XCsvLogFormatter, css::lang::XServiceInfo>
{ public: virtual OUString SAL_CALL formatMultiColumn(const Sequence< OUString>& column_data) override;
void appendEncodedString(OUStringBuffer& buf, std::u16string_view str)
{ if(needsQuoting(str))
{ // each double-quote will get replaced by two double-quotes
buf.append(quote_char); const sal_Int32 buf_offset = buf.getLength(); const size_t str_length = str.size();
buf.append(str); // special treatment for the last character if(quote_char==str[str_length-1])
buf.append(quote_char); // iterating backwards because the index at which we insert won't be shifted // when moving that way. for(size_t i = str_length;; )
{
--i;
i=str.substr(i).rfind(quote_char); if(i==std::u16string_view::npos) break;
buf.insert(buf_offset + i, quote_char);
}
buf.append(quote_char);
} else
buf.append(str);
};
}
// if the CsvFormatter has multiple columns set via setColumnnames(), the // message of the record is expected to be encoded with formatMultiColumn // if the CsvFormatter has only one column set, the message is expected not // to be encoded if(m_MultiColumn)
aLogEntry.append(record.Message); else
appendEncodedString(aLogEntry, record.Message);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.