Giter Club home page Giter Club logo

Comments (3)

Lastique avatar Lastique commented on July 28, 2024

You can't, because Boost.DateTime currently does not provide a way to obtain the current timezone from the system. I'm actually not sure there is a more or less standard way to do this.

If you have a timezone through some external means, you could create an attribute that generates boost::local_time::local_date_time with the time zone, and then use its locale facet to format the date and time with the timezone. You can use the basic_clock attribute with your own traits (see here for examples of clock traits).

There is no workaround for file names. This was already reported in #210.

from log.

lijh8 avatar lijh8 commented on July 28, 2024
#define LOG(severity) \
    now = time(NULL); \
    strftime(tz, sizeof(tz), "%z", localtime(&now)); \
    BOOST_LOG_TRIVIAL(severity) << " " << tz << " " << __FILE__ << ":" << __LINE__ << ": "

I tried adding the timezone in the LOG macro which was written by you in 2016. But it outputs the timezone after severity +0800. It also calls extra functions time() and strftime(). I don't think you'll like it.

2023-Jul-02 20:52:01.079777 [info   ]  +0800 main.cpp:45: info msg!
2023-Jul-02 20:52:01.080239 [warning]  +0800 main.cpp:46: warning msg!
2023-Jul-02 20:52:01.098602 [error  ]  +0800 main.cpp:47: error msg!

from log.

Lastique avatar Lastique commented on July 28, 2024

I didn't mean to modify the logging macro, I meant to add your own attribute for timestamps instead of attrs::local_clock, which would contain time zone information, and then format it.

from log.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.