Comments (3)
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.
#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.
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)
- Redirect log records to specific sink only HOT 4
- Max file rotating under the same target directory HOT 1
- BOOST_LOG_TRIVIAL cannot find overloaded `operator<<()` when it's declared in global scope HOT 2
- using BOOST_LOG_TRIVIAL << with string greater than max_size_decor results in bufferoverlfow detected HOT 3
- An infinite loop occurs when boost writes to the log file HOT 4
- Timezone information with text file backend HOT 2
- Boost.Log rotation may throw boost::filesystem::filesystem_error HOT 10
- Formatting TimeStamp HOT 1
- Boost 1.82, boost\Log\trivial unresolved external symbol error if included after curl HOT 3
- Log Formatting [Conan 2.x, C++20, Boost 1.83] HOT 2
- 1.82.0 compiled for XP uses AcquireSRWLockExclusive HOT 2
- How to append log to same log file after program restarts? HOT 1
- CMake integration for Xcode universal 2 builds HOT 1
- boost日志在动态库里被使用,再次在主程序中使用会崩溃 HOT 1
- Boost stopped printing logs after changing the system time HOT 4
- Redundent call to boost_install() HOT 1
- An infinite loop occurs when boost writes to the log file (Debug Mode, Medium size file) HOT 1
- Consider switching dependency from MPL to MP11 HOT 2
- Please consider improving the documentation and examples HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from log.