/*
 * SPDX-FileCopyrightText: 2000-2002 Copyright LifeLine Networks BV (www.lifeline.nl)
 * SPDX-FileCopyrightText: 2000-2002 Copyright Bastiaan Bakker
 * SPDX-FileCopyrightText: 2004 Copyright contributors to the cppTango project
 *
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#include <tango/common/log4tango/Layout.h>

#include <tango/common/log4tango/Level.h>
#include <tango/common/log4tango/Portability.h>

#include <chrono>
#include <sstream>

namespace log4tango
{

std::string Layout::format(const LoggingEvent &event)
{
    const char sep = ' ';

    std::ostringstream message;

    auto seconds = std::chrono::duration_cast<std::chrono::seconds>(event.timestamp.time_since_epoch()).count();

    message << seconds << sep << "[" << event.thread_id << "]" << sep << Level::get_name(event.level) << sep << '('
            << event.file_path << ':' << event.line_number << ')' << sep << event.logger_name << sep << event.message
            << std::ends;

    return message.str();
}

} // namespace log4tango
