Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/issue-3101: fix the issue where mdc ignores SPDLOG_NO_TLS #3184

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

Allen-20180115
Copy link
Contributor

Compared to the previous PR, additional testing details have been added.

Test results of the original v1.x branch code:

compilation steps:

$ git clone git@github.com:Allen-20180115/spdlog.git
$ cd spdlog && mkdir build && cd build
$ cmake .. -DSPDLOG_BUILD_EXAMPLE=ON -DSPDLOG_NO_TLS=ON
$ make
$ cd example
$ ./example

test result:

allen@allen:~/mytest/spdlog/build/example$ ./example 
[2024-09-11 16:49:41.804] [info] Welcome to spdlog version 1.14.1  !
[2024-09-11 16:49:41.804] [warning] Easy padding in numbers like 00000012
[2024-09-11 16:49:41.804] [critical] Support for int: 42;  hex: 2a;  oct: 52; bin: 101010
[2024-09-11 16:49:41.804] [info] Support for floats 1.23
[2024-09-11 16:49:41.804] [info] Positional args are supported too..
[2024-09-11 16:49:41.804] [info]    right aligned, left     aligned
[2024-09-11 16:49:41.804] [debug] This message should be displayed..
[16:49:41 +08:00] [I] [thread 25864] This an info message with custom format
[2024-09-11 16:49:41.805] [info] ****************** Backtrace Start ******************
[2024-09-11 16:49:41.805] [debug] Backtrace message 90
[2024-09-11 16:49:41.805] [debug] Backtrace message 91
[2024-09-11 16:49:41.805] [debug] Backtrace message 92
[2024-09-11 16:49:41.805] [debug] Backtrace message 93
[2024-09-11 16:49:41.805] [debug] Backtrace message 94
[2024-09-11 16:49:41.805] [debug] Backtrace message 95
[2024-09-11 16:49:41.805] [debug] Backtrace message 96
[2024-09-11 16:49:41.805] [debug] Backtrace message 97
[2024-09-11 16:49:41.805] [debug] Backtrace message 98
[2024-09-11 16:49:41.805] [debug] Backtrace message 99
[2024-09-11 16:49:41.805] [info] ****************** Backtrace End ********************
[2024-09-11 16:49:41.808] [info] Binary example: 
0000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
0020: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
0040: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
[2024-09-11 16:49:41.808] [info] Another binary example:00 01 02 03 04 05 06 07 08 09
[2024-09-11 16:49:41.808] [info] Vector example: [1, 2, 3]
[multi_sink_example] [warning] this should appear in both console and file
[2024-09-11 16:49:41.808] [info] user defined type: [my_type i=14]
[2024-09-11 16:49:41.931] [info] Stopwatch: 0.123096335 seconds
[2024-09-11 16:49:41.931] [info] Before opening logs/events-sample.txt
[2024-09-11 16:49:41.931] [info] After opening logs/events-sample.txt
[2024-09-11 16:49:41.931] [info] Before closing logs/events-sample.txt
[2024-09-11 16:49:41.931] [info] After closing logs/events-sample.txt
[16:49:41 +08:00] [I] [key1:value1 key2:value2] Some log message with context
[16:49:41 +08:00] [I] [key1:value1 key2:value2] End of example.
[16:49:41 +08:00] [I] [key1:value1 key2:value2] End of example.

PR branch code test results:

compilation steps:

$ git clone git@github.com:Allen-20180115/spdlog.git
$ cd spdlog && mkdir build2 && cd build2
$ cmake .. -DSPDLOG_BUILD_EXAMPLE=ON -DSPDLOG_NO_TLS=ON
$ make
$ cd example
$ ./example

test result:

allen@allen:~/mytest/spdlog/build2/example$ ./example 
[2024-09-12 19:26:54.801] [info] Welcome to spdlog version 1.14.1  !
[2024-09-12 19:26:54.801] [warning] Easy padding in numbers like 00000012
[2024-09-12 19:26:54.802] [critical] Support for int: 42;  hex: 2a;  oct: 52; bin: 101010
[2024-09-12 19:26:54.802] [info] Support for floats 1.23
[2024-09-12 19:26:54.802] [info] Positional args are supported too..
[2024-09-12 19:26:54.802] [info]    right aligned, left     aligned
[2024-09-12 19:26:54.802] [debug] This message should be displayed..
[19:26:54 +08:00] [I] [thread 26706] This an info message with custom format
[2024-09-12 19:26:54.802] [info] ****************** Backtrace Start ******************
[2024-09-12 19:26:54.802] [debug] Backtrace message 90
[2024-09-12 19:26:54.802] [debug] Backtrace message 91
[2024-09-12 19:26:54.802] [debug] Backtrace message 92
[2024-09-12 19:26:54.802] [debug] Backtrace message 93
[2024-09-12 19:26:54.802] [debug] Backtrace message 94
[2024-09-12 19:26:54.802] [debug] Backtrace message 95
[2024-09-12 19:26:54.802] [debug] Backtrace message 96
[2024-09-12 19:26:54.802] [debug] Backtrace message 97
[2024-09-12 19:26:54.802] [debug] Backtrace message 98
[2024-09-12 19:26:54.802] [debug] Backtrace message 99
[2024-09-12 19:26:54.802] [info] ****************** Backtrace End ********************
[2024-09-12 19:26:54.803] [info] Binary example: 
0000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
0020: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
0040: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
[2024-09-12 19:26:54.803] [info] Another binary example:00 01 02 03 04 05 06 07 08 09
[2024-09-12 19:26:54.803] [info] Vector example: [1, 2, 3]
[multi_sink_example] [warning] this should appear in both console and file
[2024-09-12 19:26:54.803] [info] user defined type: [my_type i=14]
[2024-09-12 19:26:54.927] [info] Stopwatch: 0.123242379 seconds
[2024-09-12 19:26:54.927] [info] Before opening logs/events-sample.txt
[2024-09-12 19:26:54.927] [info] After opening logs/events-sample.txt
[2024-09-12 19:26:54.927] [info] Before closing logs/events-sample.txt
[2024-09-12 19:26:54.927] [info] After closing logs/events-sample.txt
[2024-09-12 19:26:54.927] [info] End of example.
[2024-09-12 19:26:54.927] [console] [info] End of example.

Please note the output results on the end of line. At this point, calling mdc_example() does not ignore the compiler option SPDLOG_NO_TLS

@gabime gabime merged commit 362214a into gabime:v1.x Sep 12, 2024
8 checks passed
@gabime
Copy link
Owner

gabime commented Sep 12, 2024

Thanks @Allen-20180115. Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants