| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Log function ala log4j https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5920 |
Page 1 of 1 |
| Author: | biobier [ Thu Sep 03, 2020 7:53 pm ] |
| Post subject: | Log function ala log4j |
Hej coders, I would like to have a logging function which does only print if the external setting is equal or higher. Similar as with log4j library at java and others. I came that far: Code: Select all Cheers! |
|
| Author: | renexxxx [ Thu Sep 03, 2020 10:21 pm ] |
| Post subject: | Log function ala log4j |
You can use function overloading to create different "versions" of the log function like so: void log(LogLevel lvl, string text) { ... } void log(LogLevel lvl, double num) { ... } void log(LogLevel lvl, int num) { ... } However, with variable number of arguments of different types this is not practical as you would end up with zillions of log function definitions. Therefore it is far better to do the conversion of data into a string by the caller of the log function. So, you would only have one simple version of the log function like so: Code: Select all Code: Select all |
|
| Author: | biobier [ Fri Sep 04, 2020 11:09 am ] |
| Post subject: | Log function ala log4j |
Thanks Rene, did not come across StringFormat yet for this! So far I used IntegerToString()/ DoubleToStr(). Both not ideal. In a modern language we could just pass object and try to parse it. Did not found a way to do that in MQL4 |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|