Timezone information with text file backend

Open
#210 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
backend

Research direction

Start by reading the file-sink filename pattern code and how it formats time values; the issue points to Boost.Log's text file backend and Boost.DateTime's documented format flags. Check existing tests for filename pattern expansion and add coverage for including a timezone offset such as +0200. Done means the requested filename format works and the relevant tests pass.

Written by the indexing model from the issue text.

Description

We're currently working on adding logging to our application and trying to get a log file in the following format: test_20230607T165634+0200.log

With the following code however, the resulting log file is test_20230607T165634.log. After reading the documentation is seems that boost log does not support any of the time zone flags, since it uses ptime internally (https://www.boost.org/doc/libs/1_82_0/doc/html/date_time/date_time_io.html#date_time.format_flags). Could support for this be added?

#include <boost/log/trivial.hpp>
#include <boost/log/utility/setup/file.hpp>

void init_logger(const std::string& filename)
{
  auto sink = boost::log::add_file_log(boost::log::keywords::file_name = filename + "_%Y%m%dT%H%M%S%q.log");
}

int main(int, char**)
{
  init_logger("test");

  BOOST_LOG_TRIVIAL(info) << "Hello, World!";
}
Dominant language
C++
Stars
211
Forks
114
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/log

All issues in boostorg/log

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.