abumq / easyloggingpp

C++ logging library. It is powerful, supports asynchronous low latency, extendable, light-weight, fast performing, thread and type safe and consists of many built-in features. It provides ability to write logs in your own customized format. It also provide support for logging your classes, third-party libraries, STL and third-party containers etc.
MIT License
3.75k stars 918 forks source link

Custom datetime format from config file produces weird output with `_ELPP_UNICODE` defined #222

Open torbjoernk opened 9 years ago

torbjoernk commented 9 years ago

I'm trying to specify a custom datetime format via a config file:

## Default configuration for easyloggingpp
* GLOBAL:
  ENABLED              = true
  To_File              = false
  To_Standard_Output   = true
  Format               = "[%datetime{%y-%M-%d %H:%m:%s,%g}] %level - %msg"
  Milliseconds_Width   = 2
  Performance_Tracking = true
  Max_Log_File_Size    = 2097152  ## 2MB
  Log_Flush_Threshold  = 100      ## flush after 100 logs
* DEBUG:
  Format               = "[%datetime{%Y-%M-%d %H:%m:%s,%g}] %level (%logger) - %func (%loc) - %msg"
  Performance_Tracking = false
  Log_Flush_Threshold  = 50

I've defined _ELPP_STL_LOGGING and _ELPP_UNICODE prior to including easylogging++.h. I'm calling _INITIALIZE_EASYLOGGINGPP right after the include. In main, I first read in the config file via

el::Configurations defaultConfig(PFASST_LOGGING_DEFAULT_CONF_FILE);
el::Loggers::setDefaultConfigurations(defaultConfig, true);

and call _START_EASYLOGGINGPP(argc, argv) afterwards.

The output of LOG(INFO) << "Logger test"; is really, really weird:

[371214537774537100323772583710] INFO  - Logger test

Not specifying a custom format (or datetime) gives the expected output:

31/10/2014 11:33:09,35 INFO  [default] Logger test
easylogging commented 9 years ago

Try configuring after start

torbjoernk commented 9 years ago

Thanks for the fast reply. However, I've switched the setup without any effects. However, when I don't define _ELPP_UNICODE, it formats the datetime correctly as expected.