mirror of
https://github.com/gabime/spdlog.git
synced 2025-04-29 20:13:52 +00:00
Compare commits
3088 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
548b264254 | ||
|
847db3375f | ||
|
bb8694b50f | ||
|
cec28bf839 | ||
|
bd0609d7a0 | ||
|
1f4959c832 | ||
|
48bcf39a66 | ||
|
9c58257480 | ||
|
faa0a7a9c5 | ||
|
10320184df | ||
|
3335c380a0 | ||
|
f355b3d58f | ||
|
ac432c3602 | ||
|
3c23c27d2d | ||
|
ae1de0dc8c | ||
|
7cbf2a6967 | ||
|
57505989b7 | ||
|
96a7d2a1d4 | ||
|
d71555306a | ||
|
ad0f31c009 | ||
|
96a8f6250c | ||
|
7f8060d5b2 | ||
|
276ee5f5c0 | ||
|
24dde318fe | ||
|
65e388e82b | ||
|
1e6250e183 | ||
|
951c5b9987 | ||
|
15f539685b | ||
|
43dcb3982d | ||
|
0efef2af24 | ||
|
018d8aa266 | ||
|
35b0417fbe | ||
|
94526fa8e8 | ||
|
633003f40a | ||
|
9edab1b5a1 | ||
|
1245bf8e8a | ||
|
51a0deca2c | ||
|
8e5613379f | ||
|
7cee026baa | ||
|
ebfa906952 | ||
|
68f6ec7af1 | ||
|
d343d413c2 | ||
|
fe4f99527d | ||
|
5673e9e545 | ||
|
63f0875000 | ||
|
5fd32e1a70 | ||
|
35345182f8 | ||
|
3c2e002b51 | ||
|
6192537d08 | ||
|
6c7201553d | ||
|
d939255f0e | ||
|
ecc3881122 | ||
|
bff1a6036a | ||
|
6f2ead1a0e | ||
|
92f9aa32ce | ||
|
64d9b4e263 | ||
|
3d3f71dbe2 | ||
|
3fec1a81b7 | ||
|
984a959883 | ||
|
7ecfb3bc9c | ||
|
614c3a6836 | ||
|
5dc356dcbe | ||
|
a7eb388f84 | ||
|
a5cfbf369d | ||
|
d373093734 | ||
|
7a950e028c | ||
|
9fe79692eb | ||
|
96c9a62bfd | ||
|
85bdab0c18 | ||
|
63d1884215 | ||
|
b6da59447f | ||
|
16e0d2e77c | ||
|
ee16895787 | ||
|
e593f6695c | ||
|
2c76e6101a | ||
|
bdd1dff378 | ||
|
ffd5aa41d6 | ||
|
c1fbafdcef | ||
|
362214a349 | ||
|
2169a6f6ae | ||
|
271f0f3b14 | ||
|
a3a0c9d663 | ||
|
5ebfc92730 | ||
|
885b5473e2 | ||
|
d276069a6e | ||
|
eeb22c13bb | ||
|
c3aed4b683 | ||
|
27cb4c7670 | ||
|
2d4acf8cc3 | ||
|
3b4fd93bd0 | ||
|
2122eb2194 | ||
|
22b0f4fc06 | ||
|
37b847692e | ||
|
fa6605dc99 | ||
|
94a8e87c71 | ||
|
238c9ffa5d | ||
|
3b4c775b5b | ||
|
3403f27898 | ||
|
a34e08c7ff | ||
|
71925ca382 | ||
|
fd61ea9348 | ||
|
66ac83e703 | ||
|
dd6c9c6e43 | ||
|
b7e0e2c237 | ||
|
a0d2187d8f | ||
|
e3f5a4fe66 | ||
|
1e7d7e0766 | ||
|
a2b4262090 | ||
|
8fed530bdf | ||
|
1253a57db6 | ||
|
cba66029e2 | ||
|
4517ce8b5c | ||
|
1f93017403 | ||
|
f030afe696 | ||
|
2969dde400 | ||
|
d8e0ad46bf | ||
|
62302019ba | ||
|
a19c76a4e7 | ||
|
ec661f98dc | ||
|
c9ce17abca | ||
|
6725584e27 | ||
|
6766f873d6 | ||
|
73e2e02b42 | ||
|
d03eb40c17 | ||
|
23587b0d9a | ||
|
819eb27c5d | ||
|
4052bc0621 | ||
|
8cfd4a7e7b | ||
|
e15c505965 | ||
|
42cd77d7e8 | ||
|
c838945eac | ||
|
0621a7ae49 | ||
|
e0410f430e | ||
|
ae525b75c3 | ||
|
a45c939040 | ||
|
5532231bbc | ||
|
60faedb025 | ||
|
bc4b329585 | ||
|
75bfbb7c0c | ||
|
3f0e400718 | ||
|
9a445245f1 | ||
|
d387fdf96c | ||
|
134f9194bb | ||
|
fe79bfcc51 | ||
|
47b7e7c736 | ||
|
696db97f67 | ||
|
8979f7fb2a | ||
|
7c02e204c9 | ||
|
2aa8b6c971 | ||
|
7cb90d1ab2 | ||
|
1ef8d3ce34 | ||
|
c1569a3d29 | ||
|
ba508057b1 | ||
|
ac55e60488 | ||
|
ddce42155e | ||
|
8b331e2cd1 | ||
|
2d5179ba7d | ||
|
ff205fd29a | ||
|
595a524758 | ||
|
c5452e0508 | ||
|
0c4fb032e4 | ||
|
508d20f0fa | ||
|
479a5ac3f1 | ||
|
91807c2e71 | ||
|
d4a5fd564c | ||
|
e5865186d4 | ||
|
b6eeb7364c | ||
|
0a53eafe18 | ||
|
251c856a12 | ||
|
4b2a8219d5 | ||
|
cafde8ccc1 | ||
|
9d52261185 | ||
|
230e15f499 | ||
|
7f535d184e | ||
|
95c226e9c9 | ||
|
5e88d5fe22 | ||
|
5931a3d6f8 | ||
|
f4afd81ce6 | ||
|
1a0bfc7a89 | ||
|
f24f7fa2fa | ||
|
65701f4d5b | ||
|
9e36a15875 | ||
|
b9cb721b92 | ||
|
1d6dbc2a56 | ||
|
b5b5043d42 | ||
|
d109e1dcd0 | ||
|
a98d3ab0c7 | ||
|
8014d6c31a | ||
|
3aceda041b | ||
|
7d0531b076 | ||
|
47e04cf043 | ||
|
81ce5fcdb7 | ||
|
cedfeeb95f | ||
|
2312489bdc | ||
|
811bc4c7a9 | ||
|
1f8d36071e | ||
|
bffceb90b0 | ||
|
371bc8ebe2 | ||
|
2ee8bac78e | ||
|
d8d23a6606 | ||
|
76dfc7e7c0 | ||
|
7e635fca68 | ||
|
bed324e414 | ||
|
72a7ec3eb9 | ||
|
64ed6b495c | ||
|
4338b9cd23 | ||
|
b73616ce29 | ||
|
01b3724c48 | ||
|
4b8ff51a29 | ||
|
8b8bc20f30 | ||
|
3cd06a3d40 | ||
|
c3fa8f60e2 | ||
|
169f827957 | ||
|
62e55e7a7f | ||
|
b85c509ec6 | ||
|
b1eb4953fa | ||
|
5ece88e5a8 | ||
|
826d8ba4b2 | ||
|
326f8870c2 | ||
|
7990ed8f2b | ||
|
da1e671d42 | ||
|
a29cef5787 | ||
|
9ce7295191 | ||
|
36eb173030 | ||
|
ca44ce50ab | ||
|
91280df07e | ||
|
5a6b6cafa8 | ||
|
4f4da7f114 | ||
|
199cc0a6d8 | ||
|
4fb4e2bd86 | ||
|
c17b5d9cd1 | ||
|
3a7188505f | ||
|
32bab0e103 | ||
|
f0e1f22bbc | ||
|
1f61f5e019 | ||
|
31cefdce79 | ||
|
95b8ee9b32 | ||
|
d7985e3965 | ||
|
dfcb74b129 | ||
|
6a96c7f902 | ||
|
6940f4fd46 | ||
|
1f1897e3a4 | ||
|
0f50ad92d6 | ||
|
5384512f25 | ||
|
230cad163d | ||
|
3a6ee663ba | ||
|
931cd2fb54 | ||
|
8fdcf0365b | ||
|
32701af60b | ||
|
31cf79a70d | ||
|
d1eb68154f | ||
|
c174c15138 | ||
|
8222ca4837 | ||
|
62a4b8ce4e | ||
|
ea1af20840 | ||
|
1fba68bfe2 | ||
|
4c5ee9bb10 | ||
|
dd173bc544 | ||
|
fcc8a95a95 | ||
|
9fcf609b67 | ||
|
af1785b897 | ||
|
57a9fd0841 | ||
|
f9c24d9fa8 | ||
|
e4f92bed48 | ||
|
c65aa4e488 | ||
|
e539d6ae42 | ||
|
0ca574ae16 | ||
|
069a2e8fc9 | ||
|
42d1f40a18 | ||
|
040874224b | ||
|
706ad70591 | ||
|
1262a249a6 | ||
|
2a861d28bd | ||
|
febc1e233d | ||
|
763ff37348 | ||
|
2d57e3b57e | ||
|
b25aaecf6a | ||
|
d07e8cb576 | ||
|
bcd0a2b820 | ||
|
7f09c88817 | ||
|
150ba9e6dd | ||
|
8be5b41a2f | ||
|
ceb71825b2 | ||
|
2a6d3e9f3b | ||
|
6b67054071 | ||
|
13f45c531b | ||
|
937ce23537 | ||
|
60f5cb73a8 | ||
|
0e9ccd73ef | ||
|
839ea957ab | ||
|
262acfdeb5 | ||
|
a4d8817745 | ||
|
66407f5b48 | ||
|
4641347c3f | ||
|
51bcff820e | ||
|
7372596126 | ||
|
da14258533 | ||
|
927cc29444 | ||
|
5a589438d2 | ||
|
d8c061aa6e | ||
|
3cab260814 | ||
|
654dbc5c32 | ||
|
78e86ba01f | ||
|
435827fe5a | ||
|
f29f369a12 | ||
|
5a63426d1c | ||
|
05e3a73b16 | ||
|
c92d12bc18 | ||
|
6df64c6c34 | ||
|
0b9ff5210a | ||
|
85a009ad64 | ||
|
287a00d364 | ||
|
3c93f7690a | ||
|
a4e9917575 | ||
|
edc51df1bd | ||
|
ff88b13c35 | ||
|
dd0d0f68c4 | ||
|
8512000f36 | ||
|
f0cd9d1530 | ||
|
50e8b2d982 | ||
|
4f80077339 | ||
|
c5a09ebc49 | ||
|
d7de159455 | ||
|
18495bf25d | ||
|
ad0e89cbfb | ||
|
6a9d561671 | ||
|
545c301877 | ||
|
7aa00607ea | ||
|
bd5a81df70 | ||
|
4accce5d7b | ||
|
4d7308f26d | ||
|
678a79c0be | ||
|
fbba6dff20 | ||
|
fdb1f5926e | ||
|
b59b4a2b45 | ||
|
6c975fa13b | ||
|
c627c66560 | ||
|
130ff0c8db | ||
|
31d6935b97 | ||
|
14a29c03eb | ||
|
a7e2bf161e | ||
|
070dd181df | ||
|
7147da468f | ||
|
9125bda301 | ||
|
a4743370e2 | ||
|
867df8cf87 | ||
|
8a0b2231b1 | ||
|
3499dfeeb4 | ||
|
3c0e036cc9 | ||
|
bced424855 | ||
|
5fba2867f5 | ||
|
b5d361fc21 | ||
|
0674e79066 | ||
|
5f67ef4d6f | ||
|
1bb1f05d73 | ||
|
77429b2e2e | ||
|
a3c47cc682 | ||
|
0145223be1 | ||
|
f3b61c70ba | ||
|
7768c6271c | ||
|
d011332616 | ||
|
93b9132b0a | ||
|
936697e5b1 | ||
|
cf6cdc5ba6 | ||
|
ec81b321c2 | ||
|
23fce5ffaa | ||
|
7fa59cf555 | ||
|
29b24f9e72 | ||
|
523a075f82 | ||
|
06f9953fa8 | ||
|
b8fdc9bf5d | ||
|
7130676697 | ||
|
5ca5fdff9f | ||
|
81de01c02c | ||
|
b60512731b | ||
|
1eaf98cc10 | ||
|
34f88d4382 | ||
|
57e5814364 | ||
|
de67ebdda1 | ||
|
f44fa31f51 | ||
|
64e0724bd6 | ||
|
afb1699e0a | ||
|
b75edfafca | ||
|
26f69ee9d2 | ||
|
61879237e9 | ||
|
fb3ddf749d | ||
|
7d805c2231 | ||
|
5f8877b665 | ||
|
834840636c | ||
|
dfe1009080 | ||
|
6c95f4c816 | ||
|
d7690d8e7e | ||
|
68f42a5b90 | ||
|
ab7b325906 | ||
|
a26e174b36 | ||
|
866fdaa6db | ||
|
03315853df | ||
|
ca747c7572 | ||
|
1f608a81e8 | ||
|
822f972842 | ||
|
298a200f69 | ||
|
beefee7929 | ||
|
1eafcfab70 | ||
|
9e8e52c048 | ||
|
1f0c2f9f36 | ||
|
fc93ddbefe | ||
|
ffd929c590 | ||
|
d546201f12 | ||
|
799802f93b | ||
|
3d7ee64661 | ||
|
876880fb3f | ||
|
afb69071d5 | ||
|
0d8197cc9d | ||
|
e36b69a0ec | ||
|
0ef5228a77 | ||
|
e05b8542a0 | ||
|
41efc971ad | ||
|
d89a1e66d8 | ||
|
d3dee23e6c | ||
|
5f5e70e96e | ||
|
128cbe5a06 | ||
|
6d587f5181 | ||
|
9b4b373121 | ||
|
aa7490d187 | ||
|
c03c925e29 | ||
|
38929f856d | ||
|
bd0198de2d | ||
|
ece96216c4 | ||
|
a9347017db | ||
|
2eedf1fa28 | ||
|
0a875d7b2d | ||
|
173d06578f | ||
|
b299855ef2 | ||
|
8338a48c5b | ||
|
cd4f6c1466 | ||
|
37dd6bb159 | ||
|
714cf12822 | ||
|
ee00f2e07d | ||
|
c203b4df8e | ||
|
56adf64ccf | ||
|
91019f4f46 | ||
|
3cf94968e7 | ||
|
ebeb3707b1 | ||
|
b3ce5ed379 | ||
|
78fbc69c94 | ||
|
4ccbb5a71a | ||
|
e6265c04ae | ||
|
184fae06d7 | ||
|
76fb40d954 | ||
|
757e9f8ec6 | ||
|
fc51c095ba | ||
|
36b4b9dac9 | ||
|
083ea59fbd | ||
|
c1aeefb0c9 | ||
|
3c1ee54112 | ||
|
a49456f7f2 | ||
|
52dc210423 | ||
|
b1478d98f0 | ||
|
5ee969e4f6 | ||
|
7f8a61e79d | ||
|
69cac816aa | ||
|
2f2d04b3e8 | ||
|
9cd9c98f59 | ||
|
f2461f1430 | ||
|
a732a0dc85 | ||
|
4c2ce2c82c | ||
|
4cea9b8729 | ||
|
53c9b70ea3 | ||
|
71105e0b07 | ||
|
c432fdd987 | ||
|
d8199b607d | ||
|
b7836c33ae | ||
|
d497f494f0 | ||
|
0b48976be4 | ||
|
5b03dc1796 | ||
|
ec8b0beddd | ||
|
7536192058 | ||
|
5afff7821f | ||
|
8fb112158a | ||
|
792d618c02 | ||
|
93f59d04e9 | ||
|
666bec5017 | ||
|
2382c87aa3 | ||
|
caa0e54396 | ||
|
28b9adf794 | ||
|
584d77237e | ||
|
d9ec02d400 | ||
|
5568b16ed5 | ||
|
eab522e743 | ||
|
4cfdc8c5c8 | ||
|
2a4c34b878 | ||
|
729d7f6d88 | ||
|
3540ba32e9 | ||
|
32fedcf90c | ||
|
626efad307 | ||
|
cc30229abb | ||
|
a087dee98a | ||
|
f096c615c3 | ||
|
f81cb9f365 | ||
|
7e95963940 | ||
|
3f49f0f247 | ||
|
4cb1187871 | ||
|
fe782edc53 | ||
|
702cf4f54a | ||
|
0c84e21022 | ||
|
ee74321ac3 | ||
|
e45c11f98a | ||
|
c211288576 | ||
|
4fefd51e08 | ||
|
ad08f13aac | ||
|
6638c23cfc | ||
|
378a42c887 | ||
|
9abcf38b90 | ||
|
8715f51c61 | ||
|
37cbab363e | ||
|
afdcfc710e | ||
|
16bc6d04ad | ||
|
ac6908a139 | ||
|
28e415fb3e | ||
|
ab2e72340a | ||
|
da9c16278a | ||
|
b5d6c939fd | ||
|
fda2b361da | ||
|
6636ff05e6 | ||
|
9e17fafe1b | ||
|
1f58535920 | ||
|
8dd012096a | ||
|
f81970191a | ||
|
b8b16e49a5 | ||
|
2c21d9ecf8 | ||
|
2a45eff693 | ||
|
5bf8728cfa | ||
|
e3e4c4bc95 | ||
|
0c611af552 | ||
|
f304ca3daf | ||
|
d93cea97ec | ||
|
cabbe65be4 | ||
|
8a6b5b9e62 | ||
|
c15262c493 | ||
|
9a12e4a885 | ||
|
f52d526e1e | ||
|
e1a4b28039 | ||
|
b3560d1567 | ||
|
c6d144dab9 | ||
|
d5c000394d | ||
|
58e2b455fb | ||
|
2ab86a46d0 | ||
|
569b851b80 | ||
|
232df72b82 | ||
|
e65efdbbe1 | ||
|
29b41741cb | ||
|
17f21df441 | ||
|
94d2a84995 | ||
|
aac187d3a0 | ||
|
8d46977060 | ||
|
ca1eaedf7b | ||
|
8bd5f4f883 | ||
|
dc030ec53c | ||
|
1756c5d37f | ||
|
2b4e07dd91 | ||
|
0df2582674 | ||
|
24e47efae0 | ||
|
10b640d773 | ||
|
ff80d10820 | ||
|
126a9fb261 | ||
|
4001032858 | ||
|
ad779e4865 | ||
|
701ef17227 | ||
|
5d6af189f1 | ||
|
518bf36aa9 | ||
|
5b7dfefc7e | ||
|
484bf07379 | ||
|
0ded003703 | ||
|
95aa159bdd | ||
|
ba120e524b | ||
|
a6945d046f | ||
|
108c656e66 | ||
|
2d77ef92b0 | ||
|
f6901606f5 | ||
|
849e90bd01 | ||
|
e86be93b4a | ||
|
698516f3f5 | ||
|
da621e4402 | ||
|
ea92864a4d | ||
|
a5fa6eb356 | ||
|
cbaf4880ad | ||
|
b813bb863d | ||
|
30fb78813b | ||
|
a3ad8b5f26 | ||
|
24a551c14e | ||
|
8e359baaec | ||
|
85bdfc8695 | ||
|
c466e2d8f8 | ||
|
d75de3d3b2 | ||
|
c8ba643f53 | ||
|
591eedcf36 | ||
|
48e35f9c3e | ||
|
89c4b1aabe | ||
|
6ff1b83038 | ||
|
4008f31add | ||
|
c475418975 | ||
|
a31ae23db1 | ||
|
44a4517e2b | ||
|
ff9313e6dd | ||
|
c47ae3b15d | ||
|
6aafa89d20 | ||
|
acbf18d0dd | ||
|
8826011c81 | ||
|
d6a78cb85b | ||
|
7812a4c89f | ||
|
ef540c1243 | ||
|
8ffbc0f114 | ||
|
21ba38972b | ||
|
d54b8e89c0 | ||
|
14eecc6e2a | ||
|
99fda0ed22 | ||
|
8e055a4086 | ||
|
d4967358a5 | ||
|
bae78f7b6c | ||
|
f97dcc72dc | ||
|
dd10e41b27 | ||
|
c0d10efabf | ||
|
fecb3f4307 | ||
|
9bb66c00e9 | ||
|
1ec50cdcfc | ||
|
5906ce844a | ||
|
2e66a27081 | ||
|
497fa60f57 | ||
|
2d1217006b | ||
|
444df2b287 | ||
|
8ee1c167b9 | ||
|
486dc5102e | ||
|
a1d9f501e3 | ||
|
4501f21ae7 | ||
|
649424b8ea | ||
|
a15f5137ef | ||
|
410e641dff | ||
|
c5fd8a0b97 | ||
|
5df9b11141 | ||
|
e159052e6d | ||
|
23f47ebc47 | ||
|
58e7f68004 | ||
|
29e5930090 | ||
|
deb178a0b1 | ||
|
e185926beb | ||
|
0d10e21c2f | ||
|
ed27592537 | ||
|
df45d78d14 | ||
|
c98b29aa67 | ||
|
388679b00e | ||
|
119467c580 | ||
|
c2550ac24a | ||
|
12ee35a3d1 | ||
|
eb3220622e | ||
|
8f26e819ad | ||
|
b6b1c2f95d | ||
|
9ce9804a88 | ||
|
ddaa61ca9a | ||
|
4646bd082a | ||
|
53aca9c3d0 | ||
|
aa1e794213 | ||
|
45e3b678b0 | ||
|
bd99496423 | ||
|
e471ec884e | ||
|
b400705a1c | ||
|
cb35191fc1 | ||
|
1945a93b33 | ||
|
dfd12e6dac | ||
|
ba29e1d75d | ||
|
8f6d123586 | ||
|
d368ed586c | ||
|
87095a9f1f | ||
|
dd6d203488 | ||
|
f463ebf54a | ||
|
3547d7e24f | ||
|
a9c01aba78 | ||
|
f237947bdc | ||
|
890df3d90b | ||
|
14783585b6 | ||
|
243c4beac7 | ||
|
fe9cb54e0d | ||
|
dabec32748 | ||
|
6faa5fc95b | ||
|
dbbec6cdb4 | ||
|
43923cf038 | ||
|
2ccba49b01 | ||
|
362fdc6ceb | ||
|
7bb53541e4 | ||
|
c07b3aeef9 | ||
|
fb47935a7b | ||
|
ec3538c2ee | ||
|
84e15d1ee2 | ||
|
5b4c4f3f77 | ||
|
aecdfc60a0 | ||
|
816ede3a17 | ||
|
353c79ca71 | ||
|
e93115f436 | ||
|
197c9639bb | ||
|
a358a38b84 | ||
|
16d76e2293 | ||
|
536e583cbe | ||
|
9049f9aeb9 | ||
|
bee3e63e1b | ||
|
d8f13cbd5b | ||
|
0f39da5490 | ||
|
28fef35a12 | ||
|
1344d44a5a | ||
|
61ed2a670e | ||
|
db1bc035f7 | ||
|
8de6cdaa82 | ||
|
fe1a4f5fb6 | ||
|
d38f89cae8 | ||
|
9c90fe8264 | ||
|
b85a666f72 | ||
|
5ba95f6816 | ||
|
dc38b7c3c4 | ||
|
6484b03dd9 | ||
|
29235d9b4b | ||
|
4b3687f1a6 | ||
|
e7e8b75a4c | ||
|
e98265a49b | ||
|
e87f69bdb6 | ||
|
70d2832c0d | ||
|
7636f1f659 | ||
|
1523c83650 | ||
|
a6987efaec | ||
|
6491abb519 | ||
|
8faabb4e3a | ||
|
2838c2c8a5 | ||
|
3315bad009 | ||
|
3eeced78b5 | ||
|
c23430b438 | ||
|
0e49bfff51 | ||
|
3ed40d04a9 | ||
|
70b36aa55d | ||
|
0f83b33d4f | ||
|
b83106bed4 | ||
|
21413e599a | ||
|
5f4cc7b036 | ||
|
9aa26fb969 | ||
|
7f74012a0d | ||
|
96ebef093f | ||
|
a19f4bba0c | ||
|
c24b957e17 | ||
|
5ba2f77230 | ||
|
a09f490804 | ||
|
082d6fbea9 | ||
|
37372960a8 | ||
|
0035a0c98d | ||
|
036cc5d575 | ||
|
14950926ed | ||
|
baa3b1a07e | ||
|
2a09f66a44 | ||
|
e50b62c770 | ||
|
13d8b0f17f | ||
|
9e0c658b29 | ||
|
74fec56927 | ||
|
514f304a47 | ||
|
7f85a5c988 | ||
|
14d626d961 | ||
|
7560cacb3f | ||
|
3cd9bcdab9 | ||
|
32f1efdc99 | ||
|
bcc9f03457 | ||
|
4c845bf02b | ||
|
c727864393 | ||
|
4548573a75 | ||
|
385246730d | ||
|
e06d21a4c0 | ||
|
c132d2ae8c | ||
|
ece31100e0 | ||
|
ce4e1ac54b | ||
|
ef61fb11f0 | ||
|
42f2b11ec8 | ||
|
ac87cbb0d1 | ||
|
c65de3d689 | ||
|
1433fa4209 | ||
|
d51149e5ac | ||
|
ffd813435a | ||
|
d75fd2c7f9 | ||
|
cdad84aa46 | ||
|
0fdb545d8c | ||
|
a5f5ff70e0 | ||
|
4f0e320236 | ||
|
68aed6a5eb | ||
|
6811112208 | ||
|
9ebc4b24d9 | ||
|
b990080a52 | ||
|
efbe3e4d57 | ||
|
7b14a65b2b | ||
|
5887744d8b | ||
|
8bf718671a | ||
|
c858b14c03 | ||
|
12df172575 | ||
|
7fa751d36e | ||
|
7a7611e977 | ||
|
ec8763adf2 | ||
|
f2d1d573f5 | ||
|
a530b87fd0 | ||
|
6c21789aed | ||
|
616866fcf4 | ||
|
faf06bcfe5 | ||
|
cd376a5c43 | ||
|
6ba5ab6d67 | ||
|
1bee3218b4 | ||
|
802eaadd2d | ||
|
ee22eed23d | ||
|
ab72de5f7a | ||
|
a32cea24fd | ||
|
af0d805be4 | ||
|
181c22f798 | ||
|
87133ef6b7 | ||
|
1ef2f014ee | ||
|
0a92d1d684 | ||
|
ff5221b693 | ||
|
db484cc4b8 | ||
|
6442963f49 | ||
|
0f7b95ce47 | ||
|
632a2e0894 | ||
|
e9635c7b2d | ||
|
8e3b1338a5 | ||
|
9d3dde0900 | ||
|
c5abaeddca | ||
|
ca2cd6f3e7 | ||
|
7d07e0312a | ||
|
e1c73fd8f4 | ||
|
b83ab21283 | ||
|
8001156ca8 | ||
|
57e31f0a58 | ||
|
51fadf6b7e | ||
|
2a6a8aa0a0 | ||
|
aa264a7fb2 | ||
|
5e35c2b6ab | ||
|
0385372314 | ||
|
efbff95ec7 | ||
|
2a9edb2153 | ||
|
be14e60d9e | ||
|
ef4641cad7 | ||
|
100f30043f | ||
|
1574b5b0a2 | ||
|
012fe99ab1 | ||
|
8ff5a3e096 | ||
|
65317eb019 | ||
|
ac3e26b0ff | ||
|
e86f450428 | ||
|
7b2776fdc7 | ||
|
2a16d1d230 | ||
|
53e1c9ab11 | ||
|
410abc4626 | ||
|
a2e28443f0 | ||
|
c1af0a3f21 | ||
|
bb5e1ee2f9 | ||
|
3aee89c8fd | ||
|
44e1f9f682 | ||
|
37d76b961c | ||
|
1305663d99 | ||
|
8f4efe57a2 | ||
|
0613dbc4a2 | ||
|
0ed0d69368 | ||
|
2ffbbee1f6 | ||
|
b9d2f2537b | ||
|
69dc173979 | ||
|
ded8b5ebd4 | ||
|
ed58ae9f98 | ||
|
f7f790b4b3 | ||
|
fe74c80992 | ||
|
fa659bf7ad | ||
|
9b41649601 | ||
|
1b3438f5a5 | ||
|
3eed64e5c4 | ||
|
0fac33781d | ||
|
3135b6a33d | ||
|
2686ae2322 | ||
|
a709e29586 | ||
|
dd46579cb4 | ||
|
f4b7210e7b | ||
|
05a0b0d7b0 | ||
|
c1f4d7506a | ||
|
b6ba0be550 | ||
|
23dfb4e2f9 | ||
|
7a10e31982 | ||
|
de89c4fd01 | ||
|
5d4956d34b | ||
|
42c5eb59c9 | ||
|
09cc6e7754 | ||
|
4a5bc41e89 | ||
|
0ade18828d | ||
|
91046e6ca4 | ||
|
17e1ba8ae2 | ||
|
c47c854f15 | ||
|
e931866b35 | ||
|
7828a065bf | ||
|
3e689e700e | ||
|
a9964afcf7 | ||
|
95c19876c6 | ||
|
5efccfa5e2 | ||
|
89e737a258 | ||
|
8fbc853b0d | ||
|
2e008b319c | ||
|
ff6e3c95f2 | ||
|
7e9385405f | ||
|
592ea36a86 | ||
|
e059ebf99d | ||
|
609480ed78 | ||
|
4271185936 | ||
|
aacae62591 | ||
|
47cbf3828d | ||
|
46d418164d | ||
|
ede8d84884 | ||
|
53d223b45f | ||
|
ac35dd5a6f | ||
|
9e19012cb0 | ||
|
1234cda3b3 | ||
|
710a0e3a45 | ||
|
b7f24b2456 | ||
|
fc594b551a | ||
|
f39ccccc0c | ||
|
f0a4ddd78b | ||
|
c691769e46 | ||
|
19dc30567e | ||
|
a453bccff0 | ||
|
aa2053a575 | ||
|
3d8f71c4d2 | ||
|
6aaaabbc4d | ||
|
42c36f48ed | ||
|
a5f4139102 | ||
|
030d85a9b3 | ||
|
adcfb7fb55 | ||
|
cec365888a | ||
|
55bfa8dd11 | ||
|
e99759fe45 | ||
|
17c6e6ee3f | ||
|
7fff900a1a | ||
|
c67974e4c8 | ||
|
a36696e02e | ||
|
9b80ca6c41 | ||
|
22f514aabf | ||
|
211478e13e | ||
|
5e33a7e58b | ||
|
b2e31721e8 | ||
|
de0dbfa359 | ||
|
f93459579f | ||
|
2b81c40b90 | ||
|
233e97c5e4 | ||
|
fc1ce48dc7 | ||
|
fd5562eebe | ||
|
0695d9cb5f | ||
|
456b24134d | ||
|
f8ba24afee | ||
|
eebb921c9f | ||
|
e17ee87f38 | ||
|
18e3f07f7d | ||
|
9ce39a470f | ||
|
23572369fc | ||
|
01b350de96 | ||
|
365e470a32 | ||
|
a42b40656c | ||
|
40160f2a57 | ||
|
90b33b1552 | ||
|
5567ed01e5 | ||
|
cbe9448650 | ||
|
5b345534dc | ||
|
c8dc318fb3 | ||
|
23cb1a1080 | ||
|
21cf8d7d3c | ||
|
3cf4d34094 | ||
|
16d78ae5db | ||
|
62b4b7af83 | ||
|
9799ecac6a | ||
|
dccb766095 | ||
|
c97983a91c | ||
|
680fb07fd5 | ||
|
cfd0ea197c | ||
|
48d4ed9bc0 | ||
|
3bed78356e | ||
|
8923922f30 | ||
|
7542e42e4f | ||
|
7a9b23e4f4 | ||
|
47253ba2a1 | ||
|
69b54dd9e4 | ||
|
36138617fc | ||
|
231ca50700 | ||
|
c7613f3e91 | ||
|
05d5546eb1 | ||
|
cefe67726e | ||
|
1ac2dcc537 | ||
|
3a68eecb28 | ||
|
54a8259b42 | ||
|
32b6f1619f | ||
|
99b8c5d379 | ||
|
5deb7c55e1 | ||
|
9cd25dd216 | ||
|
4a9ccf7e38 | ||
|
2963b9f07f | ||
|
a4a9bc4d8e | ||
|
a16a029790 | ||
|
97fea81599 | ||
|
ccffb6ecd6 | ||
|
63b5a1a4d8 | ||
|
dfc777803a | ||
|
934a9bb23e | ||
|
7097f7a894 | ||
|
537fd7c4ba | ||
|
d5048b8b0c | ||
|
0348556aac | ||
|
d6329b9dce | ||
|
34f3d29d93 | ||
|
cd701761f9 | ||
|
23c2c00d69 | ||
|
fa501b46cf | ||
|
38dc0a5c5d | ||
|
685cc4edbc | ||
|
78369375e3 | ||
|
6587058f74 | ||
|
30f738e49a | ||
|
726ca01e5c | ||
|
83b40b8cda | ||
|
db0d0438ff | ||
|
3c527488e7 | ||
|
99abcf6ded | ||
|
7009727559 | ||
|
ae02fba141 | ||
|
76cdeb62e3 | ||
|
ae9627c64c | ||
|
58875bdcd7 | ||
|
616caa5d30 | ||
|
8236ee3ff6 | ||
|
19f2804661 | ||
|
c62ba5f48d | ||
|
22bee8128a | ||
|
39150eb8c7 | ||
|
1b14fa53ef | ||
|
cf55e5d4f8 | ||
|
1a1ea028f6 | ||
|
814c3445a3 | ||
|
075dcee042 | ||
|
fe97a03033 | ||
|
f593aad786 | ||
|
4a8c602a59 | ||
|
7143dbc46a | ||
|
e69699e12c | ||
|
d6dbdbf27a | ||
|
a0dae55a69 | ||
|
7f15fb2a21 | ||
|
d5aa8db36f | ||
|
357b6c9d8c | ||
|
b0c4794305 | ||
|
071206ef59 | ||
|
63ab8e6341 | ||
|
741b0d6e82 | ||
|
3041faffab | ||
|
30ee690401 | ||
|
22a169bc31 | ||
|
ac19803d03 | ||
|
95485ee89b | ||
|
bc61f69058 | ||
|
0b86d6a451 | ||
|
0317731dc9 | ||
|
3dedb52163 | ||
|
ad393b83a2 | ||
|
01dac453db | ||
|
03abdf49a0 | ||
|
83b9149930 | ||
|
5ca5cbd447 | ||
|
597e89efe3 | ||
|
683e44f5f8 | ||
|
0b36d4e360 | ||
|
67606e2460 | ||
|
b6c6b30c0d | ||
|
e5935f0ced | ||
|
75c15e8028 | ||
|
4831ae17d9 | ||
|
22655d7554 | ||
|
ff0e430e46 | ||
|
e86dc8c338 | ||
|
0814de6371 | ||
|
34bc6907d0 | ||
|
a6dd1a2b4b | ||
|
4fe5d3d5e3 | ||
|
937fe7e909 | ||
|
89ab1e679d | ||
|
559984b2fe | ||
|
3ac9540351 | ||
|
d5709c9d70 | ||
|
891cc95add | ||
|
0246b5657a | ||
|
26ca1fb9f3 | ||
|
6b4355b76f | ||
|
90bd9692f5 | ||
|
8878185628 | ||
|
15066d1d37 | ||
|
abaae6e28b | ||
|
2170de8819 | ||
|
300ec667f6 | ||
|
348c4380d6 | ||
|
98388d18de | ||
|
bbc5753b96 | ||
|
564eecaa3b | ||
|
0480920058 | ||
|
d977dd4395 | ||
|
ca402379a9 | ||
|
903bf2135d | ||
|
1f732585b2 | ||
|
224de0601e | ||
|
9b84337830 | ||
|
a4665c27df | ||
|
3337015346 | ||
|
42c466296a | ||
|
a9fcf9db47 | ||
|
f3b55fcab0 | ||
|
b56b6509b1 | ||
|
ac85e383a9 | ||
|
2b326e90b8 | ||
|
3e8be645d2 | ||
|
81444265f4 | ||
|
5716ab70ec | ||
|
faaef7686d | ||
|
9e6f5b6b2d | ||
|
d28465bf60 | ||
|
867fec260b | ||
|
f5309d902a | ||
|
82823e50dd | ||
|
394f79e9d3 | ||
|
595bbbd3e4 | ||
|
2127572c33 | ||
|
7d6c927684 | ||
|
9d2d4c82df | ||
|
515ce9bebb | ||
|
7698bb0ae1 | ||
|
c89a5148b2 | ||
|
c37adba77b | ||
|
95cc3dec3f | ||
|
42c4a91041 | ||
|
d253dad2ee | ||
|
7f0265e674 | ||
|
b9726ba66d | ||
|
b20ffa7369 | ||
|
854abdf5e6 | ||
|
d0fc8a572c | ||
|
8bc1ca0e44 | ||
|
d38bd138cd | ||
|
7766bc25d1 | ||
|
34244656a6 | ||
|
619849c793 | ||
|
927b2b3942 | ||
|
76389e057f | ||
|
0a14e491ab | ||
|
1f7f1c1ffb | ||
|
6440733002 | ||
|
02802af97f | ||
|
a8169a3d6b | ||
|
9ba7fc94a5 | ||
|
48b71a02d7 | ||
|
18ed04b990 | ||
|
d09e03606c | ||
|
b2017f5653 | ||
|
c16eb80d7f | ||
|
0c56f98a92 | ||
|
490940cd53 | ||
|
92d27b0aa3 | ||
|
ca9c83f824 | ||
|
fc900e2432 | ||
|
e3257e56ab | ||
|
7d2337c6eb | ||
|
58629f1fea | ||
|
132ec0a5fc | ||
|
c2b47430fb | ||
|
7906592230 | ||
|
f57378d8ba | ||
|
1ccdc225af | ||
|
3e4df86ac0 | ||
|
7054cf7a35 | ||
|
2a7fc9e30e | ||
|
f1b4f15dbb | ||
|
c98152e9d0 | ||
|
7c34859e0c | ||
|
dd38e096b2 | ||
|
ea89efbed7 | ||
|
61408a0f29 | ||
|
cca004efe4 | ||
|
da3f3da92c | ||
|
f0c35819bd | ||
|
ff616002cf | ||
|
e1c79869b6 | ||
|
bd43403f5a | ||
|
d3997cc4d1 | ||
|
5b0b8579b2 | ||
|
c927de137c | ||
|
eb23d505f8 | ||
|
2400cf16a4 | ||
|
bbe3ace533 | ||
|
3b87eb3d08 | ||
|
d43a17304e | ||
|
21d41b8e81 | ||
|
332eaaf916 | ||
|
0a5ada6411 | ||
|
963f8d3485 | ||
|
60a8c5f1c9 | ||
|
d1a1024465 | ||
|
0d7ff9ac47 | ||
|
752d5685dc | ||
|
c6c517431f | ||
|
ee54f54ced | ||
|
2c5c96e159 | ||
|
a10763138e | ||
|
208eb0ca07 | ||
|
f0403fa9e4 | ||
|
3f86b250e6 | ||
|
d1819f5f76 | ||
|
19c7e63858 | ||
|
7efdcc26fe | ||
|
3ab3970dd2 | ||
|
5ab487dbae | ||
|
55fbc2c78e | ||
|
643426e2b2 | ||
|
f31a834613 | ||
|
683080be53 | ||
|
d14b8a9ad6 | ||
|
0f87ba6c93 | ||
|
02bfa0898c | ||
|
f5313f92f1 | ||
|
e41a258b93 | ||
|
ffa85cda1a | ||
|
0123d41647 | ||
|
2b0481deed | ||
|
1389f86675 | ||
|
cf6bb88af2 | ||
|
8e19a267bd | ||
|
3b55709e7f | ||
|
f78bca4ad8 | ||
|
713feca582 | ||
|
26c20ed91d | ||
|
e399249f31 | ||
|
b4a1b4b59a | ||
|
b309a88bea | ||
|
e88bee49a6 | ||
|
ec12770693 | ||
|
5b3a18319e | ||
|
3b73278348 | ||
|
0ca2cb625e | ||
|
67561f97ec | ||
|
b667bae65d | ||
|
54be9bd8b9 | ||
|
06d0299639 | ||
|
84851e230f | ||
|
52aed9e0de | ||
|
ead9a550fd | ||
|
cf80b492a3 | ||
|
69f3d2678e | ||
|
8038bc2fc8 | ||
|
f20b12cf3f | ||
|
c8bd53509c | ||
|
006124d816 | ||
|
efd73ac956 | ||
|
b7d7334451 | ||
|
8284865f9a | ||
|
1f8b04cbd1 | ||
|
b3402a0b9f | ||
|
4037959945 | ||
|
d7313a3274 | ||
|
8302086942 | ||
|
6095db951b | ||
|
817d2764b6 | ||
|
62189602cb | ||
|
0120dcc787 | ||
|
6bfc0ec3a7 | ||
|
f999d879d5 | ||
|
c861e2d9cf | ||
|
e696978d11 | ||
|
fbf2e942a9 | ||
|
d18f282938 | ||
|
c10be7eaec | ||
|
05ecad4263 | ||
|
4cdb159ccb | ||
|
fccb25586f | ||
|
ab2f3307eb | ||
|
db26a103d6 | ||
|
32902f79ad | ||
|
fab33dd230 | ||
|
daaa025356 | ||
|
ffe272c165 | ||
|
6e763d2776 | ||
|
c71b433a35 | ||
|
0b91d55269 | ||
|
9f41903067 | ||
|
64de8807e2 | ||
|
3848cbe24a | ||
|
15ac7b08f7 | ||
|
e47ecc1828 | ||
|
c09641cf47 | ||
|
92467db591 | ||
|
ea5e7182ab | ||
|
d38d53d9dd | ||
|
c9e094d9fc | ||
|
af75985ec6 | ||
|
4b7c05903b | ||
|
695912c7cf | ||
|
5c06306ccc | ||
|
d4fd17f64f | ||
|
76d94e69ae | ||
|
0f42744f5c | ||
|
e8daf7c73b | ||
|
0cf1af5bbf | ||
|
a343328a21 | ||
|
53a56b82af | ||
|
64dd4dc219 | ||
|
9e9da42c64 | ||
|
5c410f4ca2 | ||
|
0778211116 | ||
|
574563d711 | ||
|
e9d0b424d5 | ||
|
eef981e05f | ||
|
9f24f4bc69 | ||
|
5da9818676 | ||
|
ff59b07986 | ||
|
1b6d4fd277 | ||
|
7b19890deb | ||
|
5370443ece | ||
|
ad4fb1cf84 | ||
|
7f8169f0da | ||
|
66e8652862 | ||
|
05cbdbc1ef | ||
|
38584a1fca | ||
|
d96d8c49ac | ||
|
4bb623a0a3 | ||
|
3aa94a0997 | ||
|
ccad4ae04f | ||
|
346b9ae5a1 | ||
|
12f36debae | ||
|
87acec6a91 | ||
|
58a5e654f9 | ||
|
e278953191 | ||
|
573ddf8aec | ||
|
4f32243214 | ||
|
601bdfb1b4 | ||
|
90454a93b2 | ||
|
640921cd3f | ||
|
fccee959b1 | ||
|
67a8ecf2bf | ||
|
d8701890b2 | ||
|
2435f46d06 | ||
|
4bece787c8 | ||
|
d4ce938679 | ||
|
033fe9f133 | ||
|
25b10dc264 | ||
|
a9c3630d1b | ||
|
f3d99f41d4 | ||
|
fdb46b857f | ||
|
8d06df9775 | ||
|
a8d6e60ec6 | ||
|
4e643fa42c | ||
|
eb234bbf91 | ||
|
db1a221427 | ||
|
5378f35239 | ||
|
622f5eb967 | ||
|
966d827d35 | ||
|
bed56d3e52 | ||
|
24173d5ebc | ||
|
60853b5e54 | ||
|
da2ff552c5 | ||
|
742df52236 | ||
|
1b4621962f | ||
|
0a36828ff3 | ||
|
85ea4297b9 | ||
|
34cc3419fa | ||
|
46fcd2e844 | ||
|
23f0cdf901 | ||
|
26bdf66659 | ||
|
cf6f1dd01e | ||
|
286eb59081 | ||
|
40bb28e9b6 | ||
|
aac085a9be | ||
|
58e68901c7 | ||
|
8e69c6e492 | ||
|
4d98a14cb1 | ||
|
5bf99dfd61 | ||
|
bc42415ceb | ||
|
284e6a80ac | ||
|
0243882238 | ||
|
877eee408e | ||
|
8dd54de326 | ||
|
09d729bfba | ||
|
9caaca742e | ||
|
ac95c3ffbf | ||
|
9715d80030 | ||
|
a0a1e5c078 | ||
|
d7ba1fdd3d | ||
|
2544fca519 | ||
|
0b55e2c332 | ||
|
b105046202 | ||
|
de20255c71 | ||
|
1a1c37db7c | ||
|
a87700a28c | ||
|
1f8e9ad0fc | ||
|
e13e978af4 | ||
|
28e334c728 | ||
|
15a9427112 | ||
|
010b0e1d75 | ||
|
cd5ddca00d | ||
|
f18e1fccfd | ||
|
773b8c5a54 | ||
|
fc3d18ed64 | ||
|
68ed281461 | ||
|
65ada37399 | ||
|
9f539d7028 | ||
|
c73a5ff918 | ||
|
9858d4e918 | ||
|
0dfb1d264e | ||
|
a056b9115b | ||
|
62ecc04212 | ||
|
4a0f4fc186 | ||
|
3a61dcd360 | ||
|
04d0240f8d | ||
|
13ebfc0779 | ||
|
d70d5aa9d8 | ||
|
70d3c2cd3e | ||
|
6fbe0dec2c | ||
|
9d3591dcd5 | ||
|
8992f36fbf | ||
|
3d203aa7c4 | ||
|
cd8d7e6de9 | ||
|
5d4e6f17ee | ||
|
49f707ec93 | ||
|
6a305df46d | ||
|
35e9482574 | ||
|
dac61d4e9c | ||
|
d52e825bbc | ||
|
4fa463dff6 | ||
|
ebaa16f403 | ||
|
175741ed1d | ||
|
8d9d9899b7 | ||
|
cff7448fb2 | ||
|
0f8f510ebb | ||
|
3812c22f86 | ||
|
2b3000dddc | ||
|
b278baf94e | ||
|
4119b72d50 | ||
|
da2c15ecb4 | ||
|
25a702fc22 | ||
|
ab178057db | ||
|
c44cf5a720 | ||
|
98ca01bf2d | ||
|
d0ed873ab6 | ||
|
0f24399887 | ||
|
abbbda6f74 | ||
|
1a5ee7ab83 | ||
|
3a258ee5c9 | ||
|
4d41fdf0fc | ||
|
1586c4b0c7 | ||
|
9198e97401 | ||
|
346267c82f | ||
|
529f72325f | ||
|
1cf1209586 | ||
|
36774529a4 | ||
|
27dcb1008c | ||
|
e8a9c7b13e | ||
|
7be59851d5 | ||
|
15cf9ec365 | ||
|
c44c904161 | ||
|
9e3d8d1650 | ||
|
7b9668fe01 | ||
|
2334c48e02 | ||
|
afb949a417 | ||
|
c9bb85c91d | ||
|
13e1667d61 | ||
|
3c106c9cec | ||
|
1988668d10 | ||
|
484d7f91e5 | ||
|
53d58f222f | ||
|
d5a72b1eaf | ||
|
6b5ebab6ae | ||
|
8107df08a8 | ||
|
dc29500931 | ||
|
31fc1aca53 | ||
|
0db4b04ad3 | ||
|
1aa9ea92e2 | ||
|
2698f54a9c | ||
|
6f977248bf | ||
|
046fd62dc4 | ||
|
da60dda2dd | ||
|
d25fb08a75 | ||
|
79e105243c | ||
|
2d4e531ac9 | ||
|
52403ad9ed | ||
|
2d264855cc | ||
|
c172c72be9 | ||
|
79259fdb3f | ||
|
cee35f7d24 | ||
|
1f5f17622e | ||
|
e8f7f80f2b | ||
|
6db8beeade | ||
|
4f66313440 | ||
|
89b5bcfdc7 | ||
|
26f706ebe3 | ||
|
0cb38085a1 | ||
|
cff6644b28 | ||
|
63837530ed | ||
|
62e09e73f7 | ||
|
daef0a2374 | ||
|
042045b998 | ||
|
bad7284465 | ||
|
6f0cb6365e | ||
|
653ec05c0e | ||
|
be2a751513 | ||
|
840adfbbcf | ||
|
acf32be842 | ||
|
3999613eca | ||
|
bff85725d2 | ||
|
93008b2369 | ||
|
be336e7514 | ||
|
255f7f2dee | ||
|
de2c07ac62 | ||
|
844d54d7e6 | ||
|
ff3e6c7248 | ||
|
408a2229d6 | ||
|
7cdd65075c | ||
|
436ce16e79 | ||
|
58320e2678 | ||
|
a6f7edf94b | ||
|
4a4f13be46 | ||
|
a13b0abb7d | ||
|
c081919320 | ||
|
21f7f78130 | ||
|
bb1b24c178 | ||
|
3f30000088 | ||
|
e6ce39f76e | ||
|
10116b7717 | ||
|
18edb8bd63 | ||
|
dae1aeb1f7 | ||
|
57085c892f | ||
|
d67efb2cab | ||
|
0e09ecbaa5 | ||
|
e3699070a4 | ||
|
bf40855825 | ||
|
3ee4f2810d | ||
|
79468cf676 | ||
|
4037942a26 | ||
|
cae6c9ab36 | ||
|
15b393193a | ||
|
53ab34928c | ||
|
eb4a169cfb | ||
|
6f6cadf31d | ||
|
17513a6dce | ||
|
a44560ddb6 | ||
|
2b8afb38b7 | ||
|
685ad74d53 | ||
|
288ea11534 | ||
|
b848ff8db9 | ||
|
5881fcb0d6 | ||
|
491a2e8732 | ||
|
4a620a2c5e | ||
|
05105155f8 | ||
|
9f96545fa7 | ||
|
0c60107e62 | ||
|
49eb9cbdd8 | ||
|
594d226056 | ||
|
aac7dccf45 | ||
|
c19e325b83 | ||
|
bd92c23add | ||
|
88335bd92e | ||
|
a4602021d8 | ||
|
dbe5c17a96 | ||
|
c40555c0ac | ||
|
bfc76278a9 | ||
|
a1f283946e | ||
|
066087b383 | ||
|
e9d42e059f | ||
|
d1dadc9814 | ||
|
2cc620ef33 | ||
|
cee705ccd3 | ||
|
a8f72424db | ||
|
31ed133932 | ||
|
d3c6974e99 | ||
|
1271081865 | ||
|
8a638a95a0 | ||
|
d9f726f2a5 | ||
|
5f3521b3d4 | ||
|
9a68bd8cc8 | ||
|
9b7812a0f2 | ||
|
4858d7e454 | ||
|
fbb3f41dff | ||
|
1472048b97 | ||
|
4aad51a352 | ||
|
9a0a0c2d8c | ||
|
fcc809f4f1 | ||
|
f3369677ef | ||
|
a03f9eb156 | ||
|
aa65dd8905 | ||
|
856b4f4654 | ||
|
9369fe8c27 | ||
|
1549ff12f1 | ||
|
70357ceff2 | ||
|
cfe7cac1c4 | ||
|
fb70eca0a3 | ||
|
cf2bf488a2 | ||
|
5c02fc47b9 | ||
|
4021e5eea9 | ||
|
5cd0b6272d | ||
|
bf49bebe7a | ||
|
1e8299e893 | ||
|
5381061d97 | ||
|
274558c430 | ||
|
188afe20f9 | ||
|
1add9c9a02 | ||
|
e7d4b99350 | ||
|
8627721533 | ||
|
6696416107 | ||
|
453be2e08a | ||
|
83497e4dc9 | ||
|
3806a9c320 | ||
|
4da95066a0 | ||
|
ab1105524f | ||
|
d70b743e03 | ||
|
920dd078f3 | ||
|
f8e780b9dd | ||
|
588910129c | ||
|
e42867f0a8 | ||
|
fe20afac17 | ||
|
10578ff08c | ||
|
1f0513cf4e | ||
|
647470f3ae | ||
|
efd0dbe5c2 | ||
|
bd2fe64bf1 | ||
|
7153db954f | ||
|
3b425affd3 | ||
|
d5a79ad5d7 | ||
|
7951338d27 | ||
|
90801267ee | ||
|
8d57823e51 | ||
|
277ccc5e18 | ||
|
cff9db5044 | ||
|
216f905670 | ||
|
53b2308011 | ||
|
c368500efd | ||
|
2fed68a73b | ||
|
e7ab49c973 | ||
|
5496491aa4 | ||
|
53ca5b2870 | ||
|
6aced26c35 | ||
|
2331750b58 | ||
|
b3fb4c1265 | ||
|
3ad7b9b117 | ||
|
5721debdf1 | ||
|
c1c23d1e7b | ||
|
9605641982 | ||
|
e52672c263 | ||
|
50f070980e | ||
|
7733849478 | ||
|
4bbc8a89a0 | ||
|
c87882e82f | ||
|
bd4301b2c1 | ||
|
e771f4e75e | ||
|
35835469d7 | ||
|
0d6992fcdd | ||
|
29b3f471cf | ||
|
4985875a15 | ||
|
4fffd3a111 | ||
|
590749e8be | ||
|
27cc76766c | ||
|
d52cf87d71 | ||
|
2ddd6895e1 | ||
|
545e7d2de8 | ||
|
a9ed6b352b | ||
|
523eebe47d | ||
|
b303d8bc40 | ||
|
68118f4233 | ||
|
fcc6b97f88 | ||
|
adc4398cc5 | ||
|
c53d26cfca | ||
|
c188bee229 | ||
|
7f1a89e3f6 | ||
|
5d46f3fcab | ||
|
b55d95d365 | ||
|
494cc8bace | ||
|
03e8c0f45c | ||
|
b6388a15ff | ||
|
45a18a61c6 | ||
|
1857a44c7c | ||
|
bd9e1475e2 | ||
|
6883267996 | ||
|
b88c784634 | ||
|
31020f9eea | ||
|
e89d59995a | ||
|
bf324a11cd | ||
|
e149433a80 | ||
|
65d02e495e | ||
|
f196a9fd27 | ||
|
7f0398ca25 | ||
|
d7f05722d4 | ||
|
26377a2195 | ||
|
aa4eaa16bf | ||
|
abc7bfe5c9 | ||
|
f0f4499540 | ||
|
dae4f9fef6 | ||
|
4c45c6fbd8 | ||
|
172cf26d77 | ||
|
feefb7e7e2 | ||
|
ced44a15ea | ||
|
5c2855e1c1 | ||
|
433785dc64 | ||
|
28845b96bd | ||
|
98ec35cee1 | ||
|
f795297e15 | ||
|
3fd3c47e6d | ||
|
153c25dbb3 | ||
|
a1a6b7e64f | ||
|
3ea7fb18d6 | ||
|
6ff52332a8 | ||
|
5e75b104d6 | ||
|
dc893701f9 | ||
|
e6b0aaf94a | ||
|
e754cbf763 | ||
|
5988895d69 | ||
|
2af5eea2c6 | ||
|
554acb7429 | ||
|
9c5869ce5a | ||
|
e641ff64fd | ||
|
aa731e3297 | ||
|
ac6407bb8e | ||
|
baf08eee09 | ||
|
04a43cd6a1 | ||
|
ed8d099607 | ||
|
b693d0cd91 | ||
|
fafedd2d59 | ||
|
f3a7ef1199 | ||
|
cb890c96b9 | ||
|
37bfa092a5 | ||
|
c517cb64ae | ||
|
51e09fa504 | ||
|
691172e28b | ||
|
6cf6d2159b | ||
|
17f0b417d5 | ||
|
d89baf4c5b | ||
|
2eb52cd047 | ||
|
f5492aed12 | ||
|
c2efd6ee58 | ||
|
be507bf1cc | ||
|
f11f3ce8b7 | ||
|
b2a3e930c1 | ||
|
147bf04d08 | ||
|
f4d3616c4b | ||
|
c97c025adb | ||
|
c55336e78d | ||
|
13e9135935 | ||
|
5c1e44a93d | ||
|
75adf9e75e | ||
|
0fa09f6af4 | ||
|
011ed270e8 | ||
|
d7e58ce10e | ||
|
813536d4c6 | ||
|
b89023efa1 | ||
|
b155347560 | ||
|
15faf742f1 | ||
|
2ba7d1639e | ||
|
a2de7cf070 | ||
|
c6d558b6f2 | ||
|
d1b97c0ba9 | ||
|
755ce0a016 | ||
|
79334ca5ab | ||
|
11e9752536 | ||
|
72b0f9e8f7 | ||
|
408a162044 | ||
|
7d6444491c | ||
|
7bfb6d6b76 | ||
|
e1be7f3d6f | ||
|
04a8485b17 | ||
|
f330dd210e | ||
|
97dc27b5fa | ||
|
1fd43fe673 | ||
|
29e21cc7f3 | ||
|
292fc153ef | ||
|
25d3c83d3b | ||
|
6b7f3db28e | ||
|
eec6e28b19 | ||
|
f3e379cf78 | ||
|
0258c47774 | ||
|
f63df65245 | ||
|
099137fe9a | ||
|
36f253893e | ||
|
8280c0d64c | ||
|
4f98b000eb | ||
|
b5d61b963a | ||
|
a7f7984c4a | ||
|
dd33c16aae | ||
|
e0bf0c0301 | ||
|
8d8aacf5e9 | ||
|
e085ba7fcc | ||
|
33f881ac8b | ||
|
b24ef39b9d | ||
|
a6d8b52686 | ||
|
65407539bb | ||
|
543060683b | ||
|
2848e51755 | ||
|
0db4978899 | ||
|
0284a23d0a | ||
|
7e728869cc | ||
|
a19d93e1a2 | ||
|
5aefa1af3d | ||
|
f1718fb5b3 | ||
|
6b527a50dd | ||
|
74df115fc1 | ||
|
3adfeeec3e | ||
|
c4df94a1d9 | ||
|
da1d98d603 | ||
|
6683418983 | ||
|
2c1d97f1ad | ||
|
2f854428bc | ||
|
c1a524a969 | ||
|
23807e12e8 | ||
|
87ec1ab97b | ||
|
b057b979fa | ||
|
7dc378e296 | ||
|
6d8cc30f12 | ||
|
0335e3fcc0 | ||
|
76aa1059cd | ||
|
b0a25f0183 | ||
|
db1babab5e | ||
|
7ea951613d | ||
|
6506b73523 | ||
|
639029007d | ||
|
01eb59ca9b | ||
|
a8b5e3da29 | ||
|
8cc0997f79 | ||
|
ffb7c317b5 | ||
|
bb7420fc22 | ||
|
0df9164e7c | ||
|
dcd590b9de | ||
|
8dc3a66688 | ||
|
88b4adebdc | ||
|
01f2438c1f | ||
|
eb51f37c67 | ||
|
4ef4d0659d | ||
|
2ce9a3f70f | ||
|
59cbdaaf49 | ||
|
e0cf16b7e9 | ||
|
1cdf09e9dd | ||
|
9966a6a4b7 | ||
|
20a1d1c519 | ||
|
313ec87dc1 | ||
|
a7ba6e447d | ||
|
baa978ab0b | ||
|
9f1b4fc9e7 | ||
|
38e5dbd866 | ||
|
50ed27946d | ||
|
856ac7d773 | ||
|
81f12df8b5 | ||
|
9eca3234e8 | ||
|
5a540bdd42 | ||
|
6d394b132d | ||
|
96a317ce68 | ||
|
bca8945c26 | ||
|
a4b108334f | ||
|
4f72cf9744 | ||
|
3c30f77d31 | ||
|
bcb6484062 | ||
|
11472eddbc | ||
|
12470f6221 | ||
|
a82d0e2f57 | ||
|
dca1d1e0d1 | ||
|
0cef8f3d26 | ||
|
fbde18fc02 | ||
|
b640c59087 | ||
|
1f3dea60d3 | ||
|
a7c06eadd0 | ||
|
39910f5137 | ||
|
6fc4eb92db | ||
|
81e82fb2d3 | ||
|
c817254495 | ||
|
4578b0ad11 | ||
|
9fbf82b603 | ||
|
4b0267910c | ||
|
54456aee9e | ||
|
2a31cdcded | ||
|
d3f31c6038 | ||
|
59dd9f6203 | ||
|
05cac05c06 | ||
|
724713ac80 | ||
|
72f3d5291c | ||
|
c138685364 | ||
|
4180d00a6c | ||
|
2512ac1e3c | ||
|
121fc0a273 | ||
|
4d9281018f | ||
|
3a94a60537 | ||
|
161e6fb8fb | ||
|
29fa474e4a | ||
|
ddb19f4a4f | ||
|
789fb1e7c9 | ||
|
521c5317a2 | ||
|
e0d85e60a3 | ||
|
ac7821f9bf | ||
|
84809db955 | ||
|
e6cecd97ac | ||
|
60e7deaaf5 | ||
|
23b07d8cb6 | ||
|
5f27697198 | ||
|
261d2c5ae4 | ||
|
847f7de003 | ||
|
dffc8df3e0 | ||
|
330d491eba | ||
|
db103ff340 | ||
|
1ac46bacfe | ||
|
c27a4ee61f | ||
|
2d8c4b1c88 | ||
|
d969f8621d | ||
|
a4ec91fd06 | ||
|
fd53472238 | ||
|
b3ddef2fc2 | ||
|
07d753176f | ||
|
8d758add63 | ||
|
506ab1c735 | ||
|
945020e505 | ||
|
5a7bcd0a4f | ||
|
ae92279f5c | ||
|
be33f5eb89 | ||
|
717a582085 | ||
|
ee87aee4dd | ||
|
2d6afeebe1 | ||
|
49bc58da04 | ||
|
f5831d5132 | ||
|
517ccc4088 | ||
|
90dd56b839 | ||
|
d1794f4c1b | ||
|
75bb4346b2 | ||
|
13477e5478 | ||
|
1093897838 | ||
|
4d27419d7c | ||
|
89e6d66872 | ||
|
b97c16a636 | ||
|
751ff59e2a | ||
|
64a549d051 | ||
|
7a686d4d21 | ||
|
7b218737cc | ||
|
b1520a87c3 | ||
|
2a2a34601c | ||
|
3c64b3da97 | ||
|
e7889e9ce2 | ||
|
7c8f45747c | ||
|
d37def7a72 | ||
|
452770e374 | ||
|
54e44ab477 | ||
|
6012d52fdb | ||
|
7ffa0766b4 | ||
|
d8e17111b9 | ||
|
9e602a491b | ||
|
f529afa625 | ||
|
5a4deb6e88 | ||
|
3bcd3cef2f | ||
|
fbe6f945f3 | ||
|
bb0f3839c1 | ||
|
af4026104c | ||
|
822aee2b4f | ||
|
f09334dc6f | ||
|
d1d2609f49 | ||
|
9aa6cdc494 | ||
|
8b403081c1 | ||
|
dc054c3f8a | ||
|
94c2810b0a | ||
|
6e83abdbf2 | ||
|
f03eaaaf33 | ||
|
71162ebdbb | ||
|
c75549f6db | ||
|
2ebc96d8eb | ||
|
29f2eeea31 | ||
|
a13981ffe4 | ||
|
cf152e6030 | ||
|
b279196af2 | ||
|
98e151fda7 | ||
|
7f3b5fb84d | ||
|
3d069f7b46 | ||
|
65c4f955a6 | ||
|
246b4b01c5 | ||
|
a680b71dc7 | ||
|
d0b5b09318 | ||
|
67f3a83c31 | ||
|
5dd260c336 | ||
|
ee6f165a1f | ||
|
0cc2ff83ed | ||
|
a9e92d6c5c | ||
|
ea5f07110b | ||
|
59746c2e36 | ||
|
6399e05209 | ||
|
08de642536 | ||
|
ab9e1b3aa7 | ||
|
af6744b112 | ||
|
1d86803e38 | ||
|
b12c19162b | ||
|
220608e52a | ||
|
06fb5c7c69 | ||
|
8970fd5d2f | ||
|
67d5f65507 | ||
|
7d678be07a | ||
|
74e2aa9c66 | ||
|
b9cc158e52 | ||
|
e68cf1c9ed | ||
|
f0fcc73f92 | ||
|
a340b3812c | ||
|
78c833a09f | ||
|
38888ba5b3 | ||
|
99e519cf0f | ||
|
09cb45001b | ||
|
9d3aa5a253 | ||
|
314308f975 | ||
|
b658ff2124 | ||
|
c844ea4423 | ||
|
db5af8ead1 | ||
|
c09dee7717 | ||
|
352281313f | ||
|
8afe18f148 | ||
|
90f348d26a | ||
|
8d3d06b7a0 | ||
|
c56ee8ec03 | ||
|
76f6c10434 | ||
|
cf64f2baca | ||
|
68a0193d95 | ||
|
80740f0e46 | ||
|
c60f790793 | ||
|
e0b4ec54bd | ||
|
d1bed6bf45 | ||
|
b82966e775 | ||
|
19a9d87486 | ||
|
3448e5867e | ||
|
e013d6b98c | ||
|
d392739049 | ||
|
12266ad004 | ||
|
e03c160e27 | ||
|
03f0e2196e | ||
|
34ea38c12e | ||
|
a33de607df | ||
|
e39959a132 | ||
|
33a42202c7 | ||
|
efc358da9f | ||
|
c1b39eb2ce | ||
|
12e30f0eb4 | ||
|
94bf971f72 | ||
|
bcfa9241b8 | ||
|
eea9d6136f | ||
|
c35f33e61a | ||
|
78eeba940a | ||
|
b3ed5f77f2 | ||
|
38f6b5ea71 | ||
|
c000a6164c | ||
|
cb6208a6fa | ||
|
b540558db6 | ||
|
e70b2dfbb2 | ||
|
f64cad89c4 | ||
|
935b3de2ad | ||
|
abc0359522 | ||
|
fcd48d9b2d | ||
|
97a79a4511 | ||
|
31172b0ecc | ||
|
74bd1613bd | ||
|
1fb3f95fdb | ||
|
ca571e7a7a | ||
|
52b6be0dfe | ||
|
abd6a6784e | ||
|
978df46611 | ||
|
31c428cece | ||
|
67c892991a | ||
|
5743adc467 | ||
|
76fc166e11 | ||
|
459cd21070 | ||
|
fc53e3339f | ||
|
9b788a882d | ||
|
5a3e0d5e85 | ||
|
ce4da69cc0 | ||
|
1a779077db | ||
|
e79531b292 | ||
|
7fea60183f | ||
|
41df6c4df2 | ||
|
b6a28b497b | ||
|
c75fbabc0f | ||
|
4cc0876efa | ||
|
abe1e37253 | ||
|
4dec965569 | ||
|
f478eaa98e | ||
|
1e105f88ca | ||
|
6586f3ed29 | ||
|
ba7019de8a | ||
|
9562ce3b87 | ||
|
a48fe674ee | ||
|
d439f75491 | ||
|
c559067f77 | ||
|
30bd80bd85 | ||
|
5709cb10d1 | ||
|
9329f8d3cd | ||
|
884c23a9c9 | ||
|
7a3a560c44 | ||
|
2963da1392 | ||
|
54f1941691 | ||
|
ca14ae19db | ||
|
6636ae6e63 | ||
|
2e75f42c69 | ||
|
c9547f383a | ||
|
65576707bf | ||
|
6ec8a06a09 | ||
|
9205c9d031 | ||
|
1ef80d6330 | ||
|
322665a22f | ||
|
cfa6d12691 | ||
|
c264c3e2dd | ||
|
d21bcd2f87 | ||
|
84f25b9f18 | ||
|
576fec4c36 | ||
|
48acafd10d | ||
|
a532a072ce | ||
|
2cd53c6ff1 | ||
|
18ccd55725 | ||
|
87eb569929 | ||
|
92387b1527 | ||
|
dd2f293f33 | ||
|
24e4f0aa87 | ||
|
6fe899af10 | ||
|
107fe0a142 | ||
|
b021be29e5 | ||
|
55e7844ca0 | ||
|
8dd85285e7 | ||
|
dbcbeb7a57 | ||
|
a9aee1c5b3 | ||
|
b3fe4b54c8 | ||
|
872ea6bf09 | ||
|
32fb9d51b9 | ||
|
ce637440bb | ||
|
61e4597488 | ||
|
26a064ed2d | ||
|
d5c9bac3c7 | ||
|
1665006401 | ||
|
5220ac4a9e | ||
|
ee0fdf016a | ||
|
8b4eedb594 | ||
|
01f5efa1d9 | ||
|
130bc26b9a | ||
|
09e83937de | ||
|
42e30468a9 | ||
|
3834acad5b | ||
|
654f7eceee | ||
|
ca9c8ae5fb | ||
|
1752086cfd | ||
|
369b2f7cd2 | ||
|
8b244ca988 | ||
|
fb9e51d943 | ||
|
bb3dc87953 | ||
|
6bcb422c80 | ||
|
540f865355 | ||
|
46ef71e3ec | ||
|
005450ff13 | ||
|
f809427575 | ||
|
9564eb2edb | ||
|
49708f209b | ||
|
14381fe8d0 | ||
|
17bec5c3ce | ||
|
2b90ab496a | ||
|
74dbf4cf70 | ||
|
e504aceeb5 | ||
|
3ce9ac74a6 | ||
|
3b0e7b4d0d | ||
|
5e856c6b4d | ||
|
6651a48c4d | ||
|
c031ae2aab | ||
|
1ac6c9f9c2 | ||
|
5d0eb6dda5 | ||
|
29c949ab03 | ||
|
576e389788 | ||
|
7b15a3d345 | ||
|
eedb43d756 | ||
|
338125b93a | ||
|
3ecc3ab798 | ||
|
de1cdb2dbe | ||
|
c9887874bc | ||
|
69fcaf14e5 | ||
|
f414198fee | ||
|
2de924a187 | ||
|
c1c2ff2d07 | ||
|
ff89f1476d | ||
|
e8d99cee70 | ||
|
ccfa3f03b0 | ||
|
baefe0b3f6 | ||
|
3669351427 | ||
|
79938b98da | ||
|
411d588fea | ||
|
7e63d773ef | ||
|
3e378f009d | ||
|
13db9d9452 | ||
|
c1c6e6265c | ||
|
a984b1b073 | ||
|
215b6aea95 | ||
|
96b7214ae2 | ||
|
1b0752b0a9 | ||
|
02329f61e3 | ||
|
7e29c48379 | ||
|
ad63efdaf7 | ||
|
6bec53dcd2 | ||
|
fef405ac98 | ||
|
97f9cc4bc0 | ||
|
7ab6fd9db6 | ||
|
b7ecec0c23 | ||
|
d12a858897 | ||
|
9716ff69c4 | ||
|
4dd1a24d0b | ||
|
c69c49047b | ||
|
bfbb4e4050 | ||
|
2aceb13f3e | ||
|
e9f34fbd26 | ||
|
17f9cdd401 | ||
|
156b856a80 | ||
|
e2e3df9013 | ||
|
ef8773a89b | ||
|
536f5d8203 | ||
|
631416d54a | ||
|
d366a06461 | ||
|
7bf8f14879 | ||
|
cd65d6de69 | ||
|
b57d514b1e | ||
|
f36be4d5e4 | ||
|
c2b0e223fa | ||
|
e32c856a04 | ||
|
bc7cd2ccc2 | ||
|
1842669104 | ||
|
c7535a91a6 | ||
|
99a5484dfb | ||
|
b78ae5ab10 | ||
|
f74d3e7e94 | ||
|
eba37e8fbe | ||
|
84fb11599e | ||
|
099812d219 | ||
|
c4291510e8 | ||
|
775a411215 | ||
|
59b4dd4c46 | ||
|
2f907e3a92 | ||
|
9971fd2864 | ||
|
23a394d1fc | ||
|
91d450df4e | ||
|
ea3943a87a | ||
|
019eda5b0c | ||
|
5056437ca1 | ||
|
90c912a5e2 | ||
|
9219613957 | ||
|
9858f2e499 | ||
|
6b0bf33f8e | ||
|
9ea6079072 | ||
|
478f16234d | ||
|
57a312cb1a | ||
|
bb88a74f92 | ||
|
4a07ce5fae | ||
|
043c4acc7e | ||
|
eb478e38b2 | ||
|
bf307e24c5 | ||
|
4a00590a1b | ||
|
4ccca079a5 | ||
|
9e5d1b3ba5 | ||
|
240f13a0a6 | ||
|
221ce33eb5 | ||
|
722943000e | ||
|
509a503761 | ||
|
bac1e4a850 | ||
|
934cc892eb | ||
|
b1c90f08cc | ||
|
680f19a424 | ||
|
621e0a8330 | ||
|
4449bf6f83 | ||
|
569c62e528 | ||
|
4c240edf94 | ||
|
0e977d66c1 | ||
|
3dee10772d | ||
|
1d72edcc4f | ||
|
c29b7d22d9 | ||
|
ee502aed49 | ||
|
414ff25564 | ||
|
b084b8b1d8 | ||
|
3ca19a8580 | ||
|
9c12a44d6e | ||
|
4706b0ada4 | ||
|
cc98e9850d | ||
|
af80db8c22 | ||
|
053d5ad24d | ||
|
e2805ac68a | ||
|
1caf05cc52 | ||
|
63cfb7db25 | ||
|
bdfc7d2a5a | ||
|
0ccbdcdd1f | ||
|
c598b2fa2d | ||
|
4f86448bd4 | ||
|
d235e7d46f | ||
|
e25b323d1b | ||
|
42093c48b2 | ||
|
9fca0b20f0 | ||
|
a6229d9e87 | ||
|
c443896644 | ||
|
79f11bd655 | ||
|
c5552dac1f | ||
|
734af31c13 | ||
|
2d96896fae | ||
|
20a0f82701 | ||
|
e4b7dbce7f | ||
|
0f128fd561 | ||
|
ac8a7bc12d | ||
|
90a299f424 | ||
|
00a7f5d75d | ||
|
2463fe92bd | ||
|
4f65fcd7b1 | ||
|
e41b92c55a | ||
|
3925f8fa16 | ||
|
cce1e36e26 | ||
|
3466c9c8cb | ||
|
6e2dadc63a | ||
|
00e89a23f6 | ||
|
a29e518cfe | ||
|
a7148b718e | ||
|
23fdc0eae4 | ||
|
8cb1bc89f1 | ||
|
1798a1fa12 | ||
|
f4c737ef42 | ||
|
611df4964d | ||
|
0a4ccf22da | ||
|
4fe98bf6e6 | ||
|
57c3023881 | ||
|
4408e079ff | ||
|
2991057aef | ||
|
6b4fea39ab | ||
|
a08ffcff50 | ||
|
6bd9f4a13a | ||
|
32420b77c8 | ||
|
0b8a84f536 | ||
|
f18a55831c | ||
|
58fb0decbf | ||
|
2124b7bf64 | ||
|
5b273a33b4 | ||
|
fb702f989f | ||
|
0203a0fdaf | ||
|
112a7ada74 | ||
|
452ba76507 | ||
|
2ac42c0d14 | ||
|
0955ea5b85 | ||
|
084bc72d90 | ||
|
57e2193432 | ||
|
ce8cf1e152 | ||
|
3da189f7c0 | ||
|
058d2d1bd4 | ||
|
f70f2f8c62 | ||
|
8d6086da48 | ||
|
bd6d88b884 | ||
|
4003218ceb | ||
|
ec3f2b76b0 | ||
|
fcb661d0e9 | ||
|
d8eb0558e9 | ||
|
5191948b64 | ||
|
7442d720f4 | ||
|
bbc859ca19 | ||
|
7275fb6f52 | ||
|
2d50202b2d | ||
|
f5dc16603e | ||
|
85b4d7c8d6 | ||
|
f0c962d274 | ||
|
486b6937d3 | ||
|
a6152ebadd | ||
|
63a475d88c | ||
|
3eba3224c8 | ||
|
247c4e55e7 | ||
|
26d7c27bee | ||
|
b492642282 | ||
|
cff78f5833 | ||
|
4ba19821ce | ||
|
1e385851d7 | ||
|
4643f74a03 | ||
|
6453d396bf | ||
|
92921f767e | ||
|
c251c4ccbb | ||
|
0ce670e45a | ||
|
2671b48a6c | ||
|
382478259f | ||
|
e3c333be47 | ||
|
a1a463787f | ||
|
a16ff07a06 | ||
|
3218caf34a | ||
|
01583ef540 | ||
|
dc13700094 | ||
|
1293af093c | ||
|
2998815166 | ||
|
9484c4dc05 | ||
|
521b0733d4 | ||
|
a463989278 | ||
|
a31719b546 | ||
|
f97cb00737 | ||
|
f2305fe5bf | ||
|
216cd6935f | ||
|
3a8f9484d2 | ||
|
3fa76b2d8f | ||
|
50648553cf | ||
|
70d03fd9c3 | ||
|
0a8cce6984 | ||
|
fb1a3a3a12 | ||
|
52e2722412 | ||
|
b64e4464a7 | ||
|
f1ab6feba2 | ||
|
e751461ff1 | ||
|
c7f42d1a4a | ||
|
6232ec78f7 | ||
|
f09d0f2301 | ||
|
14a071c478 | ||
|
e601ebe19b | ||
|
7068c45115 | ||
|
3bfcb0468e | ||
|
b2735eb30c | ||
|
552416bda4 | ||
|
b522413085 | ||
|
8a0fc92f20 | ||
|
4a34cd0662 | ||
|
11d83515dd | ||
|
7ce8ae72e8 | ||
|
cc7e122915 | ||
|
da84893921 | ||
|
1d5b6d7ae6 | ||
|
314991ac60 | ||
|
9b5b4cd505 | ||
|
c5069135d7 | ||
|
971c1f46b0 | ||
|
34c60e5486 | ||
|
526f21ae7f | ||
|
48597a94e8 | ||
|
0e77c3391b | ||
|
f1e79bde2e | ||
|
7b6849578b | ||
|
617fcc92cf | ||
|
18f0e4ba1a | ||
|
6fedffe6d6 | ||
|
d54e302a28 | ||
|
d99179f822 | ||
|
a6fbb3ef4c | ||
|
65cff673b8 | ||
|
dc166cad92 | ||
|
7d7ccac416 | ||
|
e933c5f481 | ||
|
2ba4b23b85 | ||
|
ba4ed0eb7f | ||
|
3cdf2b7f04 | ||
|
99b68c8352 | ||
|
a446f187c1 | ||
|
3ff541cf77 | ||
|
10895796b2 | ||
|
fbc58ebef8 | ||
|
5c54414be7 | ||
|
4df28728e2 | ||
|
f14a4c0b18 | ||
|
f5a27250b1 | ||
|
f95b189fe3 | ||
|
1aace95c8d | ||
|
7844471971 | ||
|
794a636dd3 | ||
|
e35414a0f1 | ||
|
0d0706a204 | ||
|
80f19324bc | ||
|
1b04c222cf | ||
|
5d04848886 | ||
|
fc14e831eb | ||
|
04d577262a | ||
|
7be3d2afe9 | ||
|
d1237d8984 | ||
|
1b391ccd06 | ||
|
7377bfcf07 | ||
|
665b708e6e | ||
|
f87049370f | ||
|
47948a34dd | ||
|
121a7dcedf | ||
|
240a58fd6e | ||
|
99e23b41eb | ||
|
cadb3d7da2 | ||
|
392d126372 | ||
|
871cca2401 | ||
|
1bdd556d3b | ||
|
9daad800a8 | ||
|
8d2c956563 | ||
|
0584d6d89b | ||
|
5763733490 | ||
|
894438d5fb | ||
|
2ad191aeba | ||
|
dd9d7e62d5 | ||
|
4e3e80109a | ||
|
70bef682b0 | ||
|
c2a9bf9974 | ||
|
23da9f13b0 | ||
|
a5a39c52b0 | ||
|
6355e9895d | ||
|
abf4af2645 | ||
|
cb71fea0f6 | ||
|
3e2d593dde | ||
|
4b66e94ecf | ||
|
40143cae1e | ||
|
b1277caeeb | ||
|
13cc6478fb | ||
|
c465250c21 | ||
|
815b52b8fb | ||
|
275167d1b0 | ||
|
45717147f7 | ||
|
f2f9f324ec | ||
|
8131d3e127 | ||
|
226d5a1d36 | ||
|
312fe4775d | ||
|
b368d18b0f | ||
|
8e4996baf4 | ||
|
b7cd502054 | ||
|
53ac379bc5 | ||
|
10e809cf64 | ||
|
3079551d30 | ||
|
f4c5c5a367 | ||
|
2a7b995723 | ||
|
d0beac70bd | ||
|
cbf66ac653 | ||
|
98f9cb8c1f | ||
|
8bd4c87d2f | ||
|
c88b568685 | ||
|
c83c9a3193 | ||
|
410c46f1ab | ||
|
1b8bf35acc | ||
|
aa47ac85c9 | ||
|
3eadda9466 | ||
|
dea6a7c217 | ||
|
887a104dd0 | ||
|
1808e3c4c8 | ||
|
1f4cae4bf7 | ||
|
3b009f5aa6 | ||
|
36112371c0 | ||
|
2fa538779f | ||
|
b7a6659451 | ||
|
102c31a04c | ||
|
f01da91abf | ||
|
10000c383a | ||
|
8b42b7d269 | ||
|
17702969fa | ||
|
cc3613e012 | ||
|
0258418a99 | ||
|
397c2a934f | ||
|
796986f38c | ||
|
c5011181bb | ||
|
dace099348 | ||
|
0876e39c4f | ||
|
0b516733db | ||
|
e15deead32 | ||
|
18df6138a7 | ||
|
8c125ed009 | ||
|
4720b703f4 | ||
|
cd8e15dcd1 | ||
|
a06d32ae19 | ||
|
7af3f014af | ||
|
8e80081f99 | ||
|
14c0417f3e | ||
|
0879dea444 | ||
|
a8c4aef6bd | ||
|
669a66f18a | ||
|
e8dae26176 | ||
|
e3a66473b2 | ||
|
7704e41336 | ||
|
a74bbe7381 | ||
|
729ec21629 | ||
|
b393715bee | ||
|
5ec4e60424 | ||
|
5cd24f3033 | ||
|
27a03c5cec | ||
|
5d34d21f40 | ||
|
ca8accbaa8 | ||
|
65defd3806 | ||
|
be7e7237e9 | ||
|
234cb2dfba | ||
|
b922ae0fb8 | ||
|
8649fb5118 | ||
|
a4bae6aba9 | ||
|
808bc1f4ed | ||
|
41d879e292 | ||
|
2e7b3cae2a | ||
|
a0ae62a733 | ||
|
06eb69b93a | ||
|
7025ff4280 | ||
|
2fa7410c0e | ||
|
3771d12992 | ||
|
f4ac67ae1c | ||
|
d48d6939c2 | ||
|
188cff7d65 | ||
|
75925762e8 | ||
|
f2ac7d730c | ||
|
c5c1c5458b | ||
|
1649597eae | ||
|
22f85deb2c | ||
|
1cb49bfe72 | ||
|
1aa4b657d6 | ||
|
52a01b2cf2 | ||
|
d803e7003f | ||
|
18efcd62ff | ||
|
9fda1cb421 | ||
|
bcc6db4a06 | ||
|
37cd707294 | ||
|
3698c1d2f1 | ||
|
00acb8ba41 | ||
|
a6ee1cf590 | ||
|
ebce97947d | ||
|
f4bbe8b2b3 | ||
|
e52e258f15 | ||
|
679fcd787f | ||
|
f3798159e7 | ||
|
c4de214cea | ||
|
6c5bbca0c1 | ||
|
447a6a15d9 | ||
|
5d7845c138 | ||
|
91d8869f36 | ||
|
1f8b2cbb8b | ||
|
d0cfca0820 | ||
|
f6049cd333 | ||
|
a25fd62349 | ||
|
39492436ec | ||
|
df962e5c53 | ||
|
2990126054 | ||
|
3edc7f1d18 | ||
|
2870afdeae | ||
|
d3c1ad29a0 | ||
|
23db7a213d | ||
|
3151081ff3 | ||
|
0758b39061 | ||
|
45d3c8341c | ||
|
8418131ae3 | ||
|
9ad9cfb898 | ||
|
a281d21fbf | ||
|
af5962450e | ||
|
3b3af1ab1e | ||
|
acd7a88bf2 | ||
|
176cab4fee | ||
|
28435dc736 | ||
|
a58d7594cb | ||
|
06181720fb | ||
|
b51c8cfd0f | ||
|
b6b9d835c5 | ||
|
ebea09c8b4 | ||
|
137f801ec7 | ||
|
3d58f8d471 | ||
|
b962fbb15c | ||
|
e8927dc75f | ||
|
fb37585bc1 | ||
|
4a871b9792 | ||
|
057bf1b92d | ||
|
750b520f41 | ||
|
c23f36c734 | ||
|
4eb80dd8d2 | ||
|
c543985cf4 | ||
|
863f704f47 | ||
|
54896763ab | ||
|
0272bd2846 | ||
|
70f3ed66f4 | ||
|
1dba3162c4 | ||
|
cb0d8cfbbd | ||
|
08064716b3 | ||
|
dca20731a2 | ||
|
530e209f66 | ||
|
566df7e826 | ||
|
56b3a17e56 | ||
|
d6cc5847fa | ||
|
1d672d39cf | ||
|
aefde13858 | ||
|
607779cccf | ||
|
da2af6ea2e | ||
|
ba337d1393 | ||
|
6ae240c0b6 | ||
|
05d6960ebc | ||
|
4866f2ac05 | ||
|
4456f96ae3 | ||
|
8008d7fe53 | ||
|
0a585092dc | ||
|
387ccae7d8 | ||
|
d951ea32a6 | ||
|
da30e2ef18 | ||
|
cb299375f6 | ||
|
4534d5239f | ||
|
af5a516443 | ||
|
368b3699d0 | ||
|
49d663f6c8 | ||
|
7e32ccbd8f | ||
|
f8f2d7b950 | ||
|
769f11109d | ||
|
85a2bf1c17 | ||
|
a2fa7a833c | ||
|
8179b26388 | ||
|
12bbef308b | ||
|
caff7296b1 | ||
|
779328a940 | ||
|
01e05a4495 | ||
|
af6b3fe599 | ||
|
74e8bebb75 | ||
|
8bfec30d48 | ||
|
2880eceeae | ||
|
34ada56f5d | ||
|
64521005ab | ||
|
16b18f7962 | ||
|
986af6ea9e | ||
|
691011c473 | ||
|
fd54719351 | ||
|
420b17ae65 | ||
|
ef5e7af68a | ||
|
05b68b8581 | ||
|
de6ddf4e2a | ||
|
a12a21a18e | ||
|
d8053dd6a6 | ||
|
7d38e2b01e | ||
|
53cd47e19f | ||
|
ce5c1c24cf | ||
|
2894e8de5e | ||
|
74c10df169 | ||
|
0da977f9c7 | ||
|
0b7c505b50 | ||
|
cb9c984aa7 | ||
|
516a8e4212 | ||
|
40aeaaee54 | ||
|
5fd56ec463 | ||
|
33329c80a9 | ||
|
fe73255452 | ||
|
9d497d5afd | ||
|
693103af9c | ||
|
7184c42376 | ||
|
349829fa96 | ||
|
3684228cd5 | ||
|
9e4925eff0 | ||
|
a96b4d7529 | ||
|
d5af87a8e1 | ||
|
683dc0b216 | ||
|
989a10e48b | ||
|
41d248f442 | ||
|
2dfea6bee3 | ||
|
0c07df7005 | ||
|
599981e2e6 | ||
|
b0059b290f | ||
|
9cbdd5ffd4 | ||
|
ddb3002bc1 | ||
|
63db70aacc | ||
|
6225a9fa4f | ||
|
3aaefc48ec | ||
|
c832a39d44 | ||
|
0a3c81826f | ||
|
b710e0fe86 | ||
|
9df2bd256e | ||
|
b238bf9512 | ||
|
07928109af | ||
|
2e4e80f2a9 | ||
|
4b62819da0 | ||
|
e3af4124de | ||
|
653c4d6472 | ||
|
b96a244984 | ||
|
2656a031e1 | ||
|
532671662d | ||
|
58f244a003 | ||
|
51c851ce3d | ||
|
c2a49080aa | ||
|
2bc05b6b17 | ||
|
41f708e438 | ||
|
7d40244a89 | ||
|
08ef5a2a66 | ||
|
16ee72da7c | ||
|
d409e5367b | ||
|
d5468e50f6 | ||
|
ef111ddba2 | ||
|
81f29a9a7a | ||
|
898e1f2641 | ||
|
23ad1aa243 | ||
|
4e9fafac75 | ||
|
b9180f8f5a | ||
|
cf6e9461af | ||
|
97c201297f | ||
|
4a59ea3b1e | ||
|
f9019870da | ||
|
60ca07c2d5 | ||
|
8baa8cf8ea | ||
|
a776a774e1 | ||
|
374a22b4b9 | ||
|
bc495bbc63 | ||
|
c887907d4a | ||
|
b4dcd592d8 | ||
|
21524c16fa | ||
|
bbff8abf58 | ||
|
99cc35384b | ||
|
8266dde556 | ||
|
2277fdc80d | ||
|
9cc731001b | ||
|
80855329e7 | ||
|
5851fb9de9 | ||
|
866e593138 | ||
|
7f26ad29a0 | ||
|
f766b6d882 | ||
|
ca2724d82e | ||
|
a8b026bd70 | ||
|
2292f7a27a | ||
|
3ea1d27aac | ||
|
df779f66a2 | ||
|
81f3cc5575 | ||
|
1fd166d417 | ||
|
5bfeb672f7 | ||
|
3c40c5ca5d | ||
|
f4771be70e | ||
|
887326e715 | ||
|
45da6c9c33 | ||
|
7ed8e1b59d | ||
|
4f1ce9189f | ||
|
775e410b00 | ||
|
c9331594bb | ||
|
cbc4db8649 | ||
|
b07069fb4d | ||
|
4fc59e3e7b | ||
|
5fddfca7c6 | ||
|
745b9e32ed | ||
|
9dc44c39e7 | ||
|
bde4c7149f | ||
|
39c6eb752a | ||
|
a9a7309001 | ||
|
72f4fae207 | ||
|
b0bf457538 | ||
|
98ab8e0d73 | ||
|
cd4dcbab36 | ||
|
3ebdb2fd8b | ||
|
69c11ea7d2 | ||
|
bd759bfca7 | ||
|
4a90950fe5 | ||
|
005468248b | ||
|
ecd7669e42 | ||
|
36a823df70 | ||
|
3643db6821 | ||
|
59f54cda10 | ||
|
95de24e4f6 | ||
|
1d9e2304be | ||
|
1f801828a5 | ||
|
94a7152afc | ||
|
0358d115e0 | ||
|
b4349e4226 | ||
|
92e2cef67f | ||
|
91264ea2f0 | ||
|
e66ee8b710 | ||
|
a6e2f23780 | ||
|
87e013534c | ||
|
1d9ec2373a | ||
|
46cf0f86b8 | ||
|
e574f57511 | ||
|
8fdd26da82 | ||
|
0c19bdd772 | ||
|
9d7a5c253a | ||
|
ac6a2a4c0f | ||
|
58e09dbd33 | ||
|
e770673f11 | ||
|
6d5670fde7 | ||
|
da0d6d0478 | ||
|
5683c06d9a | ||
|
65506136e2 | ||
|
2989e998ee | ||
|
3f438a8084 | ||
|
f2a8847902 | ||
|
94ac1261e4 | ||
|
8b7e19e92f | ||
|
81fa788bca | ||
|
cdbf2e361b | ||
|
378c7789ba | ||
|
15f3b0fea5 | ||
|
28ef15d669 | ||
|
145fc367f9 | ||
|
a21594bec7 | ||
|
7d975de193 | ||
|
5833c1dec8 | ||
|
4b9949de7b | ||
|
5997e5aae7 | ||
|
52d1c08896 | ||
|
7815d39807 | ||
|
7f6220d960 | ||
|
8a3c858d36 | ||
|
38b3ecb02e | ||
|
f2bc1571b4 | ||
|
4d7245bb67 | ||
|
ef5c4f027c | ||
|
c568640595 | ||
|
8338b45b2b | ||
|
0d0a841e8d | ||
|
31ff43ef81 | ||
|
a43a44bb88 | ||
|
cfbc8e52ba | ||
|
72506b3bab | ||
|
b002a21c36 | ||
|
7a339e2b5e | ||
|
e033a0da9a | ||
|
0d7a1d1ef9 | ||
|
80f19d7136 | ||
|
15d6432302 | ||
|
59a15c02d3 | ||
|
e4ed7528e3 | ||
|
8932b77d63 | ||
|
b3543452c2 | ||
|
16376c18aa | ||
|
a23eb3769a | ||
|
001e22ebee | ||
|
e8a726df03 | ||
|
8901cbffe0 | ||
|
b9d7c45e40 | ||
|
cf63bcb808 | ||
|
d0b8ecb6dd | ||
|
13774e62bd | ||
|
4ec17f1a1a | ||
|
f886ae0005 | ||
|
7db5b56dd7 | ||
|
3c7103d90d | ||
|
5ec37c05f7 | ||
|
780dab6977 | ||
|
caa26a2a47 | ||
|
d389bda2cc | ||
|
60f8a68ae0 | ||
|
99ca7f1cbe | ||
|
3e28d9ab5a | ||
|
4bee0ec294 | ||
|
b3a23039b1 | ||
|
e500fa013f | ||
|
b393c9d6e6 | ||
|
e4f0d6446b | ||
|
9b5c5b4f3d | ||
|
0d61ab82e4 | ||
|
67ddd59701 | ||
|
78ea362e27 | ||
|
d51102a168 | ||
|
f2023e80a8 | ||
|
384ae1dc1b | ||
|
c63f8a6ea0 | ||
|
64c725cee2 | ||
|
110bdd93c8 | ||
|
c962c88342 | ||
|
c80cc3306f | ||
|
e4d3eb64e6 | ||
|
0969118ce7 | ||
|
ba7c4c0530 | ||
|
d6cb447667 | ||
|
b9fac2b179 | ||
|
11e068d7a3 | ||
|
924ef84241 | ||
|
9bffa921ae | ||
|
c50ba69689 | ||
|
b4cde3fc21 | ||
|
6f1dc624e6 | ||
|
7378cc297c | ||
|
6f4cd8d397 | ||
|
5e08950ed2 | ||
|
bce3b75c53 | ||
|
3fdc7996db | ||
|
e9bb008f15 | ||
|
d352aa0990 | ||
|
cfb450c059 | ||
|
b416685d6f | ||
|
64c2fe180b | ||
|
309327187a | ||
|
1dea46e1ab | ||
|
4abe403544 | ||
|
21d437fbf5 | ||
|
84c7f927c2 | ||
|
644c81b9fb | ||
|
3452892f76 | ||
|
2f7fdf2663 | ||
|
d040ab93ea | ||
|
c8610d9a86 | ||
|
93d41b2c0e | ||
|
c03ae5fafd | ||
|
b3988d6e1f | ||
|
ad2c7b3959 | ||
|
5e1e897d10 | ||
|
37f209079e | ||
|
0f66c63f72 | ||
|
abde900cd7 | ||
|
fd1c4d7877 | ||
|
70ad1aa409 | ||
|
c83dd5d60e | ||
|
18c99682a8 | ||
|
200815892f | ||
|
7eb6ca6337 | ||
|
5a0f90bc82 | ||
|
2a86cdb203 | ||
|
56e4a201ec | ||
|
c739e68021 | ||
|
fe8a519434 | ||
|
4445f6f869 | ||
|
4ee89877d5 | ||
|
ea95ea8295 | ||
|
fe5aaf4932 | ||
|
5afb5dc782 | ||
|
f4ce52d206 | ||
|
1108515738 | ||
|
8ee7b772a9 | ||
|
650daf7542 | ||
|
1946818292 | ||
|
cbe98c0fd2 | ||
|
ad221b0990 | ||
|
a2653d409f | ||
|
461b5ef28a | ||
|
7f1f7b6232 | ||
|
d741f1b654 | ||
|
f0606bcdb7 | ||
|
03bc9ebb1f | ||
|
1f79c01dc4 | ||
|
dcf803de73 | ||
|
46f9768599 | ||
|
2e098421f1 | ||
|
c21dd874d1 | ||
|
48c8755d06 | ||
|
f9750dddee | ||
|
e8a39c894f | ||
|
97cdbc45e8 | ||
|
d044369e3b | ||
|
84d3c90b93 | ||
|
2e973c8b3d | ||
|
de642b6263 | ||
|
5355bd3a8f | ||
|
35a843f8b6 | ||
|
17caf77784 | ||
|
0c94ce0039 | ||
|
af50d5ef1f | ||
|
9ce66f2c9a | ||
|
ad624432d8 | ||
|
1e1ca23101 | ||
|
e5bbe57f01 | ||
|
68f91822ed | ||
|
7aed498540 | ||
|
d5a3bb5234 | ||
|
9ebb9ff318 | ||
|
fb6df0512f | ||
|
7f4c1bb77c | ||
|
abc0d43995 | ||
|
3826ac1433 | ||
|
d650fa2456 | ||
|
80163dc6c1 | ||
|
a8b5bb894e | ||
|
3620b31ef2 | ||
|
7709fc70eb | ||
|
bce33698be | ||
|
04d0dd5987 | ||
|
051048ebd7 | ||
|
7fe3912f12 | ||
|
7eb41ccf0f | ||
|
79d55fd802 | ||
|
6df52df5b4 | ||
|
bdca50e6a7 | ||
|
851b49e147 | ||
|
e64847bd09 | ||
|
8e861728a0 | ||
|
8cfd71a9be | ||
|
5d08bd1709 | ||
|
646a140ed4 | ||
|
5eef243ab6 | ||
|
11ee6834f6 | ||
|
c07e81a049 | ||
|
05b2aabe0e | ||
|
55680db160 | ||
|
f4ffddc942 | ||
|
5ab033fba5 | ||
|
1dfc8282df | ||
|
f8aec1bdf1 | ||
|
51a83da578 | ||
|
38ccd51399 | ||
|
8696ad8739 | ||
|
c336470320 | ||
|
da51d8dfd3 | ||
|
22fdd3bf0f | ||
|
cae749fc9b | ||
|
58e68725ae | ||
|
a59f74e8a2 | ||
|
f258af4364 | ||
|
ccd675a286 | ||
|
5372d58adc | ||
|
751520f0cf | ||
|
357a63d914 | ||
|
a938045135 | ||
|
32177aa77a | ||
|
ce1df17262 | ||
|
9f8413308a | ||
|
f25f0e0e40 | ||
|
a2890f2778 | ||
|
de4644b44a | ||
|
03db102375 | ||
|
3d967dd716 | ||
|
b53d207f44 | ||
|
fde12195ee | ||
|
4ca6991828 | ||
|
813dcbcf63 | ||
|
7663f58379 | ||
|
8e3f968ba4 | ||
|
f695e536dd | ||
|
f257e4ea8c | ||
|
0ed3e4cf76 | ||
|
6d355fd602 | ||
|
dd0b7b2d13 | ||
|
42e5d98a48 | ||
|
c060a10c10 | ||
|
79a3a633c7 | ||
|
52dfd478d6 | ||
|
48eca46680 | ||
|
f93277d271 | ||
|
dda8af0092 |
19
.clang-format
Normal file
19
.clang-format
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: Google
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
Standard: c++17
|
||||||
|
IndentWidth: 4
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
ColumnLimit: 100
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
BinPackParameters: false
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
PackConstructorInitializers: Never
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
IndentPPDirectives: BeforeHash
|
||||||
|
SortIncludes: Never
|
||||||
|
...
|
||||||
|
|
53
.clang-tidy
Normal file
53
.clang-tidy
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
Checks: 'cppcoreguidelines-*,
|
||||||
|
performance-*,
|
||||||
|
modernize-*,
|
||||||
|
google-*,
|
||||||
|
misc-*
|
||||||
|
cert-*,
|
||||||
|
readability-*,
|
||||||
|
clang-analyzer-*,
|
||||||
|
-performance-unnecessary-value-param,
|
||||||
|
-modernize-use-trailing-return-type,
|
||||||
|
-google-runtime-references,
|
||||||
|
-misc-non-private-member-variables-in-classes,
|
||||||
|
-readability-braces-around-statements,
|
||||||
|
-google-readability-braces-around-statements,
|
||||||
|
-cppcoreguidelines-avoid-magic-numbers,
|
||||||
|
-readability-magic-numbers,
|
||||||
|
-readability-magic-numbers,
|
||||||
|
-cppcoreguidelines-pro-type-vararg,
|
||||||
|
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||||
|
-cppcoreguidelines-avoid-c-arrays,
|
||||||
|
-modernize-avoid-c-arrays,
|
||||||
|
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||||
|
-readability-named-parameter,
|
||||||
|
-cert-env33-c
|
||||||
|
'
|
||||||
|
|
||||||
|
|
||||||
|
WarningsAsErrors: ''
|
||||||
|
HeaderFilterRegex: '*spdlog/[^f].*'
|
||||||
|
FormatStyle: none
|
||||||
|
|
||||||
|
CheckOptions:
|
||||||
|
- key: google-readability-braces-around-statements.ShortStatementLines
|
||||||
|
value: '1'
|
||||||
|
- key: google-readability-function-size.StatementThreshold
|
||||||
|
value: '800'
|
||||||
|
- key: google-readability-namespace-comments.ShortNamespaceLines
|
||||||
|
value: '10'
|
||||||
|
- key: google-readability-namespace-comments.SpacesBeforeComments
|
||||||
|
value: '2'
|
||||||
|
- key: modernize-loop-convert.MaxCopySize
|
||||||
|
value: '16'
|
||||||
|
- key: modernize-loop-convert.MinConfidence
|
||||||
|
value: reasonable
|
||||||
|
- key: modernize-loop-convert.NamingStyle
|
||||||
|
value: CamelCase
|
||||||
|
- key: modernize-pass-by-value.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: modernize-replace-auto-ptr.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: modernize-use-nullptr.NullMacros
|
||||||
|
value: 'NULL'
|
||||||
|
|
6
.git-blame-ignore-revs
Normal file
6
.git-blame-ignore-revs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# clang-format
|
||||||
|
1a0bfc7a89f2d58e22605a4dc7e18a9a555b65aa
|
||||||
|
95c226e9c92928e20ccdac0d060e7241859e282b
|
||||||
|
9d52261185b5f2c454c381d626ec5c84d7b195f4
|
||||||
|
4b2a8219d5d1b40062d030441adde7d1fb0d4f84
|
||||||
|
0a53eafe18d983c7c8ba4cadd02d0cc7f7308f28
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
* text=false
|
87
.github/workflows/linux.yml
vendored
Normal file
87
.github/workflows/linux.yml
vendored
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
name: linux
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# Linux build matrix
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
config:
|
||||||
|
- { compiler: gcc, version: 7, build_type: Release, cppstd: 11 }
|
||||||
|
- { compiler: gcc, version: 9, build_type: Release, cppstd: 17 }
|
||||||
|
- { compiler: gcc, version: 11, build_type: Debug, cppstd: 20 }
|
||||||
|
- { compiler: gcc, version: 12, build_type: Release, cppstd: 20 }
|
||||||
|
- { compiler: gcc, version: 12, build_type: Debug, cppstd: 20, asan: ON }
|
||||||
|
- { compiler: clang, version: 12, build_type: Debug, cppstd: 17 }
|
||||||
|
- { compiler: clang, version: 15, build_type: Release, cppstd: 20, tsan: ON }
|
||||||
|
container:
|
||||||
|
image: ${{ matrix.config.compiler == 'clang' && 'teeks99/clang-ubuntu' || matrix.config.compiler }}:${{ matrix.config.version }}
|
||||||
|
name: "${{ matrix.config.compiler}} ${{ matrix.config.version }} (C++${{ matrix.config.cppstd }} ${{ matrix.config.build_type }} ${{ matrix.config.asan == 'ON' && 'ASAN' || '' }}${{ matrix.config.tsan == 'ON' && 'TSAN' || '' }})"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Setup
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y curl git pkg-config libsystemd-dev
|
||||||
|
CMAKE_VERSION="3.24.2"
|
||||||
|
curl -sSL https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh -o install-cmake.sh
|
||||||
|
chmod +x install-cmake.sh
|
||||||
|
./install-cmake.sh --prefix=/usr/local --skip-license
|
||||||
|
- name: Setup Compiler
|
||||||
|
if: matrix.config.compiler == 'clang'
|
||||||
|
run: |
|
||||||
|
scripts/ci_setup_clang.sh "${{ matrix.config.version }}"
|
||||||
|
echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV
|
||||||
|
echo "CC=clang-${{ matrix.config.version }}" >> $GITHUB_ENV
|
||||||
|
echo "CXX=clang++-${{ matrix.config.version }}" >> $GITHUB_ENV
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
mkdir -p build && cd build
|
||||||
|
cmake .. \
|
||||||
|
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
|
||||||
|
-DCMAKE_CXX_STANDARD=${{ matrix.config.cppstd }} \
|
||||||
|
-DSPDLOG_BUILD_EXAMPLE=${{ matrix.config.examples || 'ON' }} \
|
||||||
|
-DSPDLOG_BUILD_EXAMPLE_HO=${{ matrix.config.examples || 'ON' }} \
|
||||||
|
-DSPDLOG_BUILD_WARNINGS=ON \
|
||||||
|
-DSPDLOG_BUILD_BENCH=OFF \
|
||||||
|
-DSPDLOG_BUILD_TESTS=ON \
|
||||||
|
-DSPDLOG_BUILD_TESTS_HO=OFF \
|
||||||
|
-DSPDLOG_SANITIZE_ADDRESS=${{ matrix.config.asan || 'OFF' }} \
|
||||||
|
-DSPDLOG_SANITIZE_THREAD=${{ matrix.config.tsan || 'OFF' }}
|
||||||
|
make -j 4
|
||||||
|
ctest -j 4 --output-on-failure
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# OS X build matrix
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
build_osx:
|
||||||
|
runs-on: macOS-latest
|
||||||
|
name: "OS X Clang (C++11, Release)"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
mkdir -p build && cd build
|
||||||
|
cmake .. \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_CXX_STANDARD=11 \
|
||||||
|
-DSPDLOG_BUILD_EXAMPLE=ON \
|
||||||
|
-DSPDLOG_BUILD_EXAMPLE_HO=ON \
|
||||||
|
-DSPDLOG_BUILD_WARNINGS=ON \
|
||||||
|
-DSPDLOG_BUILD_BENCH=OFF \
|
||||||
|
-DSPDLOG_BUILD_TESTS=ON \
|
||||||
|
-DSPDLOG_BUILD_TESTS_HO=OFF \
|
||||||
|
-DSPDLOG_SANITIZE_ADDRESS=OFF
|
||||||
|
make -j 4
|
||||||
|
ctest -j 4 --output-on-failure
|
38
.github/workflows/macos.yml
vendored
Normal file
38
.github/workflows/macos.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
name: macos
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: macOS-latest
|
||||||
|
name: "macOS Clang (C++11, Release)"
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
config:
|
||||||
|
- USE_STD_FORMAT: 'ON'
|
||||||
|
BUILD_EXAMPLE: 'OFF'
|
||||||
|
- USE_STD_FORMAT: 'OFF'
|
||||||
|
BUILD_EXAMPLE: 'ON'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
mkdir -p build && cd build
|
||||||
|
cmake .. \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_CXX_STANDARD=11 \
|
||||||
|
-DSPDLOG_BUILD_EXAMPLE=${{ matrix.config.BUILD_EXAMPLE }} \
|
||||||
|
-DSPDLOG_BUILD_EXAMPLE_HO=${{ matrix.config.BUILD_EXAMPLE }} \
|
||||||
|
-DSPDLOG_BUILD_WARNINGS=ON \
|
||||||
|
-DSPDLOG_BUILD_BENCH=OFF \
|
||||||
|
-DSPDLOG_BUILD_TESTS=ON \
|
||||||
|
-DSPDLOG_BUILD_TESTS_HO=OFF \
|
||||||
|
-DSPDLOG_USE_STD_FORMAT=${{ matrix.config.USE_STD_FORMAT }} \
|
||||||
|
-DSPDLOG_SANITIZE_ADDRESS=OFF
|
||||||
|
make -j 4
|
||||||
|
ctest -j 4 --output-on-failure
|
148
.github/workflows/windows.yml
vendored
Normal file
148
.github/workflows/windows.yml
vendored
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
name: windows
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: windows-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
config:
|
||||||
|
- GENERATOR: "Visual Studio 17 2022"
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
BUILD_SHARED: 'ON'
|
||||||
|
FATAL_ERRORS: 'ON'
|
||||||
|
WCHAR: 'OFF'
|
||||||
|
WCHAR_FILES: 'OFF'
|
||||||
|
BUILD_EXAMPLE: 'OFF'
|
||||||
|
USE_STD_FORMAT: 'ON'
|
||||||
|
CXX_STANDARD: 20
|
||||||
|
- GENERATOR: "Visual Studio 17 2022"
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
BUILD_SHARED: 'ON'
|
||||||
|
FATAL_ERRORS: 'ON'
|
||||||
|
WCHAR: 'ON'
|
||||||
|
WCHAR_FILES: 'ON'
|
||||||
|
BUILD_EXAMPLE: 'OFF'
|
||||||
|
USE_STD_FORMAT: 'ON'
|
||||||
|
CXX_STANDARD: 20
|
||||||
|
- GENERATOR: "Visual Studio 17 2022"
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
BUILD_SHARED: 'ON'
|
||||||
|
FATAL_ERRORS: 'ON'
|
||||||
|
WCHAR: 'OFF'
|
||||||
|
WCHAR_FILES: 'OFF'
|
||||||
|
BUILD_EXAMPLE: 'ON'
|
||||||
|
USE_STD_FORMAT: 'OFF'
|
||||||
|
CXX_STANDARD: 17
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: CMake ${{ matrix.config.GENERATOR }} CXX=${{matrix.config.CXX_STANDARD}} WCHAR=${{matrix.config.WCHAR_FILES}} STD_FORMAT=${{matrix.config.USE_STD_FORMAT}}
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake -G "${{ matrix.config.GENERATOR }}" -A x64 `
|
||||||
|
-D CMAKE_BUILD_TYPE=${{ matrix.config.BUILD_TYPE }} `
|
||||||
|
-D BUILD_SHARED_LIBS=${{ matrix.config.BUILD_SHARED }} `
|
||||||
|
-D SPDLOG_WCHAR_SUPPORT=${{ matrix.config.WCHAR }} `
|
||||||
|
-D SPDLOG_WCHAR_FILENAMES=${{ matrix.config.WCHAR_FILES }} `
|
||||||
|
-D SPDLOG_BUILD_EXAMPLE=${{ matrix.config.BUILD_EXAMPLE }} `
|
||||||
|
-D SPDLOG_BUILD_EXAMPLE_HO=${{ matrix.config.BUILD_EXAMPLE }} `
|
||||||
|
-D SPDLOG_BUILD_TESTS=ON `
|
||||||
|
-D SPDLOG_BUILD_TESTS_HO=OFF `
|
||||||
|
-D SPDLOG_BUILD_WARNINGS=${{ matrix.config.FATAL_ERRORS }} `
|
||||||
|
-D SPDLOG_USE_STD_FORMAT=${{ matrix.config.USE_STD_FORMAT }} `
|
||||||
|
-D CMAKE_CXX_STANDARD=${{ matrix.config.CXX_STANDARD }} ..
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
cd build
|
||||||
|
cmake --build . --parallel --config ${{ matrix.config.BUILD_TYPE }}
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
PATH: ${{ env.PATH }};${{ github.workspace }}\build\_deps\catch2-build\src\${{ matrix.config.BUILD_TYPE }};${{ github.workspace }}\build\${{ matrix.config.BUILD_TYPE }}
|
||||||
|
run: |
|
||||||
|
build\tests\${{ matrix.config.BUILD_TYPE }}\spdlog-utests.exe
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# MSVC 2019 build matrix
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
build_2019:
|
||||||
|
runs-on: windows-2019
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
config:
|
||||||
|
- GENERATOR: "Visual Studio 16 2019"
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
BUILD_SHARED: 'ON'
|
||||||
|
FATAL_ERRORS: 'ON'
|
||||||
|
WCHAR: 'OFF'
|
||||||
|
WCHAR_FILES: 'OFF'
|
||||||
|
BUILD_EXAMPLE: 'ON'
|
||||||
|
USE_STD_FORMAT: 'OFF'
|
||||||
|
CXX_STANDARD: 17
|
||||||
|
- GENERATOR: "Visual Studio 16 2019"
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
BUILD_SHARED: 'ON'
|
||||||
|
FATAL_ERRORS: 'ON'
|
||||||
|
WCHAR: 'OFF'
|
||||||
|
WCHAR_FILES: 'OFF'
|
||||||
|
BUILD_EXAMPLE: 'ON'
|
||||||
|
USE_STD_FORMAT: 'OFF'
|
||||||
|
CXX_STANDARD: 14
|
||||||
|
- GENERATOR: "Visual Studio 16 2019"
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
BUILD_SHARED: 'ON'
|
||||||
|
FATAL_ERRORS: 'ON'
|
||||||
|
WCHAR: 'OFF'
|
||||||
|
WCHAR_FILES: 'OFF'
|
||||||
|
BUILD_EXAMPLE: 'ON'
|
||||||
|
USE_STD_FORMAT: 'OFF'
|
||||||
|
CXX_STANDARD: 11
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: CMake ${{ matrix.config.GENERATOR }} CXX=${{matrix.config.CXX_STANDARD}} WCHAR=${{matrix.config.WCHAR_FILES}} STD_FORMAT=${{matrix.config.USE_STD_FORMAT}}
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake -G "${{ matrix.config.GENERATOR }}" -A x64 `
|
||||||
|
-D CMAKE_BUILD_TYPE=${{ matrix.config.BUILD_TYPE }} `
|
||||||
|
-D BUILD_SHARED_LIBS=${{ matrix.config.BUILD_SHARED }} `
|
||||||
|
-D SPDLOG_WCHAR_SUPPORT=${{ matrix.config.WCHAR }} `
|
||||||
|
-D SPDLOG_WCHAR_FILENAMES=${{ matrix.config.WCHAR_FILES }} `
|
||||||
|
-D SPDLOG_BUILD_EXAMPLE=${{ matrix.config.BUILD_EXAMPLE }} `
|
||||||
|
-D SPDLOG_BUILD_EXAMPLE_HO=${{ matrix.config.BUILD_EXAMPLE }} `
|
||||||
|
-D SPDLOG_BUILD_TESTS=ON `
|
||||||
|
-D SPDLOG_BUILD_TESTS_HO=OFF `
|
||||||
|
-D SPDLOG_BUILD_WARNINGS=${{ matrix.config.FATAL_ERRORS }} `
|
||||||
|
-D SPDLOG_USE_STD_FORMAT=${{ matrix.config.USE_STD_FORMAT }} `
|
||||||
|
-D CMAKE_CXX_STANDARD=${{ matrix.config.CXX_STANDARD }} ..
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
cd build
|
||||||
|
cmake --build . --parallel --config ${{ matrix.config.BUILD_TYPE }}
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
PATH: ${{ env.PATH }};${{ github.workspace }}\build\_deps\catch2-build\src\${{ matrix.config.BUILD_TYPE }};${{ github.workspace }}\build\${{ matrix.config.BUILD_TYPE }}
|
||||||
|
run: |
|
||||||
|
build\tests\${{ matrix.config.BUILD_TYPE }}\spdlog-utests.exe
|
35
.gitignore
vendored
35
.gitignore
vendored
@ -1,4 +1,7 @@
|
|||||||
# Auto generated files
|
# Auto generated files
|
||||||
|
[Dd]ebug/
|
||||||
|
[Rr]elease/
|
||||||
|
build/*
|
||||||
*.slo
|
*.slo
|
||||||
*.lo
|
*.lo
|
||||||
*.o
|
*.o
|
||||||
@ -33,6 +36,9 @@
|
|||||||
# Codelite
|
# Codelite
|
||||||
.codelite
|
.codelite
|
||||||
|
|
||||||
|
# KDevelop
|
||||||
|
*.kdev4
|
||||||
|
|
||||||
# .orig files
|
# .orig files
|
||||||
*.orig
|
*.orig
|
||||||
|
|
||||||
@ -45,11 +51,13 @@ example/*
|
|||||||
!example/example.sln
|
!example/example.sln
|
||||||
!example/example.vcxproj
|
!example/example.vcxproj
|
||||||
!example/CMakeLists.txt
|
!example/CMakeLists.txt
|
||||||
|
!example/meson.build
|
||||||
!example/multisink.cpp
|
!example/multisink.cpp
|
||||||
!example/jni
|
!example/jni
|
||||||
|
|
||||||
# generated files
|
# generated files
|
||||||
generated
|
generated
|
||||||
|
version.rc
|
||||||
|
|
||||||
# Cmake
|
# Cmake
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
@ -61,7 +69,30 @@ install_manifest.txt
|
|||||||
/tests/tests.VC.VC.opendb
|
/tests/tests.VC.VC.opendb
|
||||||
/tests/tests.VC.db
|
/tests/tests.VC.db
|
||||||
/tests/tests
|
/tests/tests
|
||||||
/tests/logs/file_helper_test.txt
|
/tests/logs/*
|
||||||
|
spdlogConfig.cmake
|
||||||
|
spdlogConfigVersion.cmake
|
||||||
|
compile_commands.json
|
||||||
|
|
||||||
# idea
|
# idea
|
||||||
.idea/
|
.idea/
|
||||||
|
.cache/
|
||||||
|
.vscode/
|
||||||
|
cmake-build-*/
|
||||||
|
*.db
|
||||||
|
*.ipch
|
||||||
|
*.filters
|
||||||
|
*.db-wal
|
||||||
|
*.opendb
|
||||||
|
*.db-shm
|
||||||
|
*.vcxproj
|
||||||
|
*.tcl
|
||||||
|
*.user
|
||||||
|
*.sln
|
||||||
|
|
||||||
|
# macos
|
||||||
|
*.DS_store
|
||||||
|
*.xcodeproj/
|
||||||
|
/.vs
|
||||||
|
/out/build
|
||||||
|
/CMakeSettings.json
|
||||||
|
91
.travis.yml
91
.travis.yml
@ -1,91 +0,0 @@
|
|||||||
# Adapted from various sources, including:
|
|
||||||
# - Louis Dionne's Hana: https://github.com/ldionne/hana
|
|
||||||
# - Paul Fultz II's FIT: https://github.com/pfultz2/Fit
|
|
||||||
# - Eric Niebler's range-v3: https://github.com/ericniebler/range-v3
|
|
||||||
language: cpp
|
|
||||||
|
|
||||||
# Test matrix:
|
|
||||||
# - Build matrix per compiler: C++11/C++14 + Debug/Release
|
|
||||||
# - Optionally: AddressSanitizer (ASAN)
|
|
||||||
# - Valgrind: all release builds are also tested with valgrind
|
|
||||||
# - clang 3.4, 3.5, 3.6, trunk
|
|
||||||
# - Note: 3.4 and trunk are tested with/without ASAN,
|
|
||||||
# the rest is only tested with ASAN=On.
|
|
||||||
# - gcc 4.9, 5.0
|
|
||||||
#
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
|
|
||||||
# Test gcc-4.8: C++11, Build=Debug/Release, ASAN=Off
|
|
||||||
- env: GCC_VERSION=4.8 BUILD_TYPE=Debug CPP=11 ASAN=Off LIBCXX=Off
|
|
||||||
os: linux
|
|
||||||
addons: &gcc48
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- g++-4.8
|
|
||||||
- valgrind
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
|
|
||||||
- env: GCC_VERSION=4.8 BUILD_TYPE=Release CPP=11 ASAN=Off LIBCXX=Off
|
|
||||||
os: linux
|
|
||||||
addons: *gcc48
|
|
||||||
|
|
||||||
# Test gcc-4.9: C++11, Build=Debug/Release, ASAN=Off
|
|
||||||
- env: GCC_VERSION=4.9 BUILD_TYPE=Debug CPP=11 ASAN=Off LIBCXX=Off
|
|
||||||
os: linux
|
|
||||||
addons: &gcc49
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- g++-4.9
|
|
||||||
- valgrind
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
|
|
||||||
- env: GCC_VERSION=4.9 BUILD_TYPE=Release CPP=11 ASAN=Off LIBCXX=Off
|
|
||||||
os: linux
|
|
||||||
addons: *gcc49
|
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
before_install:
|
|
||||||
- export CHECKOUT_PATH=`pwd`;
|
|
||||||
- if [ -n "$GCC_VERSION" ]; then export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"; fi
|
|
||||||
- if [ -n "$CLANG_VERSION" ]; then export CXX="clang++-${CLANG_VERSION}" CC="clang-${CLANG_VERSION}"; fi
|
|
||||||
- if [ "$CLANG_VERSION" == "3.4" ]; then export CXX="/usr/local/clang-3.4/bin/clang++" CC="/usr/local/clang-3.4/bin/clang"; fi
|
|
||||||
- which $CXX
|
|
||||||
- which $CC
|
|
||||||
- which valgrind
|
|
||||||
- if [ -n "$CLANG_VERSION" ]; then sudo CXX=$CXX CC=$CC ./tests/install_libcxx.sh; fi
|
|
||||||
|
|
||||||
install:
|
|
||||||
- cd $CHECKOUT_PATH
|
|
||||||
|
|
||||||
# Workaround for valgrind bug: https://bugs.kde.org/show_bug.cgi?id=326469.
|
|
||||||
# It is fixed in valgrind 3.10 so this won't be necessary if someone
|
|
||||||
# replaces the current valgrind (3.7) with valgrind-3.10
|
|
||||||
- sed -i 's/march=native/msse4.2/' example/Makefile
|
|
||||||
|
|
||||||
- if [ ! -d build ]; then mkdir build; fi
|
|
||||||
- export CXX_FLAGS="-I${CHECKOUT_PATH}/include"
|
|
||||||
- export CXX_LINKER_FLAGS=""
|
|
||||||
- if [ -z "$BUILD_TYPE" ]; then export BUILD_TYPE=Release; fi
|
|
||||||
- if [ "$ASAN" == "On"]; then export CXX_FLAGS="${CXX_FLAGS} -fsanitize=address,undefined,integer -fno-omit-frame-pointer -fno-sanitize=unsigned-integer-overflow"; fi
|
|
||||||
- if [ -n "$CLANG_VERSION" ]; then CXX_FLAGS="${CXX_FLAGS} -D__extern_always_inline=inline"; fi
|
|
||||||
- if [ "$LIBCXX" == "On" ]; then CXX_FLAGS="${CXX_FLAGS} -stdlib=libc++ -I/usr/include/c++/v1/"; fi
|
|
||||||
- if [ "$LIBCXX" == "On" ]; then CXX_LINKER_FLAGS="${CXX_FLAGS} -L/usr/lib/ -lc++"; fi
|
|
||||||
- CXX_FLAGS="${CXX_FLAGS} -std=c++${CPP}"
|
|
||||||
|
|
||||||
# Build examples
|
|
||||||
- cd example
|
|
||||||
- if [ "$BUILD_TYPE" == "Release" ]; then make rebuild CXXFLAGS="${CXX_FLAGS} ${CXX_LINKER_FLAGS}" VERBOSE=1; export BIN=example; fi
|
|
||||||
- if [ "$BUILD_TYPE" == "Debug" ]; then make rebuild debug CXXFLAGS="${CXX_FLAGS} ${CXX_LINKER_FLAGS}" VERBOSE=1; export BIN=example-debug; fi
|
|
||||||
|
|
||||||
|
|
||||||
script:
|
|
||||||
- ./"${BIN}"
|
|
||||||
- valgrind --trace-children=yes --leak-check=full ./"${BIN}"
|
|
||||||
- cd $CHECKOUT_PATH/tests; make rebuild; ./tests
|
|
||||||
- cd $CHECKOUT_PATH/tests; STYLE=printf make rebuild; ./tests
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
email: false
|
|
476
CMakeLists.txt
476
CMakeLists.txt
@ -1,116 +1,404 @@
|
|||||||
#
|
# Copyright(c) 2019 spdlog authors Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
# Copyright(c) 2015 Ruslan Baratov.
|
|
||||||
# Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
cmake_minimum_required(VERSION 3.10...3.21)
|
||||||
#
|
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
# Start spdlog project
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
include(cmake/utils.cmake)
|
||||||
|
include(cmake/ide.cmake)
|
||||||
|
|
||||||
|
spdlog_extract_version()
|
||||||
|
|
||||||
|
project(spdlog VERSION ${SPDLOG_VERSION} LANGUAGES CXX)
|
||||||
|
message(STATUS "Build spdlog: ${SPDLOG_VERSION}")
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.1)
|
|
||||||
project(spdlog VERSION 0.14.0)
|
|
||||||
include(CTest)
|
|
||||||
include(CMakeDependentOption)
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
# compiler config
|
# Set default build to release
|
||||||
#---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
# ---------------------------------------------------------------------------------------
|
||||||
set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}")
|
# Compiler config
|
||||||
endif()
|
# ---------------------------------------------------------------------------------------
|
||||||
|
if (SPDLOG_USE_STD_FORMAT)
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
elseif (NOT CMAKE_CXX_STANDARD)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
endif ()
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
# spdlog target
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
add_library(spdlog INTERFACE)
|
|
||||||
|
|
||||||
option(SPDLOG_BUILD_EXAMPLES "Build examples" OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
cmake_dependent_option(SPDLOG_BUILD_TESTING
|
|
||||||
"Build spdlog tests" ON
|
if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS" OR CMAKE_SYSTEM_NAME MATCHES "MINGW")
|
||||||
"BUILD_TESTING" OFF
|
set(CMAKE_CXX_EXTENSIONS ON)
|
||||||
)
|
endif ()
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
# Set SPDLOG_MASTER_PROJECT to ON if we are building spdlog
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
# Check if spdlog is being used directly or via add_subdirectory, but allow overriding
|
||||||
|
if (NOT DEFINED SPDLOG_MASTER_PROJECT)
|
||||||
|
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||||
|
set(SPDLOG_MASTER_PROJECT ON)
|
||||||
|
else ()
|
||||||
|
set(SPDLOG_MASTER_PROJECT OFF)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
option(SPDLOG_BUILD_ALL "Build all artifacts" OFF)
|
||||||
|
|
||||||
|
# build shared option
|
||||||
|
option(SPDLOG_BUILD_SHARED "Build shared library" OFF)
|
||||||
|
|
||||||
|
# precompiled headers option
|
||||||
|
option(SPDLOG_ENABLE_PCH "Build static or shared library using precompiled header to speed up compilation time" OFF)
|
||||||
|
|
||||||
|
# build position independent code
|
||||||
|
option(SPDLOG_BUILD_PIC "Build position independent code (-fPIC)" OFF)
|
||||||
|
|
||||||
|
# example options
|
||||||
|
option(SPDLOG_BUILD_EXAMPLE "Build example" ${SPDLOG_MASTER_PROJECT})
|
||||||
|
option(SPDLOG_BUILD_EXAMPLE_HO "Build header only example" OFF)
|
||||||
|
|
||||||
|
# testing options
|
||||||
|
option(SPDLOG_BUILD_TESTS "Build tests" OFF)
|
||||||
|
option(SPDLOG_BUILD_TESTS_HO "Build tests using the header only version" OFF)
|
||||||
|
|
||||||
|
# bench options
|
||||||
|
option(SPDLOG_BUILD_BENCH "Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)" OFF)
|
||||||
|
|
||||||
|
# sanitizer options
|
||||||
|
option(SPDLOG_SANITIZE_ADDRESS "Enable address sanitizer in tests" OFF)
|
||||||
|
option(SPDLOG_SANITIZE_THREAD "Enable thread sanitizer in tests" OFF)
|
||||||
|
if (SPDLOG_SANITIZE_ADDRESS AND SPDLOG_SANITIZE_THREAD)
|
||||||
|
message(FATAL_ERROR "SPDLOG_SANITIZE_ADDRESS and SPDLOG_SANITIZE_THREAD are mutually exclusive")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# warning options
|
||||||
|
option(SPDLOG_BUILD_WARNINGS "Enable compiler warnings" OFF)
|
||||||
|
|
||||||
|
# install options
|
||||||
|
option(SPDLOG_SYSTEM_INCLUDES "Include as system headers (skip for clang-tidy)." OFF)
|
||||||
|
option(SPDLOG_INSTALL "Generate the install target" ${SPDLOG_MASTER_PROJECT})
|
||||||
|
option(SPDLOG_USE_STD_FORMAT "Use std::format instead of fmt library." OFF)
|
||||||
|
option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF)
|
||||||
|
option(SPDLOG_FMT_EXTERNAL_HO "Use external fmt header-only library instead of bundled" OFF)
|
||||||
|
option(SPDLOG_NO_EXCEPTIONS "Compile with -fno-exceptions. Call abort() on any spdlog exceptions" OFF)
|
||||||
|
|
||||||
|
if (SPDLOG_FMT_EXTERNAL AND SPDLOG_FMT_EXTERNAL_HO)
|
||||||
|
message(FATAL_ERROR "SPDLOG_FMT_EXTERNAL and SPDLOG_FMT_EXTERNAL_HO are mutually exclusive")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (SPDLOG_USE_STD_FORMAT AND SPDLOG_FMT_EXTERNAL_HO)
|
||||||
|
message(FATAL_ERROR "SPDLOG_USE_STD_FORMAT and SPDLOG_FMT_EXTERNAL_HO are mutually exclusive")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (SPDLOG_USE_STD_FORMAT AND SPDLOG_FMT_EXTERNAL)
|
||||||
|
message(FATAL_ERROR "SPDLOG_USE_STD_FORMAT and SPDLOG_FMT_EXTERNAL are mutually exclusive")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# misc tweakme options
|
||||||
|
if (WIN32)
|
||||||
|
option(SPDLOG_WCHAR_SUPPORT "Support wchar api" OFF)
|
||||||
|
option(SPDLOG_WCHAR_FILENAMES "Support wchar filenames" OFF)
|
||||||
|
option(SPDLOG_WCHAR_CONSOLE "Support wchar output to console" OFF)
|
||||||
|
else ()
|
||||||
|
set(SPDLOG_WCHAR_SUPPORT OFF CACHE BOOL "non supported option" FORCE)
|
||||||
|
set(SPDLOG_WCHAR_FILENAMES OFF CACHE BOOL "non supported option" FORCE)
|
||||||
|
set(SPDLOG_WCHAR_CONSOLE OFF CACHE BOOL "non supported option" FORCE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
option(SPDLOG_MSVC_UTF8 "Enable/disable msvc /utf-8 flag required by fmt lib" ON)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||||
|
option(SPDLOG_CLOCK_COARSE "Use CLOCK_REALTIME_COARSE instead of the regular clock," OFF)
|
||||||
|
else ()
|
||||||
|
set(SPDLOG_CLOCK_COARSE OFF CACHE BOOL "non supported option" FORCE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
option(SPDLOG_PREVENT_CHILD_FD "Prevent from child processes to inherit log file descriptors" OFF)
|
||||||
|
option(SPDLOG_NO_THREAD_ID "prevent spdlog from querying the thread id on each log call if thread id is not needed" OFF)
|
||||||
|
option(SPDLOG_NO_TLS "prevent spdlog from using thread local storage" OFF)
|
||||||
|
option(
|
||||||
|
SPDLOG_NO_ATOMIC_LEVELS
|
||||||
|
"prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently"
|
||||||
|
OFF)
|
||||||
|
option(SPDLOG_DISABLE_DEFAULT_LOGGER "Disable default logger creation" OFF)
|
||||||
|
option(SPDLOG_FWRITE_UNLOCKED "Use the unlocked variant of fwrite. Leave this on unless your libc doesn't have it" ON)
|
||||||
|
|
||||||
|
# clang-tidy
|
||||||
|
option(SPDLOG_TIDY "run clang-tidy" OFF)
|
||||||
|
|
||||||
|
if (SPDLOG_TIDY)
|
||||||
|
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
message(STATUS "Enabled clang-tidy")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (SPDLOG_BUILD_PIC)
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
# Static/Shared library
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
set(SPDLOG_SRCS src/spdlog.cpp src/stdout_sinks.cpp src/color_sinks.cpp src/file_sinks.cpp src/async.cpp src/cfg.cpp)
|
||||||
|
|
||||||
|
if (NOT SPDLOG_USE_STD_FORMAT AND NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
|
||||||
|
list(APPEND SPDLOG_SRCS src/bundled_fmtlib_format.cpp)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (SPDLOG_BUILD_SHARED OR BUILD_SHARED_LIBS)
|
||||||
|
if (WIN32)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
|
||||||
|
list(APPEND SPDLOG_SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||||
|
endif ()
|
||||||
|
add_library(spdlog SHARED ${SPDLOG_SRCS} ${SPDLOG_ALL_HEADERS})
|
||||||
|
target_compile_definitions(spdlog PUBLIC SPDLOG_SHARED_LIB)
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
target_compile_options(spdlog PUBLIC $<$<AND:$<CXX_COMPILER_ID:MSVC>,$<NOT:$<COMPILE_LANGUAGE:CUDA>>>:/wd4251
|
||||||
|
/wd4275>)
|
||||||
|
endif ()
|
||||||
|
if (NOT SPDLOG_USE_STD_FORMAT AND NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
|
||||||
|
target_compile_definitions(spdlog PRIVATE FMT_LIB_EXPORT PUBLIC FMT_SHARED)
|
||||||
|
endif ()
|
||||||
|
else ()
|
||||||
|
add_library(spdlog STATIC ${SPDLOG_SRCS} ${SPDLOG_ALL_HEADERS})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
add_library(spdlog::spdlog ALIAS spdlog)
|
||||||
|
|
||||||
|
set(SPDLOG_INCLUDES_LEVEL "")
|
||||||
|
if (SPDLOG_SYSTEM_INCLUDES)
|
||||||
|
set(SPDLOG_INCLUDES_LEVEL "SYSTEM")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
target_compile_definitions(spdlog PUBLIC SPDLOG_COMPILED_LIB)
|
||||||
|
target_include_directories(spdlog ${SPDLOG_INCLUDES_LEVEL} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
||||||
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
|
target_link_libraries(spdlog PUBLIC Threads::Threads)
|
||||||
|
spdlog_enable_warnings(spdlog)
|
||||||
|
|
||||||
|
set_target_properties(spdlog PROPERTIES VERSION ${SPDLOG_VERSION} SOVERSION
|
||||||
|
${SPDLOG_VERSION_MAJOR}.${SPDLOG_VERSION_MINOR})
|
||||||
|
set_target_properties(spdlog PROPERTIES DEBUG_POSTFIX d)
|
||||||
|
|
||||||
|
if (COMMAND target_precompile_headers AND SPDLOG_ENABLE_PCH)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/pch.h.in ${PROJECT_BINARY_DIR}/spdlog_pch.h @ONLY)
|
||||||
|
target_precompile_headers(spdlog PRIVATE ${PROJECT_BINARY_DIR}/spdlog_pch.h)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# sanitizer support
|
||||||
|
if (SPDLOG_SANITIZE_ADDRESS)
|
||||||
|
spdlog_enable_addr_sanitizer(spdlog)
|
||||||
|
elseif (SPDLOG_SANITIZE_THREAD)
|
||||||
|
spdlog_enable_thread_sanitizer(spdlog)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
# Header only version
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
add_library(spdlog_header_only INTERFACE)
|
||||||
|
add_library(spdlog::spdlog_header_only ALIAS spdlog_header_only)
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
spdlog
|
spdlog_header_only ${SPDLOG_INCLUDES_LEVEL} INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
||||||
INTERFACE
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
target_link_libraries(spdlog_header_only INTERFACE Threads::Threads)
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
|
||||||
)
|
|
||||||
|
|
||||||
set(HEADER_BASE "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
# ---------------------------------------------------------------------------------------
|
||||||
|
# Use fmt package if using external fmt
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
if (SPDLOG_FMT_EXTERNAL OR SPDLOG_FMT_EXTERNAL_HO)
|
||||||
|
if (NOT TARGET fmt::fmt)
|
||||||
|
find_package(fmt CONFIG REQUIRED)
|
||||||
|
endif ()
|
||||||
|
target_compile_definitions(spdlog PUBLIC SPDLOG_FMT_EXTERNAL)
|
||||||
|
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_FMT_EXTERNAL)
|
||||||
|
|
||||||
if(SPDLOG_BUILD_EXAMPLES)
|
# use external fmt-header-only
|
||||||
|
if (SPDLOG_FMT_EXTERNAL_HO)
|
||||||
|
target_link_libraries(spdlog PUBLIC fmt::fmt-header-only)
|
||||||
|
target_link_libraries(spdlog_header_only INTERFACE fmt::fmt-header-only)
|
||||||
|
else () # use external compile fmt
|
||||||
|
target_link_libraries(spdlog PUBLIC fmt::fmt)
|
||||||
|
target_link_libraries(spdlog_header_only INTERFACE fmt::fmt)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(PKG_CONFIG_REQUIRES fmt) # add dependency to pkg-config
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
# Check if fwrite_unlocked/_fwrite_nolock is available
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
if (SPDLOG_FWRITE_UNLOCKED)
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
if (WIN32)
|
||||||
|
check_symbol_exists(_fwrite_nolock "stdio.h" HAVE_FWRITE_UNLOCKED)
|
||||||
|
else ()
|
||||||
|
check_symbol_exists(fwrite_unlocked "stdio.h" HAVE_FWRITE_UNLOCKED)
|
||||||
|
endif ()
|
||||||
|
if (HAVE_FWRITE_UNLOCKED)
|
||||||
|
target_compile_definitions(spdlog PRIVATE SPDLOG_FWRITE_UNLOCKED)
|
||||||
|
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_FWRITE_UNLOCKED)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
# Add required libraries for Android CMake build
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
if (ANDROID)
|
||||||
|
target_link_libraries(spdlog PUBLIC log)
|
||||||
|
target_link_libraries(spdlog_header_only INTERFACE log)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
# Misc definitions according to tweak options
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
set(SPDLOG_WCHAR_TO_UTF8_SUPPORT ${SPDLOG_WCHAR_SUPPORT})
|
||||||
|
set(SPDLOG_UTF8_TO_WCHAR_CONSOLE ${SPDLOG_WCHAR_CONSOLE})
|
||||||
|
foreach (
|
||||||
|
SPDLOG_OPTION
|
||||||
|
SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||||
|
SPDLOG_UTF8_TO_WCHAR_CONSOLE
|
||||||
|
SPDLOG_WCHAR_FILENAMES
|
||||||
|
SPDLOG_NO_EXCEPTIONS
|
||||||
|
SPDLOG_CLOCK_COARSE
|
||||||
|
SPDLOG_PREVENT_CHILD_FD
|
||||||
|
SPDLOG_NO_THREAD_ID
|
||||||
|
SPDLOG_NO_TLS
|
||||||
|
SPDLOG_NO_ATOMIC_LEVELS
|
||||||
|
SPDLOG_DISABLE_DEFAULT_LOGGER
|
||||||
|
SPDLOG_USE_STD_FORMAT)
|
||||||
|
if (${SPDLOG_OPTION})
|
||||||
|
target_compile_definitions(spdlog PUBLIC ${SPDLOG_OPTION})
|
||||||
|
target_compile_definitions(spdlog_header_only INTERFACE ${SPDLOG_OPTION})
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
target_compile_options(spdlog PRIVATE "/Zc:__cplusplus")
|
||||||
|
target_compile_options(spdlog_header_only INTERFACE "/Zc:__cplusplus")
|
||||||
|
if (SPDLOG_MSVC_UTF8)
|
||||||
|
# fmtlib requires the /utf-8 flag when building with msvc.
|
||||||
|
# see https://github.com/fmtlib/fmt/pull/4159 on the purpose of the additional
|
||||||
|
# "$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>"
|
||||||
|
target_compile_options(spdlog PUBLIC $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/utf-8>)
|
||||||
|
target_compile_options(spdlog_header_only INTERFACE $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/utf-8>)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
# If exceptions are disabled, disable them in the bundled fmt as well
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
if (SPDLOG_NO_EXCEPTIONS)
|
||||||
|
if (NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
|
||||||
|
target_compile_definitions(spdlog PUBLIC FMT_USE_EXCEPTIONS=0)
|
||||||
|
endif ()
|
||||||
|
if (NOT MSVC)
|
||||||
|
target_compile_options(spdlog PRIVATE -fno-exceptions)
|
||||||
|
else ()
|
||||||
|
target_compile_options(spdlog PRIVATE /EHs-c-)
|
||||||
|
target_compile_definitions(spdlog PRIVATE _HAS_EXCEPTIONS=0)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
# Build binaries
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
if (SPDLOG_BUILD_EXAMPLE OR SPDLOG_BUILD_EXAMPLE_HO OR SPDLOG_BUILD_ALL)
|
||||||
|
message(STATUS "Generating example(s)")
|
||||||
add_subdirectory(example)
|
add_subdirectory(example)
|
||||||
endif()
|
spdlog_enable_warnings(example)
|
||||||
|
if (SPDLOG_BUILD_EXAMPLE_HO)
|
||||||
|
spdlog_enable_warnings(example_header_only)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
if(SPDLOG_BUILD_TESTING)
|
if (SPDLOG_BUILD_TESTS OR SPDLOG_BUILD_TESTS_HO OR SPDLOG_BUILD_ALL)
|
||||||
|
message(STATUS "Generating tests")
|
||||||
|
enable_testing()
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
if (SPDLOG_BUILD_BENCH OR SPDLOG_BUILD_ALL)
|
||||||
# Install/export targets and files
|
message(STATUS "Generating benchmarks")
|
||||||
#---------------------------------------------------------------------------------------
|
add_subdirectory(bench)
|
||||||
# set files and directories
|
endif ()
|
||||||
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
|
||||||
set(include_install_dir "${CMAKE_INSTALL_INCLUDEDIR}")
|
|
||||||
set(pkgconfig_install_dir "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
|
||||||
set(version_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
|
|
||||||
set(project_config "${PROJECT_NAME}Config.cmake")
|
|
||||||
set(pkg_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc")
|
|
||||||
set(targets_export_name "${PROJECT_NAME}Targets")
|
|
||||||
set(namespace "${PROJECT_NAME}::")
|
|
||||||
|
|
||||||
# generate package version file
|
# ---------------------------------------------------------------------------------------
|
||||||
include(CMakePackageConfigHelpers)
|
# Install
|
||||||
write_basic_package_version_file(
|
# ---------------------------------------------------------------------------------------
|
||||||
"${version_config}" COMPATIBILITY SameMajorVersion
|
if (SPDLOG_INSTALL)
|
||||||
)
|
message(STATUS "Generating install")
|
||||||
|
set(project_config_in "${CMAKE_CURRENT_LIST_DIR}/cmake/spdlogConfig.cmake.in")
|
||||||
|
set(project_config_out "${CMAKE_CURRENT_BINARY_DIR}/spdlogConfig.cmake")
|
||||||
|
set(config_targets_file "spdlogConfigTargets.cmake")
|
||||||
|
set(version_config_file "${CMAKE_CURRENT_BINARY_DIR}/spdlogConfigVersion.cmake")
|
||||||
|
set(export_dest_dir "${CMAKE_INSTALL_LIBDIR}/cmake/spdlog")
|
||||||
|
set(pkgconfig_install_dir "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||||
|
set(pkg_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc")
|
||||||
|
|
||||||
# configure pkg config file
|
# ---------------------------------------------------------------------------------------
|
||||||
configure_file("cmake/spdlog.pc.in" "${pkg_config}" @ONLY)
|
# Include files
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" PATTERN "fmt/bundled" EXCLUDE)
|
||||||
|
install(
|
||||||
|
TARGETS spdlog spdlog_header_only
|
||||||
|
EXPORT spdlog
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
|
||||||
# install targets
|
if (NOT SPDLOG_USE_STD_FORMAT AND NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
|
||||||
install(
|
install(DIRECTORY include/${PROJECT_NAME}/fmt/bundled/
|
||||||
TARGETS spdlog
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/fmt/bundled/")
|
||||||
EXPORT "${targets_export_name}"
|
endif ()
|
||||||
INCLUDES DESTINATION "${include_install_dir}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# install headers
|
# ---------------------------------------------------------------------------------------
|
||||||
install(
|
# Install pkg-config file
|
||||||
DIRECTORY "${HEADER_BASE}/${PROJECT_NAME}"
|
# ---------------------------------------------------------------------------------------
|
||||||
DESTINATION "${include_install_dir}"
|
if (IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
)
|
set(PKG_CONFIG_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
else ()
|
||||||
|
set(PKG_CONFIG_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
endif ()
|
||||||
|
if (IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
set(PKG_CONFIG_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
else ()
|
||||||
|
set(PKG_CONFIG_LIBDIR "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
endif ()
|
||||||
|
get_target_property(PKG_CONFIG_DEFINES spdlog INTERFACE_COMPILE_DEFINITIONS)
|
||||||
|
string(REPLACE ";" " -D" PKG_CONFIG_DEFINES "${PKG_CONFIG_DEFINES}")
|
||||||
|
string(CONCAT PKG_CONFIG_DEFINES "-D" "${PKG_CONFIG_DEFINES}")
|
||||||
|
configure_file("cmake/${PROJECT_NAME}.pc.in" "${pkg_config}" @ONLY)
|
||||||
|
install(FILES "${pkg_config}" DESTINATION "${pkgconfig_install_dir}")
|
||||||
|
|
||||||
# install project version file
|
# ---------------------------------------------------------------------------------------
|
||||||
install(
|
# Install CMake config files
|
||||||
FILES "${version_config}"
|
# ---------------------------------------------------------------------------------------
|
||||||
DESTINATION "${config_install_dir}"
|
export(TARGETS spdlog spdlog_header_only NAMESPACE spdlog::
|
||||||
)
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/${config_targets_file}")
|
||||||
|
install(EXPORT spdlog DESTINATION ${export_dest_dir} NAMESPACE spdlog:: FILE ${config_targets_file})
|
||||||
|
|
||||||
# install pkg config file
|
include(CMakePackageConfigHelpers)
|
||||||
install(
|
configure_package_config_file("${project_config_in}" "${project_config_out}" INSTALL_DESTINATION ${export_dest_dir})
|
||||||
FILES "${pkg_config}"
|
|
||||||
DESTINATION "${pkgconfig_install_dir}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# install project config file
|
write_basic_package_version_file("${version_config_file}" COMPATIBILITY SameMajorVersion)
|
||||||
install(
|
install(FILES "${project_config_out}" "${version_config_file}" DESTINATION "${export_dest_dir}")
|
||||||
EXPORT "${targets_export_name}"
|
|
||||||
NAMESPACE "${namespace}"
|
|
||||||
DESTINATION "${config_install_dir}"
|
|
||||||
FILE ${project_config}
|
|
||||||
)
|
|
||||||
|
|
||||||
# export build directory config file
|
# ---------------------------------------------------------------------------------------
|
||||||
export(
|
# Support creation of installable packages
|
||||||
EXPORT ${targets_export_name}
|
# ---------------------------------------------------------------------------------------
|
||||||
NAMESPACE "${namespace}"
|
include(cmake/spdlogCPack.cmake)
|
||||||
FILE ${project_config}
|
endif ()
|
||||||
)
|
|
||||||
|
|
||||||
# register project in CMake user registry
|
|
||||||
export(PACKAGE ${PROJECT_NAME})
|
|
||||||
|
|
||||||
file(GLOB_RECURSE spdlog_include_SRCS "${HEADER_BASE}/*.h")
|
|
||||||
add_custom_target(spdlog_headers_for_ide SOURCES ${spdlog_include_SRCS})
|
|
||||||
|
34
INSTALL
34
INSTALL
@ -1,13 +1,27 @@
|
|||||||
spdlog is header only library.
|
Header Only Version
|
||||||
Just copy the files to your build tree and use a C++11 compiler
|
==================================================================
|
||||||
|
Just copy the files to your build tree and use a C++11 compiler.
|
||||||
|
Or use CMake:
|
||||||
|
```
|
||||||
|
add_executable(example_header_only example.cpp)
|
||||||
|
target_link_libraries(example_header_only spdlog::spdlog_header_only)
|
||||||
|
```
|
||||||
|
|
||||||
Tested on:
|
Compiled Library Version
|
||||||
|
==================================================================
|
||||||
|
CMake:
|
||||||
|
```
|
||||||
|
add_executable(example example.cpp)
|
||||||
|
target_link_libraries(example spdlog::spdlog)
|
||||||
|
```
|
||||||
|
|
||||||
|
Or copy files src/*.cpp to your build tree and pass the -DSPDLOG_COMPILED_LIB to the compiler.
|
||||||
|
|
||||||
|
Important Information for Compilation:
|
||||||
|
==================================================================
|
||||||
|
* If you encounter compilation errors with gcc 4.8.x, please note that gcc 4.8.x does not fully support C++11. In such cases, consider upgrading your compiler or using a different version that fully supports C++11 standards
|
||||||
|
|
||||||
|
Tested on:
|
||||||
gcc 4.8.1 and above
|
gcc 4.8.1 and above
|
||||||
clang 3.5
|
clang 3.5
|
||||||
Visual Studio 2013
|
Visual Studio 2013
|
||||||
|
|
||||||
gcc 4.8 flags: --std==c++11 -pthread -O3 -flto -Wl,--no-as-needed
|
|
||||||
gcc 4.9 flags: --std=c++11 -pthread -O3 -flto
|
|
||||||
|
|
||||||
|
|
||||||
see the makefile in the example folder
|
|
4
LICENSE
4
LICENSE
@ -20,3 +20,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
-- NOTE: Third party dependency used by this software --
|
||||||
|
This software depends on the fmt lib (MIT License),
|
||||||
|
and users must comply to its license: https://raw.githubusercontent.com/fmtlib/fmt/master/LICENSE
|
||||||
|
|
||||||
|
684
README.md
684
README.md
@ -1,221 +1,529 @@
|
|||||||
# spdlog
|
# spdlog
|
||||||
|
|
||||||
Very fast, header only, C++ logging library. [](https://travis-ci.org/gabime/spdlog) [](https://ci.appveyor.com/project/gabime/spdlog)
|
|
||||||
|
[](https://github.com/gabime/spdlog/actions/workflows/linux.yml)
|
||||||
|
[](https://github.com/gabime/spdlog/actions/workflows/windows.yml)
|
||||||
|
[](https://github.com/gabime/spdlog/actions/workflows/macos.yml)
|
||||||
|
[](https://ci.appveyor.com/project/gabime/spdlog) [](https://github.com/gabime/spdlog/releases/latest)
|
||||||
|
|
||||||
|
Fast C++ logging library
|
||||||
|
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
#### Just copy the headers:
|
#### Header-only version
|
||||||
|
Copy the include [folder](include/spdlog) to your build tree and use a C++11 compiler.
|
||||||
|
|
||||||
* Copy the source [folder](https://github.com/gabime/spdlog/tree/master/include/spdlog) to your build tree and use a C++11 compiler.
|
#### Compiled version (recommended - much faster compile times)
|
||||||
|
```console
|
||||||
#### Or use your favorite package manager:
|
$ git clone https://github.com/gabime/spdlog.git
|
||||||
|
$ cd spdlog && mkdir build && cd build
|
||||||
* Ubuntu: `apt-get install libspdlog-dev`
|
$ cmake .. && cmake --build .
|
||||||
* Homebrew: `brew install spdlog`
|
```
|
||||||
* FreeBSD: `cd /usr/ports/devel/spdlog/ && make install clean`
|
see example [CMakeLists.txt](example/CMakeLists.txt) on how to use.
|
||||||
* Fedora: `yum install spdlog`
|
|
||||||
* Gentoo: `emerge dev-libs/spdlog`
|
|
||||||
* Arch Linux: `yaourt -S spdlog-git`
|
|
||||||
* vcpkg: `vcpkg install spdlog`
|
|
||||||
|
|
||||||
|
|
||||||
## Platforms
|
## Platforms
|
||||||
* Linux, FreeBSD, Solaris
|
* Linux, FreeBSD, OpenBSD, Solaris, AIX
|
||||||
* Windows (vc 2013+, cygwin/mingw)
|
* Windows (msvc 2013+, cygwin)
|
||||||
* Mac OSX (clang 3.5+)
|
* macOS (clang 3.5+)
|
||||||
* Android
|
* Android
|
||||||
|
|
||||||
|
## Package managers:
|
||||||
|
* Debian: `sudo apt install libspdlog-dev`
|
||||||
|
* Homebrew: `brew install spdlog`
|
||||||
|
* MacPorts: `sudo port install spdlog`
|
||||||
|
* FreeBSD: `pkg install spdlog`
|
||||||
|
* Fedora: `dnf install spdlog`
|
||||||
|
* Gentoo: `emerge dev-libs/spdlog`
|
||||||
|
* Arch Linux: `pacman -S spdlog`
|
||||||
|
* openSUSE: `sudo zypper in spdlog-devel`
|
||||||
|
* ALT Linux: `apt-get install libspdlog-devel`
|
||||||
|
* vcpkg: `vcpkg install spdlog`
|
||||||
|
* conan: `conan install --requires=spdlog/[*]`
|
||||||
|
* conda: `conda install -c conda-forge spdlog`
|
||||||
|
* build2: ```depends: spdlog ^1.8.2```
|
||||||
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* Very fast - performance is the primary goal (see [benchmarks](#benchmarks) below).
|
* Very fast (see [benchmarks](#benchmarks) below).
|
||||||
* Headers only, just copy and use.
|
* Headers only or compiled
|
||||||
* Feature rich [call style](#usage-example) using the excellent [fmt](https://github.com/fmtlib/fmt) library.
|
* Feature-rich formatting, using the excellent [fmt](https://github.com/fmtlib/fmt) library.
|
||||||
* Optional printf syntax support.
|
* Asynchronous mode (optional)
|
||||||
* Extremely fast asynchronous mode (optional) - using lockfree queues and other tricks to reach millions of calls/sec.
|
* [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) formatting.
|
||||||
* [Custom](https://github.com/gabime/spdlog/wiki/3.-Custom-formatting) formatting.
|
|
||||||
* Conditional Logging
|
|
||||||
* Multi/Single threaded loggers.
|
* Multi/Single threaded loggers.
|
||||||
* Various log targets:
|
* Various log targets:
|
||||||
* Rotating log files.
|
* Rotating log files.
|
||||||
* Daily log files.
|
* Daily log files.
|
||||||
* Console logging (colors supported).
|
* Console logging (colors supported).
|
||||||
* syslog.
|
* syslog.
|
||||||
* Windows debugger (```OutputDebugString(..)```)
|
* Windows event log.
|
||||||
* Easily extendable with custom log targets (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface).
|
* Windows debugger (```OutputDebugString(..)```).
|
||||||
* Severity based filtering - threshold levels can be modified in runtime as well as in compile time.
|
* Log to Qt widgets ([example](#log-to-qt-with-nice-colors)).
|
||||||
|
* Easily [extendable](https://github.com/gabime/spdlog/wiki/Sinks#implementing-your-own-sink) with custom log targets.
|
||||||
|
* Log filtering - log levels can be modified at runtime as well as compile time.
|
||||||
|
* Support for loading log levels from argv or environment var.
|
||||||
|
* [Backtrace](#backtrace-support) support - store debug messages in a ring buffer and display them later on demand.
|
||||||
|
|
||||||
|
## Usage samples
|
||||||
|
|
||||||
|
#### Basic usage
|
||||||
## Benchmarks
|
|
||||||
|
|
||||||
Below are some [benchmarks](bench) comparing popular log libraries under Ubuntu 64 bit, Intel i7-4770 CPU @ 3.40GHz
|
|
||||||
|
|
||||||
#### Synchronous mode
|
|
||||||
Time needed to log 1,000,000 lines in synchronous mode (in seconds, the best of 3 runs):
|
|
||||||
|
|
||||||
|threads|boost log 1.54|glog |easylogging |spdlog|
|
|
||||||
|-------|:-------:|:-----:|----------:|------:|
|
|
||||||
|1| 4.169s |1.066s |0.975s |0.302s|
|
|
||||||
|10| 6.180s |3.032s |2.857s |0.968s|
|
|
||||||
|100| 5.981s |1.139s |4.512s |0.497s|
|
|
||||||
|
|
||||||
|
|
||||||
#### Asynchronous mode
|
|
||||||
Time needed to log 1,000,000 lines in asynchronous mode, i.e. the time it takes to put them in the async queue (in seconds, the best of 3 runs):
|
|
||||||
|
|
||||||
|threads|g2log <sup>async logger</sup> |spdlog <sup>async mode</sup>|
|
|
||||||
|:-------|:-----:|-------------------------:|
|
|
||||||
|1| 1.850s |0.216s |
|
|
||||||
|10| 0.943s |0.173s|
|
|
||||||
|100| 0.959s |0.202s|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Usage Example
|
|
||||||
```c++
|
```c++
|
||||||
|
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
|
|
||||||
#include <iostream>
|
int main()
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
void async_example();
|
|
||||||
void syslog_example();
|
|
||||||
void user_defined_example();
|
|
||||||
void err_handler_example();
|
|
||||||
|
|
||||||
namespace spd = spdlog;
|
|
||||||
int main(int, char*[])
|
|
||||||
{
|
{
|
||||||
try
|
spdlog::info("Welcome to spdlog!");
|
||||||
|
spdlog::error("Some error message with arg: {}", 1);
|
||||||
|
|
||||||
|
spdlog::warn("Easy padding in numbers like {:08d}", 12);
|
||||||
|
spdlog::critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
|
||||||
|
spdlog::info("Support for floats {:03.2f}", 1.23456);
|
||||||
|
spdlog::info("Positional args are {1} {0}..", "too", "supported");
|
||||||
|
spdlog::info("{:<30}", "left aligned");
|
||||||
|
|
||||||
|
spdlog::set_level(spdlog::level::debug); // Set global log level to debug
|
||||||
|
spdlog::debug("This message should be displayed..");
|
||||||
|
|
||||||
|
// change log pattern
|
||||||
|
spdlog::set_pattern("[%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v");
|
||||||
|
|
||||||
|
// Compile time log levels
|
||||||
|
// Note that this does not change the current log level, it will only
|
||||||
|
// remove (depending on SPDLOG_ACTIVE_LEVEL) the call on the release code.
|
||||||
|
SPDLOG_TRACE("Some trace message with param {}", 42);
|
||||||
|
SPDLOG_DEBUG("Some debug message");
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
---
|
||||||
|
#### Create stdout/stderr logger object
|
||||||
|
```c++
|
||||||
|
#include "spdlog/spdlog.h"
|
||||||
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||||
|
void stdout_example()
|
||||||
|
{
|
||||||
|
// create a color multi-threaded logger
|
||||||
|
auto console = spdlog::stdout_color_mt("console");
|
||||||
|
auto err_logger = spdlog::stderr_color_mt("stderr");
|
||||||
|
spdlog::get("console")->info("loggers can be retrieved from a global registry using the spdlog::get(logger_name)");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Basic file logger
|
||||||
|
```c++
|
||||||
|
#include "spdlog/sinks/basic_file_sink.h"
|
||||||
|
void basic_logfile_example()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// Console logger with color
|
auto logger = spdlog::basic_logger_mt("basic_logger", "logs/basic-log.txt");
|
||||||
auto console = spd::stdout_color_mt("console");
|
|
||||||
console->info("Welcome to spdlog!");
|
|
||||||
console->error("Some error message with arg{}..", 1);
|
|
||||||
|
|
||||||
// Formatting examples
|
|
||||||
console->warn("Easy padding in numbers like {:08d}", 12);
|
|
||||||
console->critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
|
|
||||||
console->info("Support for floats {:03.2f}", 1.23456);
|
|
||||||
console->info("Positional args are {1} {0}..", "too", "supported");
|
|
||||||
console->info("{:<30}", "left aligned");
|
|
||||||
|
|
||||||
// Use global registry to retrieve loggers
|
|
||||||
spd::get("console")->info("loggers can be retrieved from a global registry using the spdlog::get(logger_name) function");
|
|
||||||
|
|
||||||
// Create basic file logger (not rotated)
|
|
||||||
auto my_logger = spd::basic_logger_mt("basic_logger", "logs/basic.txt");
|
|
||||||
my_logger->info("Some log message");
|
|
||||||
|
|
||||||
// Create a file rotating logger with 5mb size max and 3 rotated files
|
|
||||||
auto rotating_logger = spd::rotating_logger_mt("some_logger_name", "logs/mylogfile.txt", 1048576 * 5, 3);
|
|
||||||
for (int i = 0; i < 10; ++i)
|
|
||||||
rotating_logger->info("{} * {} equals {:>10}", i, i, i*i);
|
|
||||||
|
|
||||||
// Create a daily logger - a new file is created every day on 2:30am
|
|
||||||
auto daily_logger = spd::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);
|
|
||||||
// trigger flush if the log severity is error or higher
|
|
||||||
daily_logger->flush_on(spd::level::err);
|
|
||||||
daily_logger->info(123.44);
|
|
||||||
|
|
||||||
// Customize msg format for all messages
|
|
||||||
spd::set_pattern("*** [%H:%M:%S %z] [thread %t] %v ***");
|
|
||||||
rotating_logger->info("This is another message with custom format");
|
|
||||||
|
|
||||||
|
|
||||||
// Runtime log levels
|
|
||||||
spd::set_level(spd::level::info); //Set global log level to info
|
|
||||||
console->debug("This message should not be displayed!");
|
|
||||||
console->set_level(spd::level::debug); // Set specific logger's log level
|
|
||||||
console->debug("This message should be displayed..");
|
|
||||||
|
|
||||||
// Compile time log levels
|
|
||||||
// define SPDLOG_DEBUG_ON or SPDLOG_TRACE_ON
|
|
||||||
SPDLOG_TRACE(console, "Enabled only #ifdef SPDLOG_TRACE_ON..{} ,{}", 1, 3.23);
|
|
||||||
SPDLOG_DEBUG(console, "Enabled only #ifdef SPDLOG_DEBUG_ON.. {} ,{}", 1, 3.23);
|
|
||||||
|
|
||||||
// Asynchronous logging is very fast..
|
|
||||||
// Just call spdlog::set_async_mode(q_size) and all created loggers from now on will be asynchronous..
|
|
||||||
async_example();
|
|
||||||
|
|
||||||
// syslog example. linux/osx only
|
|
||||||
syslog_example();
|
|
||||||
|
|
||||||
// android example. compile with NDK
|
|
||||||
android_example();
|
|
||||||
|
|
||||||
// Log user-defined types example
|
|
||||||
user_defined_example();
|
|
||||||
|
|
||||||
// Change default log error handler
|
|
||||||
err_handler_example();
|
|
||||||
|
|
||||||
// Apply a function on all registered loggers
|
|
||||||
spd::apply_all([&](std::shared_ptr<spd::logger> l)
|
|
||||||
{
|
|
||||||
l->info("End of example.");
|
|
||||||
});
|
|
||||||
|
|
||||||
// Release and close all loggers
|
|
||||||
spd::drop_all();
|
|
||||||
}
|
}
|
||||||
// Exceptions will only be thrown upon failed logger or sink construction (not during logging)
|
catch (const spdlog::spdlog_ex &ex)
|
||||||
catch (const spd::spdlog_ex& ex)
|
|
||||||
{
|
{
|
||||||
std::cout << "Log init failed: " << ex.what() << std::endl;
|
std::cout << "Log init failed: " << ex.what() << std::endl;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
```
|
||||||
void async_example()
|
---
|
||||||
|
#### Rotating files
|
||||||
|
```c++
|
||||||
|
#include "spdlog/sinks/rotating_file_sink.h"
|
||||||
|
void rotating_example()
|
||||||
{
|
{
|
||||||
size_t q_size = 4096; //queue size must be power of 2
|
// Create a file rotating logger with 5 MB size max and 3 rotated files
|
||||||
spd::set_async_mode(q_size);
|
auto max_size = 1048576 * 5;
|
||||||
auto async_file = spd::daily_logger_st("async_file_logger", "logs/async_log.txt");
|
auto max_files = 3;
|
||||||
for (int i = 0; i < 100; ++i)
|
auto logger = spdlog::rotating_logger_mt("some_logger_name", "logs/rotating.txt", max_size, max_files);
|
||||||
async_file->info("Async message #{}", i);
|
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
//syslog example
|
---
|
||||||
void syslog_example()
|
#### Daily files
|
||||||
|
```c++
|
||||||
|
|
||||||
|
#include "spdlog/sinks/daily_file_sink.h"
|
||||||
|
void daily_example()
|
||||||
{
|
{
|
||||||
#ifdef SPDLOG_ENABLE_SYSLOG
|
// Create a daily logger - a new file is created every day at 2:30 am
|
||||||
std::string ident = "spdlog-example";
|
auto logger = spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);
|
||||||
auto syslog_logger = spd::syslog_logger("syslog", ident, LOG_PID);
|
|
||||||
syslog_logger->warn("This is warning that will end up in syslog..");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// user defined types logging by implementing operator<<
|
|
||||||
struct my_type
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
template<typename OStream>
|
|
||||||
friend OStream& operator<<(OStream& os, const my_type &c)
|
|
||||||
{
|
|
||||||
return os << "[my_type i="<<c.i << "]";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#include <spdlog/fmt/ostr.h> // must be included
|
|
||||||
void user_defined_example()
|
|
||||||
{
|
|
||||||
spd::get("console")->info("user defined type: {}", my_type { 14 });
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
//custom error handler
|
|
||||||
//
|
|
||||||
void err_handler_example()
|
|
||||||
{
|
|
||||||
spd::set_error_handler([](const std::string& msg) {
|
|
||||||
std::cerr << "my err handler: " << msg << std::endl;
|
|
||||||
});
|
|
||||||
// (or logger->set_error_handler(..) to set for specific logger)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Backtrace support
|
||||||
|
```c++
|
||||||
|
// Debug messages can be stored in a ring buffer instead of being logged immediately.
|
||||||
|
// This is useful to display debug logs only when needed (e.g. when an error happens).
|
||||||
|
// When needed, call dump_backtrace() to dump them to your log.
|
||||||
|
|
||||||
|
spdlog::enable_backtrace(32); // Store the latest 32 messages in a buffer.
|
||||||
|
// or my_logger->enable_backtrace(32)..
|
||||||
|
for(int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
spdlog::debug("Backtrace message {}", i); // not logged yet..
|
||||||
|
}
|
||||||
|
// e.g. if some error happened:
|
||||||
|
spdlog::dump_backtrace(); // log them now! show the last 32 messages
|
||||||
|
// or my_logger->dump_backtrace(32)..
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Periodic flush
|
||||||
|
```c++
|
||||||
|
// periodically flush all *registered* loggers every 3 seconds:
|
||||||
|
// warning: only use if all your loggers are thread-safe ("_mt" loggers)
|
||||||
|
spdlog::flush_every(std::chrono::seconds(3));
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Stopwatch
|
||||||
|
```c++
|
||||||
|
// Stopwatch support for spdlog
|
||||||
|
#include "spdlog/stopwatch.h"
|
||||||
|
void stopwatch_example()
|
||||||
|
{
|
||||||
|
spdlog::stopwatch sw;
|
||||||
|
spdlog::debug("Elapsed {}", sw);
|
||||||
|
spdlog::debug("Elapsed {:.3}", sw);
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Log binary data in hex
|
||||||
|
```c++
|
||||||
|
// many types of std::container<char> types can be used.
|
||||||
|
// ranges are supported too.
|
||||||
|
// format flags:
|
||||||
|
// {:X} - print in uppercase.
|
||||||
|
// {:s} - don't separate each byte with space.
|
||||||
|
// {:p} - don't print the position on each line start.
|
||||||
|
// {:n} - don't split the output into lines.
|
||||||
|
// {:a} - show ASCII if :n is not set.
|
||||||
|
|
||||||
|
#include "spdlog/fmt/bin_to_hex.h"
|
||||||
|
|
||||||
|
void binary_example()
|
||||||
|
{
|
||||||
|
auto console = spdlog::get("console");
|
||||||
|
std::array<char, 80> buf;
|
||||||
|
console->info("Binary example: {}", spdlog::to_hex(buf));
|
||||||
|
console->info("Another binary example:{:n}", spdlog::to_hex(std::begin(buf), std::begin(buf) + 10));
|
||||||
|
// more examples:
|
||||||
|
// logger->info("uppercase: {:X}", spdlog::to_hex(buf));
|
||||||
|
// logger->info("uppercase, no delimiters: {:Xs}", spdlog::to_hex(buf));
|
||||||
|
// logger->info("uppercase, no delimiters, no position info: {:Xsp}", spdlog::to_hex(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Logger with multi sinks - each with a different format and log level
|
||||||
|
```c++
|
||||||
|
|
||||||
|
// create a logger with 2 targets, with different log levels and formats.
|
||||||
|
// The console will show only warnings or errors, while the file will log all.
|
||||||
|
void multi_sink_example()
|
||||||
|
{
|
||||||
|
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
|
||||||
|
console_sink->set_level(spdlog::level::warn);
|
||||||
|
console_sink->set_pattern("[multi_sink_example] [%^%l%$] %v");
|
||||||
|
|
||||||
|
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/multisink.txt", true);
|
||||||
|
file_sink->set_level(spdlog::level::trace);
|
||||||
|
|
||||||
|
spdlog::logger logger("multi_sink", {console_sink, file_sink});
|
||||||
|
logger.set_level(spdlog::level::debug);
|
||||||
|
logger.warn("this should appear in both console and file");
|
||||||
|
logger.info("this message should not appear in the console, only in the file");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### User-defined callbacks about log events
|
||||||
|
```c++
|
||||||
|
|
||||||
|
// create a logger with a lambda function callback, the callback will be called
|
||||||
|
// each time something is logged to the logger
|
||||||
|
void callback_example()
|
||||||
|
{
|
||||||
|
auto callback_sink = std::make_shared<spdlog::sinks::callback_sink_mt>([](const spdlog::details::log_msg &msg) {
|
||||||
|
// for example you can be notified by sending an email to yourself
|
||||||
|
});
|
||||||
|
callback_sink->set_level(spdlog::level::err);
|
||||||
|
|
||||||
|
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
|
||||||
|
spdlog::logger logger("custom_callback_logger", {console_sink, callback_sink});
|
||||||
|
|
||||||
|
logger.info("some info log");
|
||||||
|
logger.error("critical issue"); // will notify you
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Asynchronous logging
|
||||||
|
```c++
|
||||||
|
#include "spdlog/async.h"
|
||||||
|
#include "spdlog/sinks/basic_file_sink.h"
|
||||||
|
void async_example()
|
||||||
|
{
|
||||||
|
// default thread pool settings can be modified *before* creating the async logger:
|
||||||
|
// spdlog::init_thread_pool(8192, 1); // queue with 8k items and 1 backing thread.
|
||||||
|
auto async_file = spdlog::basic_logger_mt<spdlog::async_factory>("async_file_logger", "logs/async_log.txt");
|
||||||
|
// alternatively:
|
||||||
|
// auto async_file = spdlog::create_async<spdlog::sinks::basic_file_sink_mt>("async_file_logger", "logs/async_log.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Asynchronous logger with multi sinks
|
||||||
|
```c++
|
||||||
|
#include "spdlog/async.h"
|
||||||
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||||
|
#include "spdlog/sinks/rotating_file_sink.h"
|
||||||
|
|
||||||
|
void multi_sink_example2()
|
||||||
|
{
|
||||||
|
spdlog::init_thread_pool(8192, 1);
|
||||||
|
auto stdout_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt >();
|
||||||
|
auto rotating_sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>("mylog.txt", 1024*1024*10, 3);
|
||||||
|
std::vector<spdlog::sink_ptr> sinks {stdout_sink, rotating_sink};
|
||||||
|
auto logger = std::make_shared<spdlog::async_logger>("loggername", sinks.begin(), sinks.end(), spdlog::thread_pool(), spdlog::async_overflow_policy::block);
|
||||||
|
spdlog::register_logger(logger);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### User-defined types
|
||||||
|
```c++
|
||||||
|
template<>
|
||||||
|
struct fmt::formatter<my_type> : fmt::formatter<std::string>
|
||||||
|
{
|
||||||
|
auto format(my_type my, format_context &ctx) const -> decltype(ctx.out())
|
||||||
|
{
|
||||||
|
return fmt::format_to(ctx.out(), "[my_type i={}]", my.i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void user_defined_example()
|
||||||
|
{
|
||||||
|
spdlog::info("user defined type: {}", my_type(14));
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### User-defined flags in the log pattern
|
||||||
|
```c++
|
||||||
|
// Log patterns can contain custom flags.
|
||||||
|
// the following example will add new flag '%*' - which will be bound to a <my_formatter_flag> instance.
|
||||||
|
#include "spdlog/pattern_formatter.h"
|
||||||
|
class my_formatter_flag : public spdlog::custom_flag_formatter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void format(const spdlog::details::log_msg &, const std::tm &, spdlog::memory_buf_t &dest) override
|
||||||
|
{
|
||||||
|
std::string some_txt = "custom-flag";
|
||||||
|
dest.append(some_txt.data(), some_txt.data() + some_txt.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<custom_flag_formatter> clone() const override
|
||||||
|
{
|
||||||
|
return spdlog::details::make_unique<my_formatter_flag>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void custom_flags_example()
|
||||||
|
{
|
||||||
|
auto formatter = std::make_unique<spdlog::pattern_formatter>();
|
||||||
|
formatter->add_flag<my_formatter_flag>('*').set_pattern("[%n] [%*] [%^%l%$] %v");
|
||||||
|
spdlog::set_formatter(std::move(formatter));
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Custom error handler
|
||||||
|
```c++
|
||||||
|
void err_handler_example()
|
||||||
|
{
|
||||||
|
// can be set globally or per logger(logger->set_error_handler(..))
|
||||||
|
spdlog::set_error_handler([](const std::string &msg) { spdlog::get("console")->error("*** LOGGER ERROR ***: {}", msg); });
|
||||||
|
spdlog::get("console")->info("some invalid message to trigger an error {}{}{}{}", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### syslog
|
||||||
|
```c++
|
||||||
|
#include "spdlog/sinks/syslog_sink.h"
|
||||||
|
void syslog_example()
|
||||||
|
{
|
||||||
|
std::string ident = "spdlog-example";
|
||||||
|
auto syslog_logger = spdlog::syslog_logger_mt("syslog", ident, LOG_PID);
|
||||||
|
syslog_logger->warn("This is warning that will end up in syslog.");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
---
|
||||||
|
#### Android example
|
||||||
|
```c++
|
||||||
|
#include "spdlog/sinks/android_sink.h"
|
||||||
|
void android_example()
|
||||||
|
{
|
||||||
|
std::string tag = "spdlog-android";
|
||||||
|
auto android_logger = spdlog::android_logger_mt("android", tag);
|
||||||
|
android_logger->critical("Use \"adb shell logcat\" to view this message.");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Load log levels from the env variable or argv
|
||||||
|
|
||||||
|
```c++
|
||||||
|
#include "spdlog/cfg/env.h"
|
||||||
|
int main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
spdlog::cfg::load_env_levels();
|
||||||
|
// or specify the env variable name:
|
||||||
|
// MYAPP_LEVEL=info,mylogger=trace && ./example
|
||||||
|
// spdlog::cfg::load_env_levels("MYAPP_LEVEL");
|
||||||
|
// or from the command line:
|
||||||
|
// ./example SPDLOG_LEVEL=info,mylogger=trace
|
||||||
|
// #include "spdlog/cfg/argv.h" // for loading levels from argv
|
||||||
|
// spdlog::cfg::load_argv_levels(argc, argv);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
So then you can:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ export SPDLOG_LEVEL=info,mylogger=trace
|
||||||
|
$ ./example
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Log file open/close event handlers
|
||||||
|
```c++
|
||||||
|
// You can get callbacks from spdlog before/after a log file has been opened or closed.
|
||||||
|
// This is useful for cleanup procedures or for adding something to the start/end of the log file.
|
||||||
|
void file_events_example()
|
||||||
|
{
|
||||||
|
// pass the spdlog::file_event_handlers to file sinks for open/close log file notifications
|
||||||
|
spdlog::file_event_handlers handlers;
|
||||||
|
handlers.before_open = [](spdlog::filename_t filename) { spdlog::info("Before opening {}", filename); };
|
||||||
|
handlers.after_open = [](spdlog::filename_t filename, std::FILE *fstream) { fputs("After opening\n", fstream); };
|
||||||
|
handlers.before_close = [](spdlog::filename_t filename, std::FILE *fstream) { fputs("Before closing\n", fstream); };
|
||||||
|
handlers.after_close = [](spdlog::filename_t filename) { spdlog::info("After closing {}", filename); };
|
||||||
|
auto my_logger = spdlog::basic_logger_st("some_logger", "logs/events-sample.txt", true, handlers);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Replace the Default Logger
|
||||||
|
```c++
|
||||||
|
void replace_default_logger_example()
|
||||||
|
{
|
||||||
|
auto new_logger = spdlog::basic_logger_mt("new_default_logger", "logs/new-default-log.txt", true);
|
||||||
|
spdlog::set_default_logger(new_logger);
|
||||||
|
spdlog::info("new logger log message");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Log to Qt with nice colors
|
||||||
|
```c++
|
||||||
|
#include "spdlog/spdlog.h"
|
||||||
|
#include "spdlog/sinks/qt_sinks.h"
|
||||||
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||||
|
{
|
||||||
|
setMinimumSize(640, 480);
|
||||||
|
auto log_widget = new QTextEdit(this);
|
||||||
|
setCentralWidget(log_widget);
|
||||||
|
int max_lines = 500; // keep the text widget to max 500 lines. remove old lines if needed.
|
||||||
|
auto logger = spdlog::qt_color_logger_mt("qt_logger", log_widget, max_lines);
|
||||||
|
logger->info("Some info message");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
#### Mapped Diagnostic Context
|
||||||
|
```c++
|
||||||
|
// Mapped Diagnostic Context (MDC) is a map that stores key-value pairs (string values) in thread local storage.
|
||||||
|
// Each thread maintains its own MDC, which loggers use to append diagnostic information to log outputs.
|
||||||
|
// Note: it is not supported in asynchronous mode due to its reliance on thread-local storage.
|
||||||
|
#include "spdlog/mdc.h"
|
||||||
|
void mdc_example()
|
||||||
|
{
|
||||||
|
spdlog::mdc::put("key1", "value1");
|
||||||
|
spdlog::mdc::put("key2", "value2");
|
||||||
|
// if not using the default format, use the %& formatter to print mdc data
|
||||||
|
// spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [%&] %v");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
---
|
||||||
|
## Benchmarks
|
||||||
|
|
||||||
|
Below are some [benchmarks](bench/bench.cpp) done in Ubuntu 64 bit, Intel i7-4770 CPU @ 3.40GHz
|
||||||
|
|
||||||
|
#### Synchronous mode
|
||||||
|
```
|
||||||
|
[info] **************************************************************
|
||||||
|
[info] Single thread, 1,000,000 iterations
|
||||||
|
[info] **************************************************************
|
||||||
|
[info] basic_st Elapsed: 0.17 secs 5,777,626/sec
|
||||||
|
[info] rotating_st Elapsed: 0.18 secs 5,475,894/sec
|
||||||
|
[info] daily_st Elapsed: 0.20 secs 5,062,659/sec
|
||||||
|
[info] empty_logger Elapsed: 0.07 secs 14,127,300/sec
|
||||||
|
[info] **************************************************************
|
||||||
|
[info] C-string (400 bytes). Single thread, 1,000,000 iterations
|
||||||
|
[info] **************************************************************
|
||||||
|
[info] basic_st Elapsed: 0.41 secs 2,412,483/sec
|
||||||
|
[info] rotating_st Elapsed: 0.72 secs 1,389,196/sec
|
||||||
|
[info] daily_st Elapsed: 0.42 secs 2,393,298/sec
|
||||||
|
[info] null_st Elapsed: 0.04 secs 27,446,957/sec
|
||||||
|
[info] **************************************************************
|
||||||
|
[info] 10 threads, competing over the same logger object, 1,000,000 iterations
|
||||||
|
[info] **************************************************************
|
||||||
|
[info] basic_mt Elapsed: 0.60 secs 1,659,613/sec
|
||||||
|
[info] rotating_mt Elapsed: 0.62 secs 1,612,493/sec
|
||||||
|
[info] daily_mt Elapsed: 0.61 secs 1,638,305/sec
|
||||||
|
[info] null_mt Elapsed: 0.16 secs 6,272,758/sec
|
||||||
|
```
|
||||||
|
#### Asynchronous mode
|
||||||
|
```
|
||||||
|
[info] -------------------------------------------------
|
||||||
|
[info] Messages : 1,000,000
|
||||||
|
[info] Threads : 10
|
||||||
|
[info] Queue : 8,192 slots
|
||||||
|
[info] Queue memory : 8,192 x 272 = 2,176 KB
|
||||||
|
[info] -------------------------------------------------
|
||||||
|
[info]
|
||||||
|
[info] *********************************
|
||||||
|
[info] Queue Overflow Policy: block
|
||||||
|
[info] *********************************
|
||||||
|
[info] Elapsed: 1.70784 secs 585,535/sec
|
||||||
|
[info] Elapsed: 1.69805 secs 588,910/sec
|
||||||
|
[info] Elapsed: 1.7026 secs 587,337/sec
|
||||||
|
[info]
|
||||||
|
[info] *********************************
|
||||||
|
[info] Queue Overflow Policy: overrun
|
||||||
|
[info] *********************************
|
||||||
|
[info] Elapsed: 0.372816 secs 2,682,285/sec
|
||||||
|
[info] Elapsed: 0.379758 secs 2,633,255/sec
|
||||||
|
[info] Elapsed: 0.373532 secs 2,677,147/sec
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
Documentation can be found in the [wiki](https://github.com/gabime/spdlog/wiki/1.-QuickStart) pages.
|
|
||||||
|
Documentation can be found in the [wiki](https://github.com/gabime/spdlog/wiki) pages.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Thanks to [JetBrains](https://www.jetbrains.com/?from=spdlog) for donating product licenses to help develop **spdlog** <a href="https://www.jetbrains.com/?from=spdlog"><img src="logos/jetbrains-variant-4.svg" width="94" align="center" /></a>
|
||||||
|
|
||||||
|
|
||||||
|
101
appveyor.yml
101
appveyor.yml
@ -1,32 +1,89 @@
|
|||||||
version: 1.0.{build}
|
version: 1.0.{build}
|
||||||
image: Visual Studio 2015
|
image: Visual Studio 2017
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- GENERATOR: '"MinGW Makefiles"'
|
- GENERATOR: '"Visual Studio 15 2017 Win64"'
|
||||||
BUILD_TYPE: Debug
|
BUILD_TYPE: Debug
|
||||||
- GENERATOR: '"MinGW Makefiles"'
|
BUILD_SHARED: 'OFF'
|
||||||
BUILD_TYPE: Release
|
FATAL_ERRORS: 'OFF'
|
||||||
- GENERATOR: '"Visual Studio 14 2015"'
|
WCHAR: 'ON'
|
||||||
BUILD_TYPE: Debug
|
WCHAR_FILES: 'OFF'
|
||||||
- GENERATOR: '"Visual Studio 14 2015"'
|
BUILD_EXAMPLE: 'ON'
|
||||||
BUILD_TYPE: Release
|
USE_STD_FORMAT: 'OFF'
|
||||||
- GENERATOR: '"Visual Studio 14 2015 Win64"'
|
CXX_STANDARD: 11
|
||||||
BUILD_TYPE: Debug
|
- GENERATOR: '"Visual Studio 15 2017 Win64"'
|
||||||
- GENERATOR: '"Visual Studio 14 2015 Win64"'
|
BUILD_TYPE: Release
|
||||||
BUILD_TYPE: Release
|
BUILD_SHARED: 'OFF'
|
||||||
|
FATAL_ERRORS: 'OFF'
|
||||||
|
WCHAR: 'OFF'
|
||||||
|
WCHAR_FILES: 'OFF'
|
||||||
|
BUILD_EXAMPLE: 'ON'
|
||||||
|
USE_STD_FORMAT: 'OFF'
|
||||||
|
CXX_STANDARD: 11
|
||||||
|
- GENERATOR: '"Visual Studio 15 2017 Win64"'
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
BUILD_SHARED: 'ON'
|
||||||
|
FATAL_ERRORS: 'OFF'
|
||||||
|
WCHAR: 'OFF'
|
||||||
|
WCHAR_FILES: 'OFF'
|
||||||
|
BUILD_EXAMPLE: 'ON'
|
||||||
|
USE_STD_FORMAT: 'OFF'
|
||||||
|
CXX_STANDARD: 11
|
||||||
|
- GENERATOR: '"Visual Studio 15 2017 Win64"'
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
BUILD_SHARED: 'ON'
|
||||||
|
FATAL_ERRORS: 'OFF'
|
||||||
|
WCHAR: 'ON'
|
||||||
|
WCHAR_FILES: 'ON'
|
||||||
|
BUILD_EXAMPLE: 'OFF'
|
||||||
|
USE_STD_FORMAT: 'OFF'
|
||||||
|
CXX_STANDARD: 11
|
||||||
|
- GENERATOR: '"Visual Studio 16 2019" -A x64'
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
BUILD_SHARED: 'ON'
|
||||||
|
FATAL_ERRORS: 'ON'
|
||||||
|
WCHAR: 'OFF'
|
||||||
|
WCHAR_FILES: 'OFF'
|
||||||
|
BUILD_EXAMPLE: 'OFF'
|
||||||
|
USE_STD_FORMAT: 'OFF'
|
||||||
|
CXX_STANDARD: 17
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
|
- GENERATOR: '"Visual Studio 17 2022" -A x64'
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
BUILD_SHARED: 'ON'
|
||||||
|
FATAL_ERRORS: 'ON'
|
||||||
|
WCHAR: 'OFF'
|
||||||
|
WCHAR_FILES: 'OFF'
|
||||||
|
BUILD_EXAMPLE: 'OFF'
|
||||||
|
USE_STD_FORMAT: 'ON'
|
||||||
|
CXX_STANDARD: 20
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
|
||||||
|
- GENERATOR: '"Visual Studio 17 2022" -A x64'
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
BUILD_SHARED: 'ON'
|
||||||
|
FATAL_ERRORS: 'ON'
|
||||||
|
WCHAR: 'ON'
|
||||||
|
WCHAR_FILES: 'ON'
|
||||||
|
BUILD_EXAMPLE: 'OFF'
|
||||||
|
USE_STD_FORMAT: 'ON'
|
||||||
|
CXX_STANDARD: 20
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
|
||||||
build_script:
|
build_script:
|
||||||
- cmd: >-
|
- cmd: >-
|
||||||
set
|
set
|
||||||
|
|
||||||
mkdir build
|
mkdir build
|
||||||
|
|
||||||
cd build
|
cd build
|
||||||
|
|
||||||
set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
|
set PATH=%PATH%;C:\Program Files\Git\usr\bin
|
||||||
|
|
||||||
set PATH=C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin;%PATH%
|
cmake -G %GENERATOR% -D CMAKE_BUILD_TYPE=%BUILD_TYPE% -D BUILD_SHARED_LIBS=%BUILD_SHARED% -D SPDLOG_WCHAR_SUPPORT=%WCHAR% -D SPDLOG_WCHAR_FILENAMES=%WCHAR_FILES% -D SPDLOG_BUILD_EXAMPLE=%BUILD_EXAMPLE% -D SPDLOG_BUILD_EXAMPLE_HO=%BUILD_EXAMPLE% -D SPDLOG_BUILD_TESTS=ON -D SPDLOG_BUILD_TESTS_HO=OFF -D SPDLOG_BUILD_WARNINGS=%FATAL_ERRORS% -D SPDLOG_USE_STD_FORMAT=%USE_STD_FORMAT% -D CMAKE_CXX_STANDARD=%CXX_STANDARD% ..
|
||||||
|
|
||||||
cmake .. -G %GENERATOR% -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
|
cmake --build . --config %BUILD_TYPE%
|
||||||
|
|
||||||
cmake --build . --config %BUILD_TYPE%
|
before_test:
|
||||||
test: off
|
- set PATH=%PATH%;C:\projects\spdlog\build\_deps\catch2-build\src\%BUILD_TYPE%;C:\projects\spdlog\build\%BUILD_TYPE%
|
||||||
|
|
||||||
|
test_script:
|
||||||
|
- C:\projects\spdlog\build\tests\%BUILD_TYPE%\spdlog-utests.exe
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
find . -name "*\.h" -o -name "*\.cpp"|xargs dos2unix
|
|
||||||
find . -name "*\.h" -o -name "*\.cpp"|xargs astyle -n -c -A1
|
|
||||||
|
|
||||||
|
|
37
bench/CMakeLists.txt
Normal file
37
bench/CMakeLists.txt
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# Copyright(c) 2019 spdlog authors Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.11)
|
||||||
|
project(spdlog_bench CXX)
|
||||||
|
|
||||||
|
if(NOT TARGET spdlog)
|
||||||
|
# Stand-alone build
|
||||||
|
find_package(spdlog CONFIG REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
find_package(benchmark CONFIG)
|
||||||
|
if(NOT benchmark_FOUND)
|
||||||
|
message(STATUS "Using CMake Version ${CMAKE_VERSION}")
|
||||||
|
# User can fetch googlebenchmark
|
||||||
|
message(STATUS "Downloading GoogleBenchmark")
|
||||||
|
include(FetchContent)
|
||||||
|
|
||||||
|
# disable tests
|
||||||
|
set(BENCHMARK_ENABLE_TESTING OFF CACHE INTERNAL "")
|
||||||
|
# Do not build and run googlebenchmark tests
|
||||||
|
FetchContent_Declare(googlebenchmark GIT_REPOSITORY https://github.com/google/benchmark.git GIT_TAG v1.6.0)
|
||||||
|
FetchContent_MakeAvailable(googlebenchmark)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(bench bench.cpp)
|
||||||
|
spdlog_enable_warnings(bench)
|
||||||
|
target_link_libraries(bench PRIVATE spdlog::spdlog)
|
||||||
|
|
||||||
|
add_executable(async_bench async_bench.cpp)
|
||||||
|
target_link_libraries(async_bench PRIVATE spdlog::spdlog)
|
||||||
|
|
||||||
|
add_executable(latency latency.cpp)
|
||||||
|
target_link_libraries(latency PRIVATE benchmark::benchmark spdlog::spdlog)
|
||||||
|
|
||||||
|
add_executable(formatter-bench formatter-bench.cpp)
|
||||||
|
target_link_libraries(formatter-bench PRIVATE benchmark::benchmark spdlog::spdlog)
|
@ -1,62 +0,0 @@
|
|||||||
CXX ?= g++
|
|
||||||
CXXFLAGS = -march=native -Wall -Wextra -pedantic -std=c++11 -pthread -I../include
|
|
||||||
CXX_RELEASE_FLAGS = -O3 -flto -DNDEBUG
|
|
||||||
|
|
||||||
|
|
||||||
binaries=spdlog-bench spdlog-bench-mt spdlog-async spdlog-null-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-async easylogging-bench easylogging-bench-mt
|
|
||||||
|
|
||||||
all: $(binaries)
|
|
||||||
|
|
||||||
spdlog-bench: spdlog-bench.cpp
|
|
||||||
$(CXX) spdlog-bench.cpp -o spdlog-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
spdlog-bench-mt: spdlog-bench-mt.cpp
|
|
||||||
$(CXX) spdlog-bench-mt.cpp -o spdlog-bench-mt $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
spdlog-async: spdlog-async.cpp
|
|
||||||
$(CXX) spdlog-async.cpp -o spdlog-async $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
spdlog-null-async: spdlog-null-async.cpp
|
|
||||||
$(CXX) spdlog-null-async.cpp -o spdlog-null-async $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOST_FLAGS = -DBOOST_LOG_DYN_LINK -I/usr/include -lboost_log -lboost_log_setup -lboost_filesystem -lboost_system -lboost_thread -lboost_regex -lboost_date_time -lboost_chrono
|
|
||||||
|
|
||||||
boost-bench: boost-bench.cpp
|
|
||||||
$(CXX) boost-bench.cpp -o boost-bench $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
boost-bench-mt: boost-bench-mt.cpp
|
|
||||||
$(CXX) boost-bench-mt.cpp -o boost-bench-mt $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
GLOG_FLAGS = -lglog
|
|
||||||
glog-bench: glog-bench.cpp
|
|
||||||
$(CXX) glog-bench.cpp -o glog-bench $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
glog-bench-mt: glog-bench-mt.cpp
|
|
||||||
$(CXX) glog-bench-mt.cpp -o glog-bench-mt $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
G2LOG_FLAGS = -I/home/gabi/devel/g2log/g2log/src -L/home/gabi/devel/g2log/g2log -llib_g2logger
|
|
||||||
g2log-async: g2log-async.cpp
|
|
||||||
$(CXX) g2log-async.cpp -o g2log-async $(CXXFLAGS) $(G2LOG_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
EASYL_FLAGS = -I../../easylogging/src/
|
|
||||||
easylogging-bench: easylogging-bench.cpp
|
|
||||||
$(CXX) easylogging-bench.cpp -o easylogging-bench $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
easylogging-bench-mt: easylogging-bench-mt.cpp
|
|
||||||
$(CXX) easylogging-bench-mt.cpp -o easylogging-bench-mt $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o logs/* $(binaries)
|
|
||||||
|
|
||||||
|
|
||||||
rebuild: clean all
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
|||||||
CXX ?= g++
|
|
||||||
CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -pedantic -std=c++11 -pthread -Wl,--no-as-needed -I../include
|
|
||||||
CXX_RELEASE_FLAGS = -O3 -flto
|
|
||||||
|
|
||||||
|
|
||||||
binaries=spdlog-bench spdlog-bench-mt spdlog-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-async easylogging-bench easylogging-bench-mt
|
|
||||||
|
|
||||||
all: $(binaries)
|
|
||||||
|
|
||||||
spdlog-bench: spdlog-bench.cpp
|
|
||||||
$(CXX) spdlog-bench.cpp -o spdlog-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
spdlog-bench-mt: spdlog-bench-mt.cpp
|
|
||||||
$(CXX) spdlog-bench-mt.cpp -o spdlog-bench-mt $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
spdlog-async: spdlog-async.cpp
|
|
||||||
$(CXX) spdlog-async.cpp -o spdlog-async $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
BOOST_FLAGS = -DBOOST_LOG_DYN_LINK -I/home/gabi/devel/boost_1_56_0/ -L/home/gabi/devel/boost_1_56_0/stage/lib -lboost_log -lboost_log_setup -lboost_filesystem -lboost_system -lboost_thread -lboost_regex -lboost_date_time -lboost_chrono
|
|
||||||
|
|
||||||
boost-bench: boost-bench.cpp
|
|
||||||
$(CXX) boost-bench.cpp -o boost-bench $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
boost-bench-mt: boost-bench-mt.cpp
|
|
||||||
$(CXX) boost-bench-mt.cpp -o boost-bench-mt $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
GLOG_FLAGS = -lglog
|
|
||||||
glog-bench: glog-bench.cpp
|
|
||||||
$(CXX) glog-bench.cpp -o glog-bench $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
glog-bench-mt: glog-bench-mt.cpp
|
|
||||||
$(CXX) glog-bench-mt.cpp -o glog-bench-mt $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
G2LOG_FLAGS = -I/home/gabi/devel/g2log/g2log/src -L/home/gabi/devel/g2log/g2log -llib_g2logger
|
|
||||||
g2log-async: g2log-async.cpp
|
|
||||||
$(CXX) g2log-async.cpp -o g2log-async $(CXXFLAGS) $(G2LOG_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
EASYL_FLAGS = -I../../easylogging/src/
|
|
||||||
easylogging-bench: easylogging-bench.cpp
|
|
||||||
$(CXX) easylogging-bench.cpp -o easylogging-bench $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
easylogging-bench-mt: easylogging-bench-mt.cpp
|
|
||||||
$(CXX) easylogging-bench-mt.cpp -o easylogging-bench-mt $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o logs/* $(binaries)
|
|
||||||
|
|
||||||
|
|
||||||
rebuild: clean all
|
|
||||||
|
|
||||||
|
|
||||||
|
|
168
bench/async_bench.cpp
Normal file
168
bench/async_bench.cpp
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
//
|
||||||
|
// Copyright(c) 2015 Gabi Melman.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// bench.cpp : spdlog benchmarks
|
||||||
|
//
|
||||||
|
#include "spdlog/spdlog.h"
|
||||||
|
#include "spdlog/async.h"
|
||||||
|
#include "spdlog/sinks/basic_file_sink.h"
|
||||||
|
|
||||||
|
#if defined(SPDLOG_USE_STD_FORMAT)
|
||||||
|
#include <format>
|
||||||
|
#elif defined(SPDLOG_FMT_EXTERNAL)
|
||||||
|
#include <fmt/format.h>
|
||||||
|
#else
|
||||||
|
#include "spdlog/fmt/bundled/format.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include <atomic>
|
||||||
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace std::chrono;
|
||||||
|
using namespace spdlog;
|
||||||
|
using namespace spdlog::sinks;
|
||||||
|
using namespace utils;
|
||||||
|
|
||||||
|
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count);
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4996) // disable fopen warning under msvc
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
|
int count_lines(const char *filename) {
|
||||||
|
int counter = 0;
|
||||||
|
auto *infile = fopen(filename, "r");
|
||||||
|
int ch;
|
||||||
|
while (EOF != (ch = getc(infile))) {
|
||||||
|
if ('\n' == ch) counter++;
|
||||||
|
}
|
||||||
|
fclose(infile);
|
||||||
|
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void verify_file(const char *filename, int expected_count) {
|
||||||
|
spdlog::info("Verifying {} to contain {} line..", filename, expected_count);
|
||||||
|
auto count = count_lines(filename);
|
||||||
|
if (count != expected_count) {
|
||||||
|
spdlog::error("Test failed. {} has {} lines instead of {}", filename, count,
|
||||||
|
expected_count);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
spdlog::info("Line count OK ({})\n", count);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
int howmany = 1000000;
|
||||||
|
int queue_size = std::min(howmany + 2, 8192);
|
||||||
|
int threads = 10;
|
||||||
|
int iters = 3;
|
||||||
|
|
||||||
|
try {
|
||||||
|
spdlog::set_pattern("[%^%l%$] %v");
|
||||||
|
if (argc == 1) {
|
||||||
|
spdlog::info("Usage: {} <message_count> <threads> <q_size> <iterations>", argv[0]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 1) howmany = atoi(argv[1]);
|
||||||
|
if (argc > 2) threads = atoi(argv[2]);
|
||||||
|
if (argc > 3) {
|
||||||
|
queue_size = atoi(argv[3]);
|
||||||
|
if (queue_size > 500000) {
|
||||||
|
spdlog::error("Max queue size allowed: 500,000");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 4) iters = atoi(argv[4]);
|
||||||
|
|
||||||
|
auto slot_size = sizeof(spdlog::details::async_msg);
|
||||||
|
spdlog::info("-------------------------------------------------");
|
||||||
|
spdlog::info("Messages : {:L}", howmany);
|
||||||
|
spdlog::info("Threads : {:L}", threads);
|
||||||
|
spdlog::info("Queue : {:L} slots", queue_size);
|
||||||
|
spdlog::info("Queue memory : {:L} x {:L} = {:L} KB ", queue_size, slot_size,
|
||||||
|
(queue_size * slot_size) / 1024);
|
||||||
|
spdlog::info("Total iters : {:L}", iters);
|
||||||
|
spdlog::info("-------------------------------------------------");
|
||||||
|
|
||||||
|
const char *filename = "logs/basic_async.log";
|
||||||
|
spdlog::info("");
|
||||||
|
spdlog::info("*********************************");
|
||||||
|
spdlog::info("Queue Overflow Policy: block");
|
||||||
|
spdlog::info("*********************************");
|
||||||
|
for (int i = 0; i < iters; i++) {
|
||||||
|
auto tp = std::make_shared<details::thread_pool>(queue_size, 1);
|
||||||
|
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(filename, true);
|
||||||
|
auto logger = std::make_shared<async_logger>(
|
||||||
|
"async_logger", std::move(file_sink), std::move(tp), async_overflow_policy::block);
|
||||||
|
bench_mt(howmany, std::move(logger), threads);
|
||||||
|
// verify_file(filename, howmany);
|
||||||
|
}
|
||||||
|
|
||||||
|
spdlog::info("");
|
||||||
|
spdlog::info("*********************************");
|
||||||
|
spdlog::info("Queue Overflow Policy: overrun");
|
||||||
|
spdlog::info("*********************************");
|
||||||
|
// do same test but discard oldest if queue is full instead of blocking
|
||||||
|
filename = "logs/basic_async-overrun.log";
|
||||||
|
for (int i = 0; i < iters; i++) {
|
||||||
|
auto tp = std::make_shared<details::thread_pool>(queue_size, 1);
|
||||||
|
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(filename, true);
|
||||||
|
auto logger =
|
||||||
|
std::make_shared<async_logger>("async_logger", std::move(file_sink), std::move(tp),
|
||||||
|
async_overflow_policy::overrun_oldest);
|
||||||
|
bench_mt(howmany, std::move(logger), threads);
|
||||||
|
}
|
||||||
|
spdlog::shutdown();
|
||||||
|
} catch (std::exception &ex) {
|
||||||
|
std::cerr << "Error: " << ex.what() << std::endl;
|
||||||
|
perror("Last error");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void thread_fun(std::shared_ptr<spdlog::logger> logger, int howmany) {
|
||||||
|
for (int i = 0; i < howmany; i++) {
|
||||||
|
logger->info("Hello logger: msg number {}", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> logger, int thread_count) {
|
||||||
|
using std::chrono::high_resolution_clock;
|
||||||
|
vector<std::thread> threads;
|
||||||
|
auto start = high_resolution_clock::now();
|
||||||
|
|
||||||
|
int msgs_per_thread = howmany / thread_count;
|
||||||
|
int msgs_per_thread_mod = howmany % thread_count;
|
||||||
|
for (int t = 0; t < thread_count; ++t) {
|
||||||
|
if (t == 0 && msgs_per_thread_mod)
|
||||||
|
threads.push_back(
|
||||||
|
std::thread(thread_fun, logger, msgs_per_thread + msgs_per_thread_mod));
|
||||||
|
else
|
||||||
|
threads.push_back(std::thread(thread_fun, logger, msgs_per_thread));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &t : threads) {
|
||||||
|
t.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto delta = high_resolution_clock::now() - start;
|
||||||
|
auto delta_d = duration_cast<duration<double>>(delta).count();
|
||||||
|
spdlog::info("Elapsed: {} secs\t {:L}/sec", delta_d, int(howmany / delta_d));
|
||||||
|
}
|
246
bench/bench.cpp
Normal file
246
bench/bench.cpp
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
//
|
||||||
|
// Copyright(c) 2015 Gabi Melman.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// bench.cpp : spdlog benchmarks
|
||||||
|
//
|
||||||
|
#include "spdlog/spdlog.h"
|
||||||
|
#include "spdlog/sinks/basic_file_sink.h"
|
||||||
|
#include "spdlog/sinks/daily_file_sink.h"
|
||||||
|
#include "spdlog/sinks/null_sink.h"
|
||||||
|
#include "spdlog/sinks/rotating_file_sink.h"
|
||||||
|
|
||||||
|
#if defined(SPDLOG_USE_STD_FORMAT)
|
||||||
|
#include <format>
|
||||||
|
#elif defined(SPDLOG_FMT_EXTERNAL)
|
||||||
|
#include <fmt/format.h>
|
||||||
|
#else
|
||||||
|
#include "spdlog/fmt/bundled/format.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include <atomic>
|
||||||
|
#include <cstdlib> // EXIT_FAILURE
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
void bench(int howmany, std::shared_ptr<spdlog::logger> log);
|
||||||
|
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, size_t thread_count);
|
||||||
|
|
||||||
|
// void bench_default_api(int howmany, std::shared_ptr<spdlog::logger> log);
|
||||||
|
// void bench_c_string(int howmany, std::shared_ptr<spdlog::logger> log);
|
||||||
|
|
||||||
|
static const size_t file_size = 30 * 1024 * 1024;
|
||||||
|
static const size_t rotating_files = 5;
|
||||||
|
static const int max_threads = 1000;
|
||||||
|
|
||||||
|
void bench_threaded_logging(size_t threads, int iters) {
|
||||||
|
spdlog::info("**************************************************************");
|
||||||
|
spdlog::info(spdlog::fmt_lib::format(
|
||||||
|
std::locale("en_US.UTF-8"), "Multi threaded: {:L} threads, {:L} messages", threads, iters));
|
||||||
|
spdlog::info("**************************************************************");
|
||||||
|
|
||||||
|
auto basic_mt = spdlog::basic_logger_mt("basic_mt", "logs/basic_mt.log", true);
|
||||||
|
bench_mt(iters, std::move(basic_mt), threads);
|
||||||
|
auto basic_mt_tracing =
|
||||||
|
spdlog::basic_logger_mt("basic_mt/backtrace-on", "logs/basic_mt.log", true);
|
||||||
|
basic_mt_tracing->enable_backtrace(32);
|
||||||
|
bench_mt(iters, std::move(basic_mt_tracing), threads);
|
||||||
|
|
||||||
|
spdlog::info("");
|
||||||
|
auto rotating_mt = spdlog::rotating_logger_mt("rotating_mt", "logs/rotating_mt.log", file_size,
|
||||||
|
rotating_files);
|
||||||
|
bench_mt(iters, std::move(rotating_mt), threads);
|
||||||
|
auto rotating_mt_tracing = spdlog::rotating_logger_mt(
|
||||||
|
"rotating_mt/backtrace-on", "logs/rotating_mt.log", file_size, rotating_files);
|
||||||
|
rotating_mt_tracing->enable_backtrace(32);
|
||||||
|
bench_mt(iters, std::move(rotating_mt_tracing), threads);
|
||||||
|
|
||||||
|
spdlog::info("");
|
||||||
|
auto daily_mt = spdlog::daily_logger_mt("daily_mt", "logs/daily_mt.log");
|
||||||
|
bench_mt(iters, std::move(daily_mt), threads);
|
||||||
|
auto daily_mt_tracing = spdlog::daily_logger_mt("daily_mt/backtrace-on", "logs/daily_mt.log");
|
||||||
|
daily_mt_tracing->enable_backtrace(32);
|
||||||
|
bench_mt(iters, std::move(daily_mt_tracing), threads);
|
||||||
|
|
||||||
|
spdlog::info("");
|
||||||
|
auto empty_logger = std::make_shared<spdlog::logger>("level-off");
|
||||||
|
empty_logger->set_level(spdlog::level::off);
|
||||||
|
bench(iters, empty_logger);
|
||||||
|
auto empty_logger_tracing = std::make_shared<spdlog::logger>("level-off/backtrace-on");
|
||||||
|
empty_logger_tracing->set_level(spdlog::level::off);
|
||||||
|
empty_logger_tracing->enable_backtrace(32);
|
||||||
|
bench(iters, empty_logger_tracing);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bench_single_threaded(int iters) {
|
||||||
|
spdlog::info("**************************************************************");
|
||||||
|
spdlog::info(
|
||||||
|
spdlog::fmt_lib::format(std::locale("en_US.UTF-8"), "Single threaded: {} messages", iters));
|
||||||
|
spdlog::info("**************************************************************");
|
||||||
|
|
||||||
|
auto basic_st = spdlog::basic_logger_st("basic_st", "logs/basic_st.log", true);
|
||||||
|
bench(iters, std::move(basic_st));
|
||||||
|
|
||||||
|
auto basic_st_tracing =
|
||||||
|
spdlog::basic_logger_st("basic_st/backtrace-on", "logs/basic_st.log", true);
|
||||||
|
bench(iters, std::move(basic_st_tracing));
|
||||||
|
|
||||||
|
spdlog::info("");
|
||||||
|
auto rotating_st = spdlog::rotating_logger_st("rotating_st", "logs/rotating_st.log", file_size,
|
||||||
|
rotating_files);
|
||||||
|
bench(iters, std::move(rotating_st));
|
||||||
|
auto rotating_st_tracing = spdlog::rotating_logger_st(
|
||||||
|
"rotating_st/backtrace-on", "logs/rotating_st.log", file_size, rotating_files);
|
||||||
|
rotating_st_tracing->enable_backtrace(32);
|
||||||
|
bench(iters, std::move(rotating_st_tracing));
|
||||||
|
|
||||||
|
spdlog::info("");
|
||||||
|
auto daily_st = spdlog::daily_logger_st("daily_st", "logs/daily_st.log");
|
||||||
|
bench(iters, std::move(daily_st));
|
||||||
|
auto daily_st_tracing = spdlog::daily_logger_st("daily_st/backtrace-on", "logs/daily_st.log");
|
||||||
|
daily_st_tracing->enable_backtrace(32);
|
||||||
|
bench(iters, std::move(daily_st_tracing));
|
||||||
|
|
||||||
|
spdlog::info("");
|
||||||
|
auto empty_logger = std::make_shared<spdlog::logger>("level-off");
|
||||||
|
empty_logger->set_level(spdlog::level::off);
|
||||||
|
bench(iters, empty_logger);
|
||||||
|
|
||||||
|
auto empty_logger_tracing = std::make_shared<spdlog::logger>("level-off/backtrace-on");
|
||||||
|
empty_logger_tracing->set_level(spdlog::level::off);
|
||||||
|
empty_logger_tracing->enable_backtrace(32);
|
||||||
|
bench(iters, empty_logger_tracing);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
spdlog::set_automatic_registration(false);
|
||||||
|
spdlog::default_logger()->set_pattern("[%^%l%$] %v");
|
||||||
|
int iters = 250000;
|
||||||
|
size_t threads = 4;
|
||||||
|
try {
|
||||||
|
if (argc > 1) {
|
||||||
|
iters = std::stoi(argv[1]);
|
||||||
|
}
|
||||||
|
if (argc > 2) {
|
||||||
|
threads = std::stoul(argv[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (threads > max_threads) {
|
||||||
|
throw std::runtime_error(
|
||||||
|
spdlog::fmt_lib::format("Number of threads exceeds maximum({})", max_threads));
|
||||||
|
}
|
||||||
|
|
||||||
|
bench_single_threaded(iters);
|
||||||
|
bench_threaded_logging(1, iters);
|
||||||
|
bench_threaded_logging(threads, iters);
|
||||||
|
} catch (std::exception &ex) {
|
||||||
|
spdlog::error(ex.what());
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bench(int howmany, std::shared_ptr<spdlog::logger> log) {
|
||||||
|
using std::chrono::duration;
|
||||||
|
using std::chrono::duration_cast;
|
||||||
|
using std::chrono::high_resolution_clock;
|
||||||
|
|
||||||
|
auto start = high_resolution_clock::now();
|
||||||
|
for (auto i = 0; i < howmany; ++i) {
|
||||||
|
log->info("Hello logger: msg number {}", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto delta = high_resolution_clock::now() - start;
|
||||||
|
auto delta_d = duration_cast<duration<double>>(delta).count();
|
||||||
|
|
||||||
|
spdlog::info(spdlog::fmt_lib::format(std::locale("en_US.UTF-8"),
|
||||||
|
"{:<30} Elapsed: {:0.2f} secs {:>16L}/sec", log->name(),
|
||||||
|
delta_d, size_t(howmany / delta_d)));
|
||||||
|
spdlog::drop(log->name());
|
||||||
|
}
|
||||||
|
|
||||||
|
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, size_t thread_count) {
|
||||||
|
using std::chrono::duration;
|
||||||
|
using std::chrono::duration_cast;
|
||||||
|
using std::chrono::high_resolution_clock;
|
||||||
|
|
||||||
|
std::vector<std::thread> threads;
|
||||||
|
threads.reserve(thread_count);
|
||||||
|
auto start = high_resolution_clock::now();
|
||||||
|
for (size_t t = 0; t < thread_count; ++t) {
|
||||||
|
threads.emplace_back([&]() {
|
||||||
|
for (int j = 0; j < howmany / static_cast<int>(thread_count); j++) {
|
||||||
|
log->info("Hello logger: msg number {}", j);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &t : threads) {
|
||||||
|
t.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto delta = high_resolution_clock::now() - start;
|
||||||
|
auto delta_d = duration_cast<duration<double>>(delta).count();
|
||||||
|
spdlog::info(spdlog::fmt_lib::format(std::locale("en_US.UTF-8"),
|
||||||
|
"{:<30} Elapsed: {:0.2f} secs {:>16L}/sec", log->name(),
|
||||||
|
delta_d, size_t(howmany / delta_d)));
|
||||||
|
spdlog::drop(log->name());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void bench_default_api(int howmany, std::shared_ptr<spdlog::logger> log)
|
||||||
|
{
|
||||||
|
using std::chrono::high_resolution_clock;
|
||||||
|
using std::chrono::duration;
|
||||||
|
using std::chrono::duration_cast;
|
||||||
|
|
||||||
|
auto orig_default = spdlog::default_logger();
|
||||||
|
spdlog::set_default_logger(log);
|
||||||
|
auto start = high_resolution_clock::now();
|
||||||
|
for (auto i = 0; i < howmany; ++i)
|
||||||
|
{
|
||||||
|
spdlog::info("Hello logger: msg number {}", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto delta = high_resolution_clock::now() - start;
|
||||||
|
auto delta_d = duration_cast<duration<double>>(delta).count();
|
||||||
|
spdlog::drop(log->name());
|
||||||
|
spdlog::set_default_logger(std::move(orig_default));
|
||||||
|
spdlog::info("{:<30} Elapsed: {:0.2f} secs {:>16}/sec", log->name(), delta_d, int(howmany /
|
||||||
|
delta_d));
|
||||||
|
}
|
||||||
|
|
||||||
|
void bench_c_string(int howmany, std::shared_ptr<spdlog::logger> log)
|
||||||
|
{
|
||||||
|
using std::chrono::high_resolution_clock;
|
||||||
|
using std::chrono::duration;
|
||||||
|
using std::chrono::duration_cast;
|
||||||
|
|
||||||
|
const char *msg = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pharetra
|
||||||
|
metus cursus " "lacus placerat congue. Nulla egestas, mauris a tincidunt tempus, enim lectus
|
||||||
|
volutpat mi, eu consequat sem " "libero nec massa. In dapibus ipsum a diam rhoncus gravida. Etiam
|
||||||
|
non dapibus eros. Donec fringilla dui sed " "augue pretium, nec scelerisque est maximus. Nullam
|
||||||
|
convallis, sem nec blandit maximus, nisi turpis ornare " "nisl, sit amet volutpat neque massa eu
|
||||||
|
odio. Maecenas malesuada quam ex, posuere congue nibh turpis duis.";
|
||||||
|
|
||||||
|
auto orig_default = spdlog::default_logger();
|
||||||
|
spdlog::set_default_logger(log);
|
||||||
|
auto start = high_resolution_clock::now();
|
||||||
|
for (auto i = 0; i < howmany; ++i)
|
||||||
|
{
|
||||||
|
spdlog::log(spdlog::level::info, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto delta = high_resolution_clock::now() - start;
|
||||||
|
auto delta_d = duration_cast<duration<double>>(delta).count();
|
||||||
|
spdlog::drop(log->name());
|
||||||
|
spdlog::set_default_logger(std::move(orig_default));
|
||||||
|
spdlog::info("{:<30} Elapsed: {:0.2f} secs {:>16}/sec", log->name(), delta_d, int(howmany /
|
||||||
|
delta_d));
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
@ -1,84 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <vector>
|
|
||||||
#include <atomic>
|
|
||||||
|
|
||||||
#include <boost/log/core.hpp>
|
|
||||||
#include <boost/log/trivial.hpp>
|
|
||||||
#include <boost/log/expressions.hpp>
|
|
||||||
#include <boost/log/sinks/text_file_backend.hpp>
|
|
||||||
#include <boost/log/utility/setup/file.hpp>
|
|
||||||
#include <boost/log/utility/setup/common_attributes.hpp>
|
|
||||||
#include <boost/log/sources/severity_logger.hpp>
|
|
||||||
#include <boost/log/sources/record_ostream.hpp>
|
|
||||||
|
|
||||||
namespace logging = boost::log;
|
|
||||||
namespace src = boost::log::sources;
|
|
||||||
namespace sinks = boost::log::sinks;
|
|
||||||
namespace keywords = boost::log::keywords;
|
|
||||||
|
|
||||||
void init()
|
|
||||||
{
|
|
||||||
logging::add_file_log
|
|
||||||
(
|
|
||||||
keywords::file_name = "logs/boost-sample_%N.log", /*< file name pattern >*/
|
|
||||||
keywords::auto_flush = false,
|
|
||||||
keywords::format = "[%TimeStamp%]: %Message%"
|
|
||||||
);
|
|
||||||
|
|
||||||
logging::core::get()->set_filter
|
|
||||||
(
|
|
||||||
logging::trivial::severity >= logging::trivial::info
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
int thread_count = 10;
|
|
||||||
if(argc > 1)
|
|
||||||
thread_count = atoi(argv[1]);
|
|
||||||
|
|
||||||
int howmany = 1000000;
|
|
||||||
|
|
||||||
|
|
||||||
init();
|
|
||||||
logging::add_common_attributes();
|
|
||||||
|
|
||||||
|
|
||||||
using namespace logging::trivial;
|
|
||||||
|
|
||||||
src::severity_logger_mt< severity_level > lg;
|
|
||||||
|
|
||||||
std::atomic<int > msg_counter {0};
|
|
||||||
vector<thread> threads;
|
|
||||||
|
|
||||||
for (int t = 0; t < thread_count; ++t)
|
|
||||||
{
|
|
||||||
threads.push_back(std::thread([&]()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
int counter = ++msg_counter;
|
|
||||||
if (counter > howmany) break;
|
|
||||||
BOOST_LOG_SEV(lg, info) << "boost message #" << counter << ": This is some text for your pleasure";
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for(auto &t:threads)
|
|
||||||
{
|
|
||||||
t.join();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
#include <boost/log/core.hpp>
|
|
||||||
#include <boost/log/trivial.hpp>
|
|
||||||
#include <boost/log/expressions.hpp>
|
|
||||||
#include <boost/log/sinks/text_file_backend.hpp>
|
|
||||||
#include <boost/log/utility/setup/file.hpp>
|
|
||||||
#include <boost/log/utility/setup/common_attributes.hpp>
|
|
||||||
#include <boost/log/sources/severity_logger.hpp>
|
|
||||||
#include <boost/log/sources/record_ostream.hpp>
|
|
||||||
|
|
||||||
namespace logging = boost::log;
|
|
||||||
namespace src = boost::log::sources;
|
|
||||||
namespace sinks = boost::log::sinks;
|
|
||||||
namespace keywords = boost::log::keywords;
|
|
||||||
|
|
||||||
void init()
|
|
||||||
{
|
|
||||||
logging::add_file_log
|
|
||||||
(
|
|
||||||
keywords::file_name = "logs/boost-sample_%N.log", /*< file name pattern >*/
|
|
||||||
keywords::auto_flush = false,
|
|
||||||
keywords::format = "[%TimeStamp%]: %Message%"
|
|
||||||
);
|
|
||||||
|
|
||||||
logging::core::get()->set_filter
|
|
||||||
(
|
|
||||||
logging::trivial::severity >= logging::trivial::info
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* [])
|
|
||||||
{
|
|
||||||
int howmany = 1000000;
|
|
||||||
init();
|
|
||||||
logging::add_common_attributes();
|
|
||||||
|
|
||||||
using namespace logging::trivial;
|
|
||||||
src::severity_logger_mt< severity_level > lg;
|
|
||||||
for(int i = 0 ; i < howmany; ++i)
|
|
||||||
BOOST_LOG_SEV(lg, info) << "boost message #" << i << ": This is some text for your pleasure";
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
* GLOBAL:
|
|
||||||
FORMAT = "[%datetime]: %msg"
|
|
||||||
FILENAME = ./logs/easylogging.log
|
|
||||||
ENABLED = true
|
|
||||||
TO_FILE = true
|
|
||||||
TO_STANDARD_OUTPUT = false
|
|
||||||
MILLISECONDS_WIDTH = 3
|
|
||||||
PERFORMANCE_TRACKING = false
|
|
||||||
MAX_LOG_FILE_SIZE = 10485760
|
|
||||||
Log_Flush_Threshold = 10485760
|
|
@ -1,52 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <vector>
|
|
||||||
#include <atomic>
|
|
||||||
|
|
||||||
#define _ELPP_THREAD_SAFE
|
|
||||||
#include "easylogging++.h"
|
|
||||||
_INITIALIZE_EASYLOGGINGPP
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
|
|
||||||
int thread_count = 10;
|
|
||||||
if(argc > 1)
|
|
||||||
thread_count = atoi(argv[1]);
|
|
||||||
|
|
||||||
int howmany = 1000000;
|
|
||||||
|
|
||||||
// Load configuration from file
|
|
||||||
el::Configurations conf("easyl.conf");
|
|
||||||
el::Loggers::reconfigureLogger("default", conf);
|
|
||||||
|
|
||||||
std::atomic<int > msg_counter {0};
|
|
||||||
vector<thread> threads;
|
|
||||||
|
|
||||||
for (int t = 0; t < thread_count; ++t)
|
|
||||||
{
|
|
||||||
threads.push_back(std::thread([&]()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
int counter = ++msg_counter;
|
|
||||||
if (counter > howmany) break;
|
|
||||||
LOG(INFO) << "easylog message #" << counter << ": This is some text for your pleasure";
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for(auto &t:threads)
|
|
||||||
{
|
|
||||||
t.join();
|
|
||||||
};
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
#include "easylogging++.h"
|
|
||||||
|
|
||||||
_INITIALIZE_EASYLOGGINGPP
|
|
||||||
|
|
||||||
int main(int, char* [])
|
|
||||||
{
|
|
||||||
int howmany = 1000000;
|
|
||||||
|
|
||||||
// Load configuration from file
|
|
||||||
el::Configurations conf("easyl.conf");
|
|
||||||
el::Loggers::reconfigureLogger("default", conf);
|
|
||||||
|
|
||||||
for(int i = 0 ; i < howmany; ++i)
|
|
||||||
LOG(INFO) << "easylog message #" << i << ": This is some text for your pleasure";
|
|
||||||
return 0;
|
|
||||||
}
|
|
71
bench/formatter-bench.cpp
Normal file
71
bench/formatter-bench.cpp
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
//
|
||||||
|
// Copyright(c) 2018 Gabi Melman.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "benchmark/benchmark.h"
|
||||||
|
|
||||||
|
#include "spdlog/spdlog.h"
|
||||||
|
#include "spdlog/pattern_formatter.h"
|
||||||
|
|
||||||
|
void bench_formatter(benchmark::State &state, std::string pattern) {
|
||||||
|
auto formatter = spdlog::details::make_unique<spdlog::pattern_formatter>(pattern);
|
||||||
|
spdlog::memory_buf_t dest;
|
||||||
|
std::string logger_name = "logger-name";
|
||||||
|
const char *text =
|
||||||
|
"Hello. This is some message with length of 80 ";
|
||||||
|
|
||||||
|
spdlog::source_loc source_loc{"a/b/c/d/myfile.cpp", 123, "some_func()"};
|
||||||
|
spdlog::details::log_msg msg(source_loc, logger_name, spdlog::level::info, text);
|
||||||
|
|
||||||
|
for (auto _ : state) {
|
||||||
|
dest.clear();
|
||||||
|
formatter->format(msg, dest);
|
||||||
|
benchmark::DoNotOptimize(dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bench_formatters() {
|
||||||
|
// basic patterns(single flag)
|
||||||
|
std::string all_flags = "+vtPnlLaAbBcCYDmdHIMSefFprRTXzEisg@luioO%";
|
||||||
|
std::vector<std::string> basic_patterns;
|
||||||
|
for (auto &flag : all_flags) {
|
||||||
|
auto pattern = std::string("%") + flag;
|
||||||
|
benchmark::RegisterBenchmark(pattern.c_str(), &bench_formatter, pattern);
|
||||||
|
|
||||||
|
// pattern = std::string("%16") + flag;
|
||||||
|
// benchmark::RegisterBenchmark(pattern.c_str(), &bench_formatter, pattern);
|
||||||
|
//
|
||||||
|
// // bench center padding
|
||||||
|
// pattern = std::string("%=16") + flag;
|
||||||
|
// benchmark::RegisterBenchmark(pattern.c_str(), &bench_formatter, pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
// complex patterns
|
||||||
|
std::vector<std::string> patterns = {
|
||||||
|
"[%D %X] [%l] [%n] %v",
|
||||||
|
"[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] %v",
|
||||||
|
"[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] [%t] %v",
|
||||||
|
};
|
||||||
|
for (auto &pattern : patterns) {
|
||||||
|
benchmark::RegisterBenchmark(pattern.c_str(), &bench_formatter, pattern)
|
||||||
|
->Iterations(2500000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
spdlog::set_pattern("[%^%l%$] %v");
|
||||||
|
if (argc != 2) {
|
||||||
|
spdlog::error("Usage: {} <pattern> (or \"all\" to bench all)", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string pattern = argv[1];
|
||||||
|
if (pattern == "all") {
|
||||||
|
bench_formatters();
|
||||||
|
} else {
|
||||||
|
benchmark::RegisterBenchmark(pattern.c_str(), &bench_formatter, pattern);
|
||||||
|
}
|
||||||
|
benchmark::Initialize(&argc, argv);
|
||||||
|
benchmark::RunSpecifiedBenchmarks();
|
||||||
|
}
|
@ -1,62 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <vector>
|
|
||||||
#include <atomic>
|
|
||||||
#include <iostream>
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
#include "g2logworker.h"
|
|
||||||
#include "g2log.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
template<typename T> std::string format(const T& value);
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
using namespace std::chrono;
|
|
||||||
using clock=steady_clock;
|
|
||||||
int thread_count = 10;
|
|
||||||
|
|
||||||
if(argc > 1)
|
|
||||||
thread_count = atoi(argv[1]);
|
|
||||||
int howmany = 1000000;
|
|
||||||
|
|
||||||
g2LogWorker g2log(argv[0], "logs");
|
|
||||||
g2::initializeLogging(&g2log);
|
|
||||||
|
|
||||||
|
|
||||||
std::atomic<int > msg_counter {0};
|
|
||||||
vector<thread> threads;
|
|
||||||
auto start = clock::now();
|
|
||||||
for (int t = 0; t < thread_count; ++t)
|
|
||||||
{
|
|
||||||
threads.push_back(std::thread([&]()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
int counter = ++msg_counter;
|
|
||||||
if (counter > howmany) break;
|
|
||||||
LOG(INFO) << "g2log message #" << counter << ": This is some text for your pleasure";
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for(auto &t:threads)
|
|
||||||
{
|
|
||||||
t.join();
|
|
||||||
};
|
|
||||||
|
|
||||||
duration<float> delta = clock::now() - start;
|
|
||||||
float deltaf = delta.count();
|
|
||||||
auto rate = howmany/deltaf;
|
|
||||||
|
|
||||||
cout << "Total: " << howmany << std::endl;
|
|
||||||
cout << "Threads: " << thread_count << std::endl;
|
|
||||||
std::cout << "Delta = " << deltaf << " seconds" << std::endl;
|
|
||||||
std::cout << "Rate = " << rate << "/sec" << std::endl;
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <vector>
|
|
||||||
#include <atomic>
|
|
||||||
|
|
||||||
#include "glog/logging.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
|
|
||||||
int thread_count = 10;
|
|
||||||
if(argc > 1)
|
|
||||||
thread_count = atoi(argv[1]);
|
|
||||||
|
|
||||||
int howmany = 1000000;
|
|
||||||
|
|
||||||
FLAGS_logtostderr = 0;
|
|
||||||
FLAGS_log_dir = "logs";
|
|
||||||
google::InitGoogleLogging(argv[0]);
|
|
||||||
|
|
||||||
std::atomic<int > msg_counter {0};
|
|
||||||
vector<thread> threads;
|
|
||||||
|
|
||||||
for (int t = 0; t < thread_count; ++t)
|
|
||||||
{
|
|
||||||
threads.push_back(std::thread([&]()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
int counter = ++msg_counter;
|
|
||||||
if (counter > howmany) break;
|
|
||||||
LOG(INFO) << "glog message #" << counter << ": This is some text for your pleasure";
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for(auto &t:threads)
|
|
||||||
{
|
|
||||||
t.join();
|
|
||||||
};
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "glog/logging.h"
|
|
||||||
|
|
||||||
|
|
||||||
int main(int, char* argv[])
|
|
||||||
{
|
|
||||||
int howmany = 1000000;
|
|
||||||
|
|
||||||
|
|
||||||
FLAGS_logtostderr = 0;
|
|
||||||
FLAGS_log_dir = "logs";
|
|
||||||
google::InitGoogleLogging(argv[0]);
|
|
||||||
for(int i = 0 ; i < howmany; ++i)
|
|
||||||
LOG(INFO) << "glog message # " << i << ": This is some text for your pleasure";
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
220
bench/latency.cpp
Normal file
220
bench/latency.cpp
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
//
|
||||||
|
// Copyright(c) 2018 Gabi Melman.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// latency.cpp : spdlog latency benchmarks
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "benchmark/benchmark.h"
|
||||||
|
|
||||||
|
#include "spdlog/spdlog.h"
|
||||||
|
#include "spdlog/async.h"
|
||||||
|
#include "spdlog/sinks/basic_file_sink.h"
|
||||||
|
#include "spdlog/sinks/daily_file_sink.h"
|
||||||
|
#include "spdlog/sinks/null_sink.h"
|
||||||
|
#include "spdlog/sinks/rotating_file_sink.h"
|
||||||
|
|
||||||
|
void bench_c_string(benchmark::State &state, std::shared_ptr<spdlog::logger> logger) {
|
||||||
|
const char *msg =
|
||||||
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pharetra metus cursus "
|
||||||
|
"lacus placerat congue. Nulla egestas, mauris a tincidunt tempus, enim lectus volutpat mi, "
|
||||||
|
"eu consequat sem "
|
||||||
|
"libero nec massa. In dapibus ipsum a diam rhoncus gravida. Etiam non dapibus eros. Donec "
|
||||||
|
"fringilla dui sed "
|
||||||
|
"augue pretium, nec scelerisque est maximus. Nullam convallis, sem nec blandit maximus, "
|
||||||
|
"nisi turpis ornare "
|
||||||
|
"nisl, sit amet volutpat neque massa eu odio. Maecenas malesuada quam ex, posuere congue "
|
||||||
|
"nibh turpis duis.";
|
||||||
|
|
||||||
|
for (auto _ : state) {
|
||||||
|
logger->info(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bench_logger(benchmark::State &state, std::shared_ptr<spdlog::logger> logger) {
|
||||||
|
int i = 0;
|
||||||
|
for (auto _ : state) {
|
||||||
|
logger->info("Hello logger: msg number {}...............", ++i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void bench_global_logger(benchmark::State &state, std::shared_ptr<spdlog::logger> logger) {
|
||||||
|
spdlog::set_default_logger(std::move(logger));
|
||||||
|
int i = 0;
|
||||||
|
for (auto _ : state) {
|
||||||
|
spdlog::info("Hello logger: msg number {}...............", ++i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bench_disabled_macro(benchmark::State &state, std::shared_ptr<spdlog::logger> logger) {
|
||||||
|
int i = 0;
|
||||||
|
benchmark::DoNotOptimize(i); // prevent unused warnings
|
||||||
|
benchmark::DoNotOptimize(logger); // prevent unused warnings
|
||||||
|
for (auto _ : state) {
|
||||||
|
SPDLOG_LOGGER_DEBUG(logger, "Hello logger: msg number {}...............", i++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bench_disabled_macro_global_logger(benchmark::State &state,
|
||||||
|
std::shared_ptr<spdlog::logger> logger) {
|
||||||
|
spdlog::set_default_logger(std::move(logger));
|
||||||
|
int i = 0;
|
||||||
|
benchmark::DoNotOptimize(i); // prevent unused warnings
|
||||||
|
benchmark::DoNotOptimize(logger); // prevent unused warnings
|
||||||
|
for (auto _ : state) {
|
||||||
|
SPDLOG_DEBUG("Hello logger: msg number {}...............", i++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
void bench_dev_null() {
|
||||||
|
auto dev_null_st = spdlog::basic_logger_st("/dev/null_st", "/dev/null");
|
||||||
|
benchmark::RegisterBenchmark("/dev/null_st", bench_logger, std::move(dev_null_st))
|
||||||
|
->UseRealTime();
|
||||||
|
spdlog::drop("/dev/null_st");
|
||||||
|
|
||||||
|
auto dev_null_mt = spdlog::basic_logger_mt("/dev/null_mt", "/dev/null");
|
||||||
|
benchmark::RegisterBenchmark("/dev/null_mt", bench_logger, std::move(dev_null_mt))
|
||||||
|
->UseRealTime();
|
||||||
|
spdlog::drop("/dev/null_mt");
|
||||||
|
}
|
||||||
|
#endif // __linux__
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
using spdlog::sinks::null_sink_mt;
|
||||||
|
using spdlog::sinks::null_sink_st;
|
||||||
|
|
||||||
|
size_t file_size = 30 * 1024 * 1024;
|
||||||
|
size_t rotating_files = 5;
|
||||||
|
int n_threads = benchmark::CPUInfo::Get().num_cpus;
|
||||||
|
|
||||||
|
auto full_bench = argc > 1 && std::string(argv[1]) == "full";
|
||||||
|
|
||||||
|
// disabled loggers
|
||||||
|
auto disabled_logger =
|
||||||
|
std::make_shared<spdlog::logger>("bench", std::make_shared<null_sink_mt>());
|
||||||
|
disabled_logger->set_level(spdlog::level::off);
|
||||||
|
benchmark::RegisterBenchmark("disabled-at-compile-time", bench_disabled_macro, disabled_logger);
|
||||||
|
benchmark::RegisterBenchmark("disabled-at-compile-time (global logger)",
|
||||||
|
bench_disabled_macro_global_logger, disabled_logger);
|
||||||
|
benchmark::RegisterBenchmark("disabled-at-runtime", bench_logger, disabled_logger);
|
||||||
|
benchmark::RegisterBenchmark("disabled-at-runtime (global logger)", bench_global_logger,
|
||||||
|
disabled_logger);
|
||||||
|
// with backtrace of 64
|
||||||
|
auto tracing_disabled_logger =
|
||||||
|
std::make_shared<spdlog::logger>("bench", std::make_shared<null_sink_mt>());
|
||||||
|
tracing_disabled_logger->enable_backtrace(64);
|
||||||
|
benchmark::RegisterBenchmark("disabled-at-runtime/backtrace", bench_logger,
|
||||||
|
tracing_disabled_logger);
|
||||||
|
|
||||||
|
auto null_logger_st =
|
||||||
|
std::make_shared<spdlog::logger>("bench", std::make_shared<null_sink_st>());
|
||||||
|
benchmark::RegisterBenchmark("null_sink_st (500_bytes c_str)", bench_c_string,
|
||||||
|
std::move(null_logger_st));
|
||||||
|
benchmark::RegisterBenchmark("null_sink_st", bench_logger, null_logger_st);
|
||||||
|
benchmark::RegisterBenchmark("null_sink_st (global logger)", bench_global_logger,
|
||||||
|
null_logger_st);
|
||||||
|
// with backtrace of 64
|
||||||
|
auto tracing_null_logger_st =
|
||||||
|
std::make_shared<spdlog::logger>("bench", std::make_shared<null_sink_st>());
|
||||||
|
tracing_null_logger_st->enable_backtrace(64);
|
||||||
|
benchmark::RegisterBenchmark("null_sink_st/backtrace", bench_logger, tracing_null_logger_st);
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
bench_dev_null();
|
||||||
|
#endif // __linux__
|
||||||
|
|
||||||
|
if (full_bench) {
|
||||||
|
// basic_st
|
||||||
|
auto basic_st = spdlog::basic_logger_st("basic_st", "latency_logs/basic_st.log", true);
|
||||||
|
benchmark::RegisterBenchmark("basic_st", bench_logger, std::move(basic_st))->UseRealTime();
|
||||||
|
spdlog::drop("basic_st");
|
||||||
|
// with backtrace of 64
|
||||||
|
auto tracing_basic_st =
|
||||||
|
spdlog::basic_logger_st("tracing_basic_st", "latency_logs/tracing_basic_st.log", true);
|
||||||
|
tracing_basic_st->enable_backtrace(64);
|
||||||
|
benchmark::RegisterBenchmark("basic_st/backtrace", bench_logger,
|
||||||
|
std::move(tracing_basic_st))
|
||||||
|
->UseRealTime();
|
||||||
|
spdlog::drop("tracing_basic_st");
|
||||||
|
|
||||||
|
// rotating st
|
||||||
|
auto rotating_st = spdlog::rotating_logger_st("rotating_st", "latency_logs/rotating_st.log",
|
||||||
|
file_size, rotating_files);
|
||||||
|
benchmark::RegisterBenchmark("rotating_st", bench_logger, std::move(rotating_st))
|
||||||
|
->UseRealTime();
|
||||||
|
spdlog::drop("rotating_st");
|
||||||
|
// with backtrace of 64
|
||||||
|
auto tracing_rotating_st = spdlog::rotating_logger_st(
|
||||||
|
"tracing_rotating_st", "latency_logs/tracing_rotating_st.log", file_size,
|
||||||
|
rotating_files);
|
||||||
|
benchmark::RegisterBenchmark("rotating_st/backtrace", bench_logger,
|
||||||
|
std::move(tracing_rotating_st))
|
||||||
|
->UseRealTime();
|
||||||
|
spdlog::drop("tracing_rotating_st");
|
||||||
|
|
||||||
|
// daily st
|
||||||
|
auto daily_st = spdlog::daily_logger_mt("daily_st", "latency_logs/daily_st.log");
|
||||||
|
benchmark::RegisterBenchmark("daily_st", bench_logger, std::move(daily_st))->UseRealTime();
|
||||||
|
spdlog::drop("daily_st");
|
||||||
|
auto tracing_daily_st =
|
||||||
|
spdlog::daily_logger_mt("tracing_daily_st", "latency_logs/daily_st.log");
|
||||||
|
benchmark::RegisterBenchmark("daily_st/backtrace", bench_logger,
|
||||||
|
std::move(tracing_daily_st))
|
||||||
|
->UseRealTime();
|
||||||
|
spdlog::drop("tracing_daily_st");
|
||||||
|
|
||||||
|
//
|
||||||
|
// Multi threaded bench, 10 loggers using same logger concurrently
|
||||||
|
//
|
||||||
|
auto null_logger_mt =
|
||||||
|
std::make_shared<spdlog::logger>("bench", std::make_shared<null_sink_mt>());
|
||||||
|
benchmark::RegisterBenchmark("null_sink_mt", bench_logger, null_logger_mt)
|
||||||
|
->Threads(n_threads)
|
||||||
|
->UseRealTime();
|
||||||
|
|
||||||
|
// basic_mt
|
||||||
|
auto basic_mt = spdlog::basic_logger_mt("basic_mt", "latency_logs/basic_mt.log", true);
|
||||||
|
benchmark::RegisterBenchmark("basic_mt", bench_logger, std::move(basic_mt))
|
||||||
|
->Threads(n_threads)
|
||||||
|
->UseRealTime();
|
||||||
|
spdlog::drop("basic_mt");
|
||||||
|
|
||||||
|
// rotating mt
|
||||||
|
auto rotating_mt = spdlog::rotating_logger_mt("rotating_mt", "latency_logs/rotating_mt.log",
|
||||||
|
file_size, rotating_files);
|
||||||
|
benchmark::RegisterBenchmark("rotating_mt", bench_logger, std::move(rotating_mt))
|
||||||
|
->Threads(n_threads)
|
||||||
|
->UseRealTime();
|
||||||
|
spdlog::drop("rotating_mt");
|
||||||
|
|
||||||
|
// daily mt
|
||||||
|
auto daily_mt = spdlog::daily_logger_mt("daily_mt", "latency_logs/daily_mt.log");
|
||||||
|
benchmark::RegisterBenchmark("daily_mt", bench_logger, std::move(daily_mt))
|
||||||
|
->Threads(n_threads)
|
||||||
|
->UseRealTime();
|
||||||
|
spdlog::drop("daily_mt");
|
||||||
|
}
|
||||||
|
|
||||||
|
// async
|
||||||
|
auto queue_size = 1024 * 1024 * 3;
|
||||||
|
auto tp = std::make_shared<spdlog::details::thread_pool>(queue_size, 1);
|
||||||
|
auto async_logger = std::make_shared<spdlog::async_logger>(
|
||||||
|
"async_logger", std::make_shared<null_sink_mt>(), std::move(tp),
|
||||||
|
spdlog::async_overflow_policy::overrun_oldest);
|
||||||
|
benchmark::RegisterBenchmark("async_logger", bench_logger, async_logger)
|
||||||
|
->Threads(n_threads)
|
||||||
|
->UseRealTime();
|
||||||
|
|
||||||
|
auto async_logger_tracing = std::make_shared<spdlog::async_logger>(
|
||||||
|
"async_logger_tracing", std::make_shared<null_sink_mt>(), std::move(tp),
|
||||||
|
spdlog::async_overflow_policy::overrun_oldest);
|
||||||
|
async_logger_tracing->enable_backtrace(32);
|
||||||
|
benchmark::RegisterBenchmark("async_logger/tracing", bench_logger, async_logger_tracing)
|
||||||
|
->Threads(n_threads)
|
||||||
|
->UseRealTime();
|
||||||
|
|
||||||
|
benchmark::Initialize(&argc, argv);
|
||||||
|
benchmark::RunSpecifiedBenchmarks();
|
||||||
|
}
|
@ -1,32 +0,0 @@
|
|||||||
CXX ?= g++
|
|
||||||
CXXFLAGS = -march=native -Wall -std=c++11 -pthread
|
|
||||||
CXX_RELEASE_FLAGS = -O2 -DNDEBUG
|
|
||||||
|
|
||||||
|
|
||||||
binaries=spdlog-latency g3log-latency g3log-crush
|
|
||||||
|
|
||||||
all: $(binaries)
|
|
||||||
|
|
||||||
spdlog-latency: spdlog-latency.cpp
|
|
||||||
$(CXX) spdlog-latency.cpp -o spdlog-latency $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -I../../include
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
g3log-latency: g3log-latency.cpp
|
|
||||||
$(CXX) g3log-latency.cpp -o g3log-latency $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -I../../../g3log/src -L. -lg3logger
|
|
||||||
|
|
||||||
|
|
||||||
g3log-crush: g3log-crush.cpp
|
|
||||||
$(CXX) g3log-crush.cpp -o g3log-crush $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -I../../../g3log/src -L. -lg3logger
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o *.log $(binaries)
|
|
||||||
|
|
||||||
|
|
||||||
rebuild: clean all
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
echo "running spdlog and g3log tests 10 time with ${1:-10} threads each (total 1,000,000 entries).."
|
|
||||||
rm -f *.log
|
|
||||||
for i in {1..10}
|
|
||||||
|
|
||||||
do
|
|
||||||
echo
|
|
||||||
sleep 0.5
|
|
||||||
./spdlog-latency ${1:-10} 2>/dev/null || exit
|
|
||||||
sleep 0.5
|
|
||||||
./g3log-latency ${1:-10} 2>/dev/null || exit
|
|
||||||
|
|
||||||
done
|
|
@ -1,37 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <g3log/g3log.hpp>
|
|
||||||
#include <g3log/logworker.hpp>
|
|
||||||
|
|
||||||
void CrusherLoop()
|
|
||||||
{
|
|
||||||
size_t counter = 0;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
LOGF(INFO, "Some text to crush you machine. thread:");
|
|
||||||
if(++counter % 1000000 == 0)
|
|
||||||
{
|
|
||||||
std::cout << "Wrote " << counter << " entries" << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
std::cout << "WARNING: This test will exaust all your machine memory and will crush it!" << std::endl;
|
|
||||||
std::cout << "Are you sure you want to continue ? " << std::endl;
|
|
||||||
char c;
|
|
||||||
std::cin >> c;
|
|
||||||
if (toupper( c ) != 'Y')
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
auto worker = g3::LogWorker::createLogWorker();
|
|
||||||
auto handle= worker->addDefaultLogger(argv[0], "g3log.txt");
|
|
||||||
g3::initializeLogging(worker.get());
|
|
||||||
CrusherLoop();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
|||||||
#include <thread>
|
|
||||||
#include <vector>
|
|
||||||
#include <atomic>
|
|
||||||
#include <iostream>
|
|
||||||
#include <chrono>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <map>
|
|
||||||
#include <numeric>
|
|
||||||
#include <functional>
|
|
||||||
#include <thread>
|
|
||||||
#include "utils.h"
|
|
||||||
#include <g3log/g3log.hpp>
|
|
||||||
#include <g3log/logworker.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
const uint64_t g_iterations = 1000000;
|
|
||||||
|
|
||||||
|
|
||||||
std::atomic<size_t> g_counter = {0};
|
|
||||||
|
|
||||||
|
|
||||||
void MeasurePeakDuringLogWrites(const size_t id, std::vector<uint64_t>& result)
|
|
||||||
{
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
const size_t value_now = ++g_counter;
|
|
||||||
if (value_now > g_iterations)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto start_time = std::chrono::high_resolution_clock::now();
|
|
||||||
LOGF(INFO, "Some text to log for thread: %ld", id);
|
|
||||||
auto stop_time = std::chrono::high_resolution_clock::now();
|
|
||||||
uint64_t time_us = std::chrono::duration_cast<std::chrono::microseconds>(stop_time - start_time).count();
|
|
||||||
result.push_back(time_us);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PrintResults(const std::map<size_t, std::vector<uint64_t>>& threads_result, size_t total_us)
|
|
||||||
{
|
|
||||||
|
|
||||||
std::vector<uint64_t> all_measurements;
|
|
||||||
all_measurements.reserve(g_iterations);
|
|
||||||
for (auto& t_result : threads_result)
|
|
||||||
{
|
|
||||||
all_measurements.insert(all_measurements.end(), t_result.second.begin(), t_result.second.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
// calc worst latenct
|
|
||||||
auto worst = *std::max_element(all_measurements.begin(), all_measurements.end());
|
|
||||||
|
|
||||||
// calc avg
|
|
||||||
auto total = accumulate(begin(all_measurements), end(all_measurements), 0, std::plus<uint64_t>());
|
|
||||||
auto avg = double(total)/all_measurements.size();
|
|
||||||
|
|
||||||
std::cout << "[g3log] worst: " << std::setw(10) << std::right << worst << "\tAvg: " << avg << "\tTotal: " << utils::format(total_us) << " us" << std::endl;
|
|
||||||
|
|
||||||
}
|
|
||||||
}// anonymous
|
|
||||||
|
|
||||||
|
|
||||||
// The purpose of this test is NOT to see how fast
|
|
||||||
// each thread can possibly write. It is to see what
|
|
||||||
// the worst latency is for writing a log entry
|
|
||||||
//
|
|
||||||
// In the test 1 million log entries will be written
|
|
||||||
// an atomic counter is used to give each thread what
|
|
||||||
// it is to write next. The overhead of atomic
|
|
||||||
// synchronization between the threads are not counted in the worst case latency
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
size_t number_of_threads {0};
|
|
||||||
if (argc == 2)
|
|
||||||
{
|
|
||||||
number_of_threads = atoi(argv[1]);
|
|
||||||
}
|
|
||||||
if (argc != 2 || number_of_threads == 0)
|
|
||||||
{
|
|
||||||
std::cerr << "USAGE is: " << argv[0] << " number_threads" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::thread> threads(number_of_threads);
|
|
||||||
std::map<size_t, std::vector<uint64_t>> threads_result;
|
|
||||||
|
|
||||||
for (size_t idx = 0; idx < number_of_threads; ++idx)
|
|
||||||
{
|
|
||||||
// reserve to 1 million for all the result
|
|
||||||
// it's a test so let's not care about the wasted space
|
|
||||||
threads_result[idx].reserve(g_iterations);
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string g_path = "./" ;
|
|
||||||
const std::string g_prefix_log_name = "g3log-performance-";
|
|
||||||
const std::string g_measurement_dump = g_path + g_prefix_log_name + "_RESULT.txt";
|
|
||||||
|
|
||||||
auto worker = g3::LogWorker::createLogWorker();
|
|
||||||
auto handle= worker->addDefaultLogger(argv[0], "g3log.txt");
|
|
||||||
g3::initializeLogging(worker.get());
|
|
||||||
|
|
||||||
auto start_time_application_total = std::chrono::high_resolution_clock::now();
|
|
||||||
for (uint64_t idx = 0; idx < number_of_threads; ++idx)
|
|
||||||
{
|
|
||||||
threads[idx] = std::thread(MeasurePeakDuringLogWrites, idx, std::ref(threads_result[idx]));
|
|
||||||
}
|
|
||||||
for (size_t idx = 0; idx < number_of_threads; ++idx)
|
|
||||||
{
|
|
||||||
threads[idx].join();
|
|
||||||
}
|
|
||||||
auto stop_time_application_total = std::chrono::high_resolution_clock::now();
|
|
||||||
|
|
||||||
uint64_t total_time_in_us = std::chrono::duration_cast<std::chrono::microseconds>(stop_time_application_total - start_time_application_total).count();
|
|
||||||
PrintResults(threads_result, total_time_in_us);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,128 +0,0 @@
|
|||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <vector>
|
|
||||||
#include <atomic>
|
|
||||||
#include <iostream>
|
|
||||||
#include <chrono>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <map>
|
|
||||||
#include <numeric>
|
|
||||||
#include <functional>
|
|
||||||
#include "utils.h"
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
#include "spdlog/spdlog.h"
|
|
||||||
|
|
||||||
namespace spd = spdlog;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
const uint64_t g_iterations = 1000000;
|
|
||||||
|
|
||||||
|
|
||||||
std::atomic<size_t> g_counter = {0};
|
|
||||||
|
|
||||||
|
|
||||||
void MeasurePeakDuringLogWrites(const size_t id, std::vector<uint64_t>& result)
|
|
||||||
{
|
|
||||||
auto logger = spd::get("file_logger");
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
const size_t value_now = ++g_counter;
|
|
||||||
if (value_now > g_iterations)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto start_time = std::chrono::high_resolution_clock::now();
|
|
||||||
logger->info("Some text to log for thread: [somemore text...............................] {}", id);
|
|
||||||
auto stop_time = std::chrono::high_resolution_clock::now();
|
|
||||||
uint64_t time_us = std::chrono::duration_cast<std::chrono::microseconds>(stop_time - start_time).count();
|
|
||||||
result.push_back(time_us);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PrintResults(const std::map<size_t, std::vector<uint64_t>>& threads_result, size_t total_us)
|
|
||||||
{
|
|
||||||
|
|
||||||
std::vector<uint64_t> all_measurements;
|
|
||||||
all_measurements.reserve(g_iterations);
|
|
||||||
for (auto& t_result : threads_result)
|
|
||||||
{
|
|
||||||
all_measurements.insert(all_measurements.end(), t_result.second.begin(), t_result.second.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
// calc worst latenct
|
|
||||||
auto worst = *std::max_element(all_measurements.begin(), all_measurements.end());
|
|
||||||
|
|
||||||
// calc avg
|
|
||||||
auto total = accumulate(begin(all_measurements), end(all_measurements), 0, std::plus<uint64_t>());
|
|
||||||
auto avg = double(total)/all_measurements.size();
|
|
||||||
|
|
||||||
std::cout << "[spdlog] worst: " << std::setw(10) << std::right << worst << "\tAvg: " << avg << "\tTotal: " << utils::format(total_us) << " us" << std::endl;
|
|
||||||
|
|
||||||
}
|
|
||||||
}// anonymous
|
|
||||||
|
|
||||||
|
|
||||||
// The purpose of this test is NOT to see how fast
|
|
||||||
// each thread can possibly write. It is to see what
|
|
||||||
// the worst latency is for writing a log entry
|
|
||||||
//
|
|
||||||
// In the test 1 million log entries will be written
|
|
||||||
// an atomic counter is used to give each thread what
|
|
||||||
// it is to write next. The overhead of atomic
|
|
||||||
// synchronization between the threads are not counted in the worst case latency
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
size_t number_of_threads {0};
|
|
||||||
if (argc == 2)
|
|
||||||
{
|
|
||||||
number_of_threads = atoi(argv[1]);
|
|
||||||
}
|
|
||||||
if (argc != 2 || number_of_threads == 0)
|
|
||||||
{
|
|
||||||
std::cerr << "usage: " << argv[0] << " number_threads" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::thread> threads(number_of_threads);
|
|
||||||
std::map<size_t, std::vector<uint64_t>> threads_result;
|
|
||||||
|
|
||||||
for (size_t idx = 0; idx < number_of_threads; ++idx)
|
|
||||||
{
|
|
||||||
// reserve to 1 million for all the result
|
|
||||||
// it's a test so let's not care about the wasted space
|
|
||||||
threads_result[idx].reserve(g_iterations);
|
|
||||||
}
|
|
||||||
|
|
||||||
int queue_size = 1048576; // 2 ^ 20
|
|
||||||
spdlog::set_async_mode(queue_size);
|
|
||||||
auto logger = spdlog::create<spd::sinks::simple_file_sink_mt>("file_logger", "spdlog.log", true);
|
|
||||||
|
|
||||||
//force flush on every call to compare with g3log
|
|
||||||
auto s = (spd::sinks::simple_file_sink_mt*)logger->sinks()[0].get();
|
|
||||||
s->set_force_flush(true);
|
|
||||||
|
|
||||||
auto start_time_application_total = std::chrono::high_resolution_clock::now();
|
|
||||||
for (uint64_t idx = 0; idx < number_of_threads; ++idx)
|
|
||||||
{
|
|
||||||
threads[idx] = std::thread(MeasurePeakDuringLogWrites, idx, std::ref(threads_result[idx]));
|
|
||||||
}
|
|
||||||
for (size_t idx = 0; idx < number_of_threads; ++idx)
|
|
||||||
{
|
|
||||||
threads[idx].join();
|
|
||||||
}
|
|
||||||
auto stop_time_application_total = std::chrono::high_resolution_clock::now();
|
|
||||||
|
|
||||||
uint64_t total_time_in_us = std::chrono::duration_cast<std::chrono::microseconds>(stop_time_application_total - start_time_application_total).count();
|
|
||||||
|
|
||||||
PrintResults(threads_result, total_time_in_us);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <locale>
|
|
||||||
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline std::string format(const T& value)
|
|
||||||
{
|
|
||||||
static std::locale loc("");
|
|
||||||
std::stringstream ss;
|
|
||||||
ss.imbue(loc);
|
|
||||||
ss << value;
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
inline std::string format(const double & value)
|
|
||||||
{
|
|
||||||
static std::locale loc("");
|
|
||||||
std::stringstream ss;
|
|
||||||
ss.imbue(loc);
|
|
||||||
ss << std::fixed << std::setprecision(1) << value;
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
4
bench/logs/.gitignore
vendored
4
bench/logs/.gitignore
vendored
@ -1,4 +0,0 @@
|
|||||||
# Ignore everything in this directory
|
|
||||||
*
|
|
||||||
# Except this file
|
|
||||||
!.gitignore
|
|
@ -1,62 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <vector>
|
|
||||||
#include <atomic>
|
|
||||||
#include <iostream>
|
|
||||||
#include <chrono>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include "spdlog/spdlog.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
|
|
||||||
using namespace std::chrono;
|
|
||||||
using clock=steady_clock;
|
|
||||||
namespace spd = spdlog;
|
|
||||||
|
|
||||||
int thread_count = 10;
|
|
||||||
if(argc > 1)
|
|
||||||
thread_count = ::atoi(argv[1]);
|
|
||||||
int howmany = 1000000;
|
|
||||||
|
|
||||||
spd::set_async_mode(1048576);
|
|
||||||
auto logger = spdlog::create<spd::sinks::simple_file_sink_mt>("file_logger", "logs/spd-bench-async.txt", false);
|
|
||||||
logger->set_pattern("[%Y-%b-%d %T.%e]: %v");
|
|
||||||
|
|
||||||
|
|
||||||
std::atomic<int > msg_counter {0};
|
|
||||||
vector<thread> threads;
|
|
||||||
auto start = clock::now();
|
|
||||||
for (int t = 0; t < thread_count; ++t)
|
|
||||||
{
|
|
||||||
threads.push_back(std::thread([&]()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
int counter = ++msg_counter;
|
|
||||||
if (counter > howmany) break;
|
|
||||||
logger->info("spdlog message #{}: This is some text for your pleasure", counter);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto &t:threads)
|
|
||||||
{
|
|
||||||
t.join();
|
|
||||||
};
|
|
||||||
|
|
||||||
duration<float> delta = clock::now() - start;
|
|
||||||
float deltaf = delta.count();
|
|
||||||
auto rate = howmany/deltaf;
|
|
||||||
|
|
||||||
cout << "Total: " << howmany << std::endl;
|
|
||||||
cout << "Threads: " << thread_count << std::endl;
|
|
||||||
std::cout << "Delta = " << deltaf << " seconds" << std::endl;
|
|
||||||
std::cout << "Rate = " << rate << "/sec" << std::endl;
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <vector>
|
|
||||||
#include <atomic>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include "spdlog/spdlog.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
|
|
||||||
int thread_count = 10;
|
|
||||||
if(argc > 1)
|
|
||||||
thread_count = std::atoi(argv[1]);
|
|
||||||
|
|
||||||
int howmany = 1000000;
|
|
||||||
|
|
||||||
namespace spd = spdlog;
|
|
||||||
|
|
||||||
auto logger = spdlog::create<spd::sinks::simple_file_sink_mt>("file_logger", "logs/spd-bench-mt.txt", false);
|
|
||||||
|
|
||||||
logger->set_pattern("[%Y-%b-%d %T.%e]: %v");
|
|
||||||
|
|
||||||
std::atomic<int > msg_counter {0};
|
|
||||||
std::vector<thread> threads;
|
|
||||||
|
|
||||||
for (int t = 0; t < thread_count; ++t)
|
|
||||||
{
|
|
||||||
threads.push_back(std::thread([&]()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
int counter = ++msg_counter;
|
|
||||||
if (counter > howmany) break;
|
|
||||||
logger->info("spdlog message #{}: This is some text for your pleasure", counter);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for(auto &t:threads)
|
|
||||||
{
|
|
||||||
t.join();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "spdlog/spdlog.h"
|
|
||||||
|
|
||||||
|
|
||||||
int main(int, char* [])
|
|
||||||
{
|
|
||||||
int howmany = 1000000;
|
|
||||||
namespace spd = spdlog;
|
|
||||||
///Create a file rotating logger with 5mb size max and 3 rotated files
|
|
||||||
auto logger = spdlog::create<spd::sinks::simple_file_sink_st>("file_logger", "logs/spd-bench-st.txt", false);
|
|
||||||
|
|
||||||
logger->set_pattern("[%Y-%b-%d %T.%e]: %v");
|
|
||||||
for(int i = 0 ; i < howmany; ++i)
|
|
||||||
logger->info("spdlog message #{} : This is some text for your pleasure", i);
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// bench.cpp : spdlog benchmarks
|
|
||||||
//
|
|
||||||
#include <atomic>
|
|
||||||
#include <cstdlib> // EXIT_FAILURE
|
|
||||||
#include <iostream>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <thread>
|
|
||||||
#include "spdlog/spdlog.h"
|
|
||||||
#include "spdlog/async_logger.h"
|
|
||||||
#include "spdlog/sinks/null_sink.h"
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace std::chrono;
|
|
||||||
using namespace spdlog;
|
|
||||||
using namespace spdlog::sinks;
|
|
||||||
using namespace utils;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
size_t bench_as(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count);
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
|
|
||||||
int queue_size = 1048576;
|
|
||||||
int howmany = 1000000;
|
|
||||||
int threads = 10;
|
|
||||||
int iters = 10;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
if(argc > 1)
|
|
||||||
howmany = atoi(argv[1]);
|
|
||||||
if (argc > 2)
|
|
||||||
threads = atoi(argv[2]);
|
|
||||||
if (argc > 3)
|
|
||||||
queue_size = atoi(argv[3]);
|
|
||||||
|
|
||||||
|
|
||||||
cout << "\n*******************************************************************************\n";
|
|
||||||
cout << "async logging.. " << threads << " threads sharing same logger, " << format(howmany) << " messages " << endl;
|
|
||||||
cout << "*******************************************************************************\n";
|
|
||||||
|
|
||||||
spdlog::set_async_mode(queue_size);
|
|
||||||
|
|
||||||
size_t total_rate = 0;
|
|
||||||
|
|
||||||
for(int i = 0; i < iters; ++i)
|
|
||||||
{
|
|
||||||
//auto as = spdlog::daily_logger_st("as", "logs/daily_async");
|
|
||||||
auto as = spdlog::create<null_sink_st>("async(null-sink)");
|
|
||||||
total_rate+= bench_as(howmany, as, threads);
|
|
||||||
spdlog::drop("async(null-sink)");
|
|
||||||
}
|
|
||||||
std::cout << endl;
|
|
||||||
std::cout << "Avg rate: " << format(total_rate/iters) << "/sec" <<std::endl;
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (std::exception &ex)
|
|
||||||
{
|
|
||||||
std::cerr << "Error: " << ex.what() << std::endl;
|
|
||||||
perror("Last error");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//return rate/sec
|
|
||||||
size_t bench_as(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count)
|
|
||||||
{
|
|
||||||
cout << log->name() << "...\t\t" << flush;
|
|
||||||
std::atomic<int > msg_counter {0};
|
|
||||||
vector<thread> threads;
|
|
||||||
auto start = system_clock::now();
|
|
||||||
for (int t = 0; t < thread_count; ++t)
|
|
||||||
{
|
|
||||||
threads.push_back(std::thread([&]()
|
|
||||||
{
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
int counter = ++msg_counter;
|
|
||||||
if (counter > howmany) break;
|
|
||||||
log->info("Hello logger: msg number {}", counter);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for(auto &t:threads)
|
|
||||||
{
|
|
||||||
t.join();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
auto delta = system_clock::now() - start;
|
|
||||||
auto delta_d = duration_cast<duration<double>> (delta).count();
|
|
||||||
auto per_sec = size_t(howmany / delta_d);
|
|
||||||
cout << format(per_sec) << "/sec" << endl;
|
|
||||||
return per_sec;
|
|
||||||
}
|
|
@ -5,16 +5,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
namespace utils
|
namespace utils {
|
||||||
{
|
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline std::string format(const T& value)
|
inline std::string format(const T &value) {
|
||||||
{
|
|
||||||
static std::locale loc("");
|
static std::locale loc("");
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss.imbue(loc);
|
ss.imbue(loc);
|
||||||
@ -22,9 +20,8 @@ inline std::string format(const T& value)
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template <>
|
||||||
inline std::string format(const double & value)
|
inline std::string format(const double &value) {
|
||||||
{
|
|
||||||
static std::locale loc("");
|
static std::locale loc("");
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss.imbue(loc);
|
ss.imbue(loc);
|
||||||
@ -32,4 +29,4 @@ inline std::string format(const double & value)
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace utils
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
# *************************************************************************/
|
|
||||||
# * Copyright (c) 2015 Ruslan Baratov. */
|
|
||||||
# * */
|
|
||||||
# * Permission is hereby granted, free of charge, to any person obtaining */
|
|
||||||
# * a copy of this software and associated documentation files (the */
|
|
||||||
# * "Software"), to deal in the Software without restriction, including */
|
|
||||||
# * without limitation the rights to use, copy, modify, merge, publish, */
|
|
||||||
# * distribute, sublicense, and/or sell copies of the Software, and to */
|
|
||||||
# * permit persons to whom the Software is furnished to do so, subject to */
|
|
||||||
# * the following conditions: */
|
|
||||||
# * */
|
|
||||||
# * The above copyright notice and this permission notice shall be */
|
|
||||||
# * included in all copies or substantial portions of the Software. */
|
|
||||||
# * */
|
|
||||||
# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
||||||
# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
||||||
# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
||||||
# * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
||||||
# * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
||||||
# * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
||||||
# * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
||||||
# *************************************************************************/
|
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
|
|
18
cmake/ide.cmake
Normal file
18
cmake/ide.cmake
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
# IDE support for headers
|
||||||
|
# ---------------------------------------------------------------------------------------
|
||||||
|
set(SPDLOG_HEADERS_DIR "${CMAKE_CURRENT_LIST_DIR}/../include")
|
||||||
|
|
||||||
|
file(GLOB SPDLOG_TOP_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/*.h")
|
||||||
|
file(GLOB SPDLOG_DETAILS_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/details/*.h")
|
||||||
|
file(GLOB SPDLOG_SINKS_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/sinks/*.h")
|
||||||
|
file(GLOB SPDLOG_FMT_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/fmt/*.h")
|
||||||
|
file(GLOB SPDLOG_FMT_BUNDELED_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/fmt/bundled/*.h")
|
||||||
|
set(SPDLOG_ALL_HEADERS ${SPDLOG_TOP_HEADERS} ${SPDLOG_DETAILS_HEADERS} ${SPDLOG_SINKS_HEADERS} ${SPDLOG_FMT_HEADERS}
|
||||||
|
${SPDLOG_FMT_BUNDELED_HEADERS})
|
||||||
|
|
||||||
|
source_group("Header Files\\spdlog" FILES ${SPDLOG_TOP_HEADERS})
|
||||||
|
source_group("Header Files\\spdlog\\details" FILES ${SPDLOG_DETAILS_HEADERS})
|
||||||
|
source_group("Header Files\\spdlog\\sinks" FILES ${SPDLOG_SINKS_HEADERS})
|
||||||
|
source_group("Header Files\\spdlog\\fmt" FILES ${SPDLOG_FMT_HEADERS})
|
||||||
|
source_group("Header Files\\spdlog\\fmt\\bundled\\" FILES ${SPDLOG_FMT_BUNDELED_HEADERS})
|
258
cmake/pch.h.in
Normal file
258
cmake/pch.h.in
Normal file
@ -0,0 +1,258 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// details/pattern_formatter-inl.h
|
||||||
|
// fmt/bin_to_hex.h
|
||||||
|
// fmt/bundled/format-inl.h
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
|
// details/file_helper-inl.h
|
||||||
|
// details/os-inl.h
|
||||||
|
// fmt/bundled/core.h
|
||||||
|
// fmt/bundled/posix.h
|
||||||
|
// logger-inl.h
|
||||||
|
// sinks/daily_file_sink.h
|
||||||
|
// sinks/stdout_sinks.h
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
// details/os-inl.h
|
||||||
|
// fmt/bundled/posix.h
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
// details/os-inl.h
|
||||||
|
// details/pattern_formatter-inl.h
|
||||||
|
// fmt/bundled/core.h
|
||||||
|
// fmt/bundled/format-inl.h
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
// details/os-inl.h
|
||||||
|
// details/os.h
|
||||||
|
// details/pattern_formatter-inl.h
|
||||||
|
// details/pattern_formatter.h
|
||||||
|
// fmt/bundled/chrono.h
|
||||||
|
// sinks/daily_file_sink.h
|
||||||
|
// sinks/rotating_file_sink-inl.h
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
// fmt/bundled/format-inl.h
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
|
// fmt/bundled/format-inl.h
|
||||||
|
#include <cwchar>
|
||||||
|
|
||||||
|
// fmt/bundled/format-inl.h
|
||||||
|
// fmt/bundled/format.h
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
// fmt/bundled/format-inl.h
|
||||||
|
#include <cstdarg>
|
||||||
|
|
||||||
|
// details/file_helper-inl.h
|
||||||
|
// fmt/bundled/format.h
|
||||||
|
// fmt/bundled/posix.h
|
||||||
|
// sinks/rotating_file_sink-inl.h
|
||||||
|
#include <cerrno>
|
||||||
|
|
||||||
|
// details/circular_q.h
|
||||||
|
// details/thread_pool-inl.h
|
||||||
|
// fmt/bundled/format-inl.h
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
// async_logger-inl.h
|
||||||
|
// cfg/helpers-inl.h
|
||||||
|
// log_levels.h
|
||||||
|
// common.h
|
||||||
|
// details/file_helper-inl.h
|
||||||
|
// details/log_msg.h
|
||||||
|
// details/os-inl.h
|
||||||
|
// details/pattern_formatter-inl.h
|
||||||
|
// details/pattern_formatter.h
|
||||||
|
// details/registry-inl.h
|
||||||
|
// details/registry.h
|
||||||
|
// details/tcp_client-windows.h
|
||||||
|
// details/tcp_client.h
|
||||||
|
// fmt/bundled/core.h
|
||||||
|
// sinks/android_sink.h
|
||||||
|
// sinks/ansicolor_sink.h
|
||||||
|
// sinks/basic_file_sink.h
|
||||||
|
// sinks/daily_file_sink.h
|
||||||
|
// sinks/dup_filter_sink.h
|
||||||
|
// sinks/msvc_sink.h
|
||||||
|
// sinks/ringbuffer_sink.h
|
||||||
|
// sinks/rotating_file_sink-inl.h
|
||||||
|
// sinks/rotating_file_sink.h
|
||||||
|
// sinks/syslog_sink.h
|
||||||
|
// sinks/tcp_sink.h
|
||||||
|
// sinks/win_eventlog_sink.h
|
||||||
|
// sinks/wincolor_sink.h
|
||||||
|
// spdlog.h:
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// cfg/helpers-inl.h
|
||||||
|
// fmt/bundled/chrono.h
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
// fmt/bundled/ostream.h
|
||||||
|
// sinks/ostream_sink.h
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
// cfg/log_levels.h
|
||||||
|
// details/registry-inl.h
|
||||||
|
// details/registry.h
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
// details/circular_q.h
|
||||||
|
// details/pattern_formatter-inl.h
|
||||||
|
// details/pattern_formatter.h
|
||||||
|
// details/thread_pool.h
|
||||||
|
// fmt/bundled/compile.h
|
||||||
|
// logger.h
|
||||||
|
// sinks/dist_sink.h
|
||||||
|
// sinks/ringbuffer_sink.h
|
||||||
|
// sinks/win_eventlog_sink.h
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// details/os-inl.h
|
||||||
|
// details/pattern_formatter-inl.h
|
||||||
|
// sinks/ansicolor_sink.h
|
||||||
|
// sinks/syslog_sink.h
|
||||||
|
// sinks/systemd_sink.h
|
||||||
|
// sinks/wincolor_sink.h
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
// details/file_helper-inl.h
|
||||||
|
// details/file_helper.h
|
||||||
|
// sinks/rotating_file_sink-inl.h
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
// details/os-inl.h
|
||||||
|
// fmt/bundled/format.h
|
||||||
|
// fmt/bundled/printf.h
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
// common.h
|
||||||
|
// details/backtracer.h
|
||||||
|
// details/null_mutex.h
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
// common.h
|
||||||
|
// details/backtracer.h
|
||||||
|
// details/null_mutex.h
|
||||||
|
#include <locale>
|
||||||
|
|
||||||
|
// common.h
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
|
// common.h
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
// common.h
|
||||||
|
// details/fmt_helper.h
|
||||||
|
// fmt/bundled/core.h
|
||||||
|
// fmt/bundled/ranges.h
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
// cfg/helpers-inl.h
|
||||||
|
// details/null_mutex.h
|
||||||
|
// details/pattern_formatter-inl.h
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
// async.h
|
||||||
|
// async_logger-inl.h
|
||||||
|
// common.h
|
||||||
|
// details/pattern_formatter-inl.h
|
||||||
|
// details/pattern_formatter.h
|
||||||
|
// details/registry-inl.h
|
||||||
|
// details/registry.h
|
||||||
|
// details/thread_pool.h
|
||||||
|
// fmt/bundled/format.h
|
||||||
|
// sinks/ansicolor_sink.h
|
||||||
|
// sinks/base_sink-inl.h
|
||||||
|
// sinks/dist_sink.h
|
||||||
|
// sinks/stdout_sinks-inl.h
|
||||||
|
// sinks/wincolor_sink.h
|
||||||
|
// spdlog.h
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
// async.h
|
||||||
|
// common.h
|
||||||
|
// details/backtracer.h
|
||||||
|
// details/periodic_worker.h
|
||||||
|
// details/registry-inl.h
|
||||||
|
// details/registry.h
|
||||||
|
// details/thread_pool.h
|
||||||
|
// sinks/tcp_sink.h
|
||||||
|
// spdlog.h
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
// details/mpmc_blocking_q.h
|
||||||
|
// details/periodic_worker.h
|
||||||
|
#include <condition_variable>
|
||||||
|
|
||||||
|
// details/os-inl.h
|
||||||
|
// fmt/bundled/format.h
|
||||||
|
// fmt/bundled/printf.h
|
||||||
|
// sinks/dist_sink.h
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
// common.h
|
||||||
|
// details/file_helper-inl.h
|
||||||
|
// details/fmt_helper.h
|
||||||
|
// details/os-inl.h
|
||||||
|
// details/pattern_formatter-inl.h
|
||||||
|
// details/pattern_formatter.h
|
||||||
|
// details/periodic_worker.h
|
||||||
|
// details/registry-inl.h
|
||||||
|
// details/registry.h
|
||||||
|
// details/thread_pool.h
|
||||||
|
// fmt/bundled/chrono.h
|
||||||
|
// sinks/android_sink.h
|
||||||
|
// sinks/daily_file_sink.h
|
||||||
|
// sinks/dup_filter_sink.h
|
||||||
|
// sinks/rotating_file_sink-inl.h
|
||||||
|
// sinks/rotating_file_sink.h
|
||||||
|
// sinks/tcp_sink.h
|
||||||
|
// spdlog.h
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// details/file_helper-inl.h
|
||||||
|
// details/os-inl.h
|
||||||
|
// details/pattern_formatter-inl.h
|
||||||
|
// details/periodic_worker.h
|
||||||
|
// details/thread_pool.h
|
||||||
|
// sinks/android_sink.h
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
// async.h
|
||||||
|
// details/backtracer.h
|
||||||
|
// details/console_globals.h
|
||||||
|
// details/mpmc_blocking_q.h
|
||||||
|
// details/pattern_formatter-inl.h
|
||||||
|
// details/periodic_worker.h
|
||||||
|
// details/registry.h
|
||||||
|
// sinks/android_sink.h
|
||||||
|
// sinks/ansicolor_sink.h
|
||||||
|
// sinks/basic_file_sink.h
|
||||||
|
// sinks/daily_file_sink.h
|
||||||
|
// sinks/dist_sink.h
|
||||||
|
// sinks/dup_filter_sink.h
|
||||||
|
// sinks/msvc_sink.h
|
||||||
|
// sinks/null_sink.h
|
||||||
|
// sinks/ostream_sink.h
|
||||||
|
// sinks/ringbuffer_sink.h
|
||||||
|
// sinks/rotating_file_sink-inl.h
|
||||||
|
// sinks/rotating_file_sink.h
|
||||||
|
// sinks/tcp_sink.h
|
||||||
|
// sinks/win_eventlog_sink.h
|
||||||
|
// sinks/wincolor_sink.h
|
||||||
|
//
|
||||||
|
// color_sinks.cpp
|
||||||
|
// file_sinks.cpp
|
||||||
|
// spdlog.cpp
|
||||||
|
// stdout_sinks.cpp
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
// spdlog
|
||||||
|
#include <spdlog/common.h>
|
@ -1,6 +1,13 @@
|
|||||||
prefix=@CMAKE_INSTALL_PREFIX@
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
includedir=${prefix}/include
|
exec_prefix=${prefix}
|
||||||
|
includedir=@PKG_CONFIG_INCLUDEDIR@
|
||||||
Name: @PROJECT_NAME@
|
libdir=@PKG_CONFIG_LIBDIR@
|
||||||
Description: Super fast C++ logging library.
|
|
||||||
Version: @PROJECT_VERSION@
|
Name: lib@PROJECT_NAME@
|
||||||
|
Description: Fast C++ logging library.
|
||||||
|
URL: https://github.com/gabime/@PROJECT_NAME@
|
||||||
|
Version: @SPDLOG_VERSION@
|
||||||
|
CFlags: -I${includedir} @PKG_CONFIG_DEFINES@
|
||||||
|
Libs: -L${libdir} -lspdlog -pthread
|
||||||
|
Requires: @PKG_CONFIG_REQUIRES@
|
||||||
|
|
||||||
|
60
cmake/spdlogCPack.cmake
Normal file
60
cmake/spdlogCPack.cmake
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
set(CPACK_GENERATOR "TGZ;ZIP" CACHE STRING "Semicolon separated list of generators")
|
||||||
|
|
||||||
|
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
|
||||||
|
set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_BINARY_DIR}" "${PROJECT_NAME}" ALL .)
|
||||||
|
|
||||||
|
set(CPACK_PROJECT_URL "https://github.com/gabime/spdlog")
|
||||||
|
set(CPACK_PACKAGE_VENDOR "Gabi Melman")
|
||||||
|
set(CPACK_PACKAGE_CONTACT "Gabi Melman <gmelman1@gmail.com>")
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Fast C++ logging library")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
||||||
|
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
||||||
|
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||||
|
if(PROJECT_VERSION_TWEAK)
|
||||||
|
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}.${PROJECT_VERSION_TWEAK})
|
||||||
|
endif()
|
||||||
|
set(CPACK_PACKAGE_RELOCATABLE ON CACHE BOOL "Build relocatable package")
|
||||||
|
|
||||||
|
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
|
||||||
|
set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
|
||||||
|
set(CPACK_RPM_PACKAGE_URL ${CPACK_PROJECT_URL})
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PROJECT_URL})
|
||||||
|
set(CPACK_RPM_PACKAGE_DESCRIPTION "Very fast, header-only/compiled, C++ logging library.")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Very fast, header-only/compiled, C++ logging library.")
|
||||||
|
|
||||||
|
if(CPACK_PACKAGE_NAME)
|
||||||
|
set(CPACK_RPM_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
|
||||||
|
set(CPACK_DEBIAN_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
|
||||||
|
else()
|
||||||
|
set(CPACK_RPM_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
|
||||||
|
set(CPACK_DEBIAN_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
|
||||||
|
set(CPACK_RPM_PACKAGE_NAME "${PROJECT_NAME}")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_NAME "${PROJECT_NAME}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CPACK_RPM_PACKAGE_RELEASE)
|
||||||
|
set(CPACK_RPM_FILE_NAME "${CPACK_RPM_FILE_NAME}-${CPACK_RPM_PACKAGE_RELEASE}")
|
||||||
|
endif()
|
||||||
|
if(CPACK_DEBIAN_PACKAGE_RELEASE)
|
||||||
|
set(CPACK_DEBIAN_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}-${CPACK_DEBIAN_PACKAGE_RELEASE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||||
|
set(CPACK_RPM_FILE_NAME "${CPACK_RPM_FILE_NAME}.${CPACK_RPM_PACKAGE_ARCHITECTURE}")
|
||||||
|
endif()
|
||||||
|
if(CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
||||||
|
set(CPACK_DEBIAN_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}.${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
||||||
|
endif()
|
||||||
|
set(CPACK_RPM_FILE_NAME "${CPACK_RPM_FILE_NAME}.rpm")
|
||||||
|
set(CPACK_DEBIAN_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}.deb")
|
||||||
|
|
||||||
|
if(NOT CPACK_PACKAGE_RELOCATABLE)
|
||||||
|
# Depend on pkgconfig rpm to create the system pkgconfig folder
|
||||||
|
set(CPACK_RPM_PACKAGE_REQUIRES pkgconfig)
|
||||||
|
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
|
||||||
|
"${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CPack)
|
20
cmake/spdlogConfig.cmake.in
Normal file
20
cmake/spdlogConfig.cmake.in
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Copyright(c) 2019 spdlog authors
|
||||||
|
# Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
set(SPDLOG_FMT_EXTERNAL @SPDLOG_FMT_EXTERNAL@)
|
||||||
|
set(SPDLOG_FMT_EXTERNAL_HO @SPDLOG_FMT_EXTERNAL_HO@)
|
||||||
|
set(config_targets_file @config_targets_file@)
|
||||||
|
|
||||||
|
if(SPDLOG_FMT_EXTERNAL OR SPDLOG_FMT_EXTERNAL_HO)
|
||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
find_dependency(fmt CONFIG)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/${config_targets_file}")
|
||||||
|
|
||||||
|
check_required_components(spdlog)
|
73
cmake/utils.cmake
Normal file
73
cmake/utils.cmake
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
# Get spdlog version from include/spdlog/version.h and put it in SPDLOG_VERSION
|
||||||
|
function(spdlog_extract_version)
|
||||||
|
file(READ "${CMAKE_CURRENT_LIST_DIR}/include/spdlog/version.h" file_contents)
|
||||||
|
string(REGEX MATCH "SPDLOG_VER_MAJOR ([0-9]+)" _ "${file_contents}")
|
||||||
|
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
|
||||||
|
message(FATAL_ERROR "Could not extract major version number from spdlog/version.h")
|
||||||
|
endif()
|
||||||
|
set(ver_major ${CMAKE_MATCH_1})
|
||||||
|
|
||||||
|
string(REGEX MATCH "SPDLOG_VER_MINOR ([0-9]+)" _ "${file_contents}")
|
||||||
|
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
|
||||||
|
message(FATAL_ERROR "Could not extract minor version number from spdlog/version.h")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(ver_minor ${CMAKE_MATCH_1})
|
||||||
|
string(REGEX MATCH "SPDLOG_VER_PATCH ([0-9]+)" _ "${file_contents}")
|
||||||
|
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
|
||||||
|
message(FATAL_ERROR "Could not extract patch version number from spdlog/version.h")
|
||||||
|
endif()
|
||||||
|
set(ver_patch ${CMAKE_MATCH_1})
|
||||||
|
|
||||||
|
set(SPDLOG_VERSION_MAJOR ${ver_major} PARENT_SCOPE)
|
||||||
|
set(SPDLOG_VERSION_MINOR ${ver_minor} PARENT_SCOPE)
|
||||||
|
set(SPDLOG_VERSION_PATCH ${ver_patch} PARENT_SCOPE)
|
||||||
|
set(SPDLOG_VERSION "${ver_major}.${ver_minor}.${ver_patch}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Turn on warnings on the given target
|
||||||
|
function(spdlog_enable_warnings target_name)
|
||||||
|
if(SPDLOG_BUILD_WARNINGS)
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
list(APPEND MSVC_OPTIONS "/W3")
|
||||||
|
if(MSVC_VERSION GREATER 1900) # Allow non fatal security warnings for msvc 2015
|
||||||
|
list(APPEND MSVC_OPTIONS "/WX")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_compile_options(
|
||||||
|
${target_name}
|
||||||
|
PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||||
|
-Wall
|
||||||
|
-Wextra
|
||||||
|
-Wconversion
|
||||||
|
-pedantic
|
||||||
|
-Werror
|
||||||
|
-Wfatal-errors>
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:${MSVC_OPTIONS}>)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Enable address sanitizer (gcc/clang only)
|
||||||
|
function(spdlog_enable_addr_sanitizer target_name)
|
||||||
|
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
|
message(FATAL_ERROR "Sanitizer supported only for gcc/clang")
|
||||||
|
endif()
|
||||||
|
message(STATUS "Address sanitizer enabled")
|
||||||
|
target_compile_options(${target_name} PRIVATE -fsanitize=address,undefined)
|
||||||
|
target_compile_options(${target_name} PRIVATE -fno-sanitize=signed-integer-overflow)
|
||||||
|
target_compile_options(${target_name} PRIVATE -fno-sanitize-recover=all)
|
||||||
|
target_compile_options(${target_name} PRIVATE -fno-omit-frame-pointer)
|
||||||
|
target_link_libraries(${target_name} PRIVATE -fsanitize=address,undefined)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Enable thread sanitizer (gcc/clang only)
|
||||||
|
function(spdlog_enable_thread_sanitizer target_name)
|
||||||
|
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
|
message(FATAL_ERROR "Sanitizer supported only for gcc/clang")
|
||||||
|
endif()
|
||||||
|
message(STATUS "Thread sanitizer enabled")
|
||||||
|
target_compile_options(${target_name} PRIVATE -fsanitize=thread)
|
||||||
|
target_compile_options(${target_name} PRIVATE -fno-omit-frame-pointer)
|
||||||
|
target_link_libraries(${target_name} PRIVATE -fsanitize=thread)
|
||||||
|
endfunction()
|
42
cmake/version.rc.in
Normal file
42
cmake/version.rc.in
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#include <windows.h>
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
|
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION @SPDLOG_VERSION_MAJOR@,@SPDLOG_VERSION_MINOR@,@SPDLOG_VERSION_PATCH@,0
|
||||||
|
PRODUCTVERSION @SPDLOG_VERSION_MAJOR@,@SPDLOG_VERSION_MINOR@,@SPDLOG_VERSION_PATCH@,0
|
||||||
|
FILEFLAGSMASK 0x3fL
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x40004L
|
||||||
|
FILETYPE 0x2L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "040904b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "FileDescription", "spdlog dll\0"
|
||||||
|
VALUE "FileVersion", "@SPDLOG_VERSION@.0\0"
|
||||||
|
VALUE "InternalName", "spdlog.dll\0"
|
||||||
|
VALUE "LegalCopyright", "Copyright (C) spdlog\0"
|
||||||
|
VALUE "ProductName", "spdlog\0"
|
||||||
|
VALUE "ProductVersion", "@SPDLOG_VERSION@.0\0"
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x409, 1200
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,49 +1,23 @@
|
|||||||
# *************************************************************************/
|
# Copyright(c) 2019 spdlog authors Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
# * Copyright (c) 2015 Ruslan Baratov. */
|
|
||||||
# * */
|
cmake_minimum_required(VERSION 3.11)
|
||||||
# * Permission is hereby granted, free of charge, to any person obtaining */
|
project(spdlog_examples CXX)
|
||||||
# * a copy of this software and associated documentation files (the */
|
|
||||||
# * "Software"), to deal in the Software without restriction, including */
|
if(NOT TARGET spdlog)
|
||||||
# * without limitation the rights to use, copy, modify, merge, publish, */
|
# Stand-alone build
|
||||||
# * distribute, sublicense, and/or sell copies of the Software, and to */
|
find_package(spdlog REQUIRED)
|
||||||
# * permit persons to whom the Software is furnished to do so, subject to */
|
endif()
|
||||||
# * the following conditions: */
|
|
||||||
# * */
|
# ---------------------------------------------------------------------------------------
|
||||||
# * The above copyright notice and this permission notice shall be */
|
# Example of using pre-compiled library
|
||||||
# * included in all copies or substantial portions of the Software. */
|
# ---------------------------------------------------------------------------------------
|
||||||
# * */
|
add_executable(example example.cpp)
|
||||||
# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
target_link_libraries(example PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
|
||||||
# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
||||||
# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
# ---------------------------------------------------------------------------------------
|
||||||
# * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
# Example of using header-only library
|
||||||
# * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
# ---------------------------------------------------------------------------------------
|
||||||
# * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
if(SPDLOG_BUILD_EXAMPLE_HO)
|
||||||
# * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
add_executable(example_header_only example.cpp)
|
||||||
# *************************************************************************/
|
target_link_libraries(example_header_only PRIVATE spdlog::spdlog_header_only)
|
||||||
|
endif()
|
||||||
cmake_minimum_required(VERSION 3.0)
|
|
||||||
project(SpdlogExamples)
|
|
||||||
|
|
||||||
if(TARGET spdlog)
|
|
||||||
# Part of the main project
|
|
||||||
add_library(spdlog::spdlog ALIAS spdlog)
|
|
||||||
else()
|
|
||||||
# Stand-alone build
|
|
||||||
find_package(spdlog CONFIG REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_package(Threads)
|
|
||||||
|
|
||||||
add_executable(example example.cpp)
|
|
||||||
target_link_libraries(example spdlog::spdlog ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
|
|
||||||
add_executable(benchmark bench.cpp)
|
|
||||||
target_link_libraries(benchmark spdlog::spdlog ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
|
|
||||||
add_executable(multisink multisink.cpp)
|
|
||||||
target_link_libraries(multisink spdlog::spdlog ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
|
|
||||||
enable_testing()
|
|
||||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
|
|
||||||
add_test(NAME RunExample COMMAND example)
|
|
||||||
add_test(NAME RunBenchmark COMMAND benchmark)
|
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
CXX ?= g++
|
|
||||||
CXXFLAGS =
|
|
||||||
CXX_FLAGS = -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -I../include
|
|
||||||
CXX_RELEASE_FLAGS = -O3 -march=native
|
|
||||||
CXX_DEBUG_FLAGS= -g
|
|
||||||
|
|
||||||
|
|
||||||
all: example bench
|
|
||||||
debug: example-debug bench-debug
|
|
||||||
|
|
||||||
example: example.cpp
|
|
||||||
$(CXX) example.cpp -o example $(CXX_FLAGS) $(CXX_RELEASE_FLAGS) $(CXXFLAGS)
|
|
||||||
|
|
||||||
bench: bench.cpp
|
|
||||||
$(CXX) bench.cpp -o bench $(CXX_FLAGS) $(CXX_RELEASE_FLAGS) $(CXXFLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
example-debug: example.cpp
|
|
||||||
$(CXX) example.cpp -o example-debug $(CXX_FLAGS) $(CXX_DEBUG_FLAGS) $(CXXFLAGS)
|
|
||||||
|
|
||||||
bench-debug: bench.cpp
|
|
||||||
$(CXX) bench.cpp -o bench-debug $(CXX_FLAGS) $(CXX_DEBUG_FLAGS) $(CXXFLAGS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o logs/*.txt example example-debug bench bench-debug
|
|
||||||
|
|
||||||
|
|
||||||
rebuild: clean all
|
|
||||||
rebuild-debug: clean debug
|
|
@ -1,32 +0,0 @@
|
|||||||
CXX ?= clang++
|
|
||||||
CXXFLAGS = -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -I../include
|
|
||||||
CXX_RELEASE_FLAGS = -O2
|
|
||||||
CXX_DEBUG_FLAGS= -g
|
|
||||||
|
|
||||||
|
|
||||||
all: example bench
|
|
||||||
debug: example-debug bench-debug
|
|
||||||
|
|
||||||
example: example.cpp
|
|
||||||
$(CXX) example.cpp -o example-clang $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
bench: bench.cpp
|
|
||||||
$(CXX) bench.cpp -o bench-clang $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
example-debug: example.cpp
|
|
||||||
$(CXX) example.cpp -o example-clang-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
|
|
||||||
|
|
||||||
bench-debug: bench.cpp
|
|
||||||
$(CXX) bench.cpp -o bench-clang-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o logs/*.txt example-clang example-clang-debug bench-clang bench-clang-debug
|
|
||||||
|
|
||||||
|
|
||||||
rebuild: clean all
|
|
||||||
rebuild-debug: clean debug
|
|
||||||
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
CXX ?= g++
|
|
||||||
CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -Wshadow -pedantic -std=gnu++0x -pthread -Wl,--no-as-needed -I../include
|
|
||||||
CXX_RELEASE_FLAGS = -O3
|
|
||||||
CXX_DEBUG_FLAGS= -g
|
|
||||||
|
|
||||||
|
|
||||||
all: example bench
|
|
||||||
debug: example-debug bench-debug
|
|
||||||
|
|
||||||
example: example.cpp
|
|
||||||
$(CXX) example.cpp -o example $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
bench: bench.cpp
|
|
||||||
$(CXX) bench.cpp -o bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
example-debug: example.cpp
|
|
||||||
$(CXX) example.cpp -o example-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
|
|
||||||
|
|
||||||
bench-debug: bench.cpp
|
|
||||||
$(CXX) bench.cpp -o bench-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o logs/*.txt example example-debug bench bench-debug
|
|
||||||
|
|
||||||
|
|
||||||
rebuild: clean all
|
|
||||||
rebuild-debug: clean debug
|
|
||||||
|
|
||||||
|
|
@ -1,144 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// bench.cpp : spdlog benchmarks
|
|
||||||
//
|
|
||||||
#include <atomic>
|
|
||||||
#include <cstdlib> // EXIT_FAILURE
|
|
||||||
#include <iostream>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <thread>
|
|
||||||
#include "spdlog/spdlog.h"
|
|
||||||
#include "spdlog/async_logger.h"
|
|
||||||
#include "spdlog/sinks/file_sinks.h"
|
|
||||||
#include "spdlog/sinks/null_sink.h"
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace std::chrono;
|
|
||||||
using namespace spdlog;
|
|
||||||
using namespace spdlog::sinks;
|
|
||||||
using namespace utils;
|
|
||||||
|
|
||||||
|
|
||||||
void bench(int howmany, std::shared_ptr<spdlog::logger> log);
|
|
||||||
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count);
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
|
|
||||||
int queue_size = 1048576;
|
|
||||||
int howmany = 1000000;
|
|
||||||
int threads = 10;
|
|
||||||
int file_size = 30 * 1024 * 1024;
|
|
||||||
int rotating_files = 5;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
if(argc > 1)
|
|
||||||
howmany = atoi(argv[1]);
|
|
||||||
if (argc > 2)
|
|
||||||
threads = atoi(argv[2]);
|
|
||||||
if (argc > 3)
|
|
||||||
queue_size = atoi(argv[3]);
|
|
||||||
|
|
||||||
|
|
||||||
cout << "*******************************************************************************\n";
|
|
||||||
cout << "Single thread, " << format(howmany) << " iterations" << endl;
|
|
||||||
cout << "*******************************************************************************\n";
|
|
||||||
|
|
||||||
auto rotating_st = spdlog::rotating_logger_st("rotating_st", "logs/rotating_st", file_size, rotating_files);
|
|
||||||
bench(howmany, rotating_st);
|
|
||||||
auto daily_st = spdlog::daily_logger_st("daily_st", "logs/daily_st");
|
|
||||||
bench(howmany, daily_st);
|
|
||||||
bench(howmany, spdlog::create<null_sink_st>("null_st"));
|
|
||||||
|
|
||||||
cout << "\n*******************************************************************************\n";
|
|
||||||
cout << threads << " threads sharing same logger, " << format(howmany) << " iterations" << endl;
|
|
||||||
cout << "*******************************************************************************\n";
|
|
||||||
|
|
||||||
auto rotating_mt = spdlog::rotating_logger_mt("rotating_mt", "logs/rotating_mt", file_size, rotating_files);
|
|
||||||
bench_mt(howmany, rotating_mt, threads);
|
|
||||||
|
|
||||||
|
|
||||||
auto daily_mt = spdlog::daily_logger_mt("daily_mt", "logs/daily_mt");
|
|
||||||
bench_mt(howmany, daily_mt, threads);
|
|
||||||
bench(howmany, spdlog::create<null_sink_st>("null_mt"));
|
|
||||||
|
|
||||||
cout << "\n*******************************************************************************\n";
|
|
||||||
cout << "async logging.. " << threads << " threads sharing same logger, " << format(howmany) << " iterations " << endl;
|
|
||||||
cout << "*******************************************************************************\n";
|
|
||||||
|
|
||||||
|
|
||||||
spdlog::set_async_mode(queue_size);
|
|
||||||
|
|
||||||
for(int i = 0; i < 3; ++i)
|
|
||||||
{
|
|
||||||
auto as = spdlog::daily_logger_st("as", "logs/daily_async");
|
|
||||||
bench_mt(howmany, as, threads);
|
|
||||||
spdlog::drop("as");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (std::exception &ex)
|
|
||||||
{
|
|
||||||
std::cerr << "Error: " << ex.what() << std::endl;
|
|
||||||
perror("Last error");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void bench(int howmany, std::shared_ptr<spdlog::logger> log)
|
|
||||||
{
|
|
||||||
cout << log->name() << "...\t\t" << flush;
|
|
||||||
auto start = system_clock::now();
|
|
||||||
for (auto i = 0; i < howmany; ++i)
|
|
||||||
{
|
|
||||||
log->info("Hello logger: msg number {}", i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
auto delta = system_clock::now() - start;
|
|
||||||
auto delta_d = duration_cast<duration<double>> (delta).count();
|
|
||||||
cout << format(int(howmany / delta_d)) << "/sec" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count)
|
|
||||||
{
|
|
||||||
|
|
||||||
cout << log->name() << "...\t\t" << flush;
|
|
||||||
std::atomic<int > msg_counter {0};
|
|
||||||
vector<thread> threads;
|
|
||||||
auto start = system_clock::now();
|
|
||||||
for (int t = 0; t < thread_count; ++t)
|
|
||||||
{
|
|
||||||
threads.push_back(std::thread([&]()
|
|
||||||
{
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
int counter = ++msg_counter;
|
|
||||||
if (counter > howmany) break;
|
|
||||||
log->info("Hello logger: msg number {}", counter);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for(auto &t:threads)
|
|
||||||
{
|
|
||||||
t.join();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
auto delta = system_clock::now() - start;
|
|
||||||
auto delta_d = duration_cast<duration<double>> (delta).count();
|
|
||||||
cout << format(int(howmany / delta_d)) << "/sec" << endl;
|
|
||||||
}
|
|
@ -1,167 +1,403 @@
|
|||||||
//
|
//
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
// Copyright(c) 2015 Gabi Melman.
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
//
|
|
||||||
//
|
|
||||||
// spdlog usage example
|
// spdlog usage example
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
#define SPDLOG_TRACE_ON
|
#include <cstdio>
|
||||||
#define SPDLOG_DEBUG_ON
|
#include <chrono>
|
||||||
|
|
||||||
#include "spdlog/spdlog.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
|
void load_levels_example();
|
||||||
|
void stdout_logger_example();
|
||||||
|
void basic_example();
|
||||||
|
void rotating_example();
|
||||||
|
void daily_example();
|
||||||
|
void callback_example();
|
||||||
void async_example();
|
void async_example();
|
||||||
void syslog_example();
|
void binary_example();
|
||||||
void android_example();
|
void vector_example();
|
||||||
|
void stopwatch_example();
|
||||||
|
void trace_example();
|
||||||
|
void multi_sink_example();
|
||||||
void user_defined_example();
|
void user_defined_example();
|
||||||
void err_handler_example();
|
void err_handler_example();
|
||||||
|
void syslog_example();
|
||||||
|
void udp_example();
|
||||||
|
void custom_flags_example();
|
||||||
|
void file_events_example();
|
||||||
|
void replace_default_logger_example();
|
||||||
|
void mdc_example();
|
||||||
|
|
||||||
namespace spd = spdlog;
|
#include "spdlog/spdlog.h"
|
||||||
int main(int, char*[])
|
#include "spdlog/cfg/env.h" // support for loading levels from the environment variable
|
||||||
{
|
#include "spdlog/fmt/ostr.h" // support for user defined types
|
||||||
try
|
|
||||||
{
|
|
||||||
// Console logger with color
|
|
||||||
auto console = spd::stdout_color_mt("console");
|
|
||||||
console->info("Welcome to spdlog!");
|
|
||||||
console->error("Some error message with arg{}..", 1);
|
|
||||||
|
|
||||||
|
int main(int, char *[]) {
|
||||||
|
// Log levels can be loaded from argv/env using "SPDLOG_LEVEL"
|
||||||
|
load_levels_example();
|
||||||
|
|
||||||
// Formatting examples
|
spdlog::info("Welcome to spdlog version {}.{}.{} !", SPDLOG_VER_MAJOR, SPDLOG_VER_MINOR,
|
||||||
console->warn("Easy padding in numbers like {:08d}", 12);
|
SPDLOG_VER_PATCH);
|
||||||
console->critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
|
|
||||||
console->info("Support for floats {:03.2f}", 1.23456);
|
|
||||||
console->info("Positional args are {1} {0}..", "too", "supported");
|
|
||||||
console->info("{:<30}", "left aligned");
|
|
||||||
|
|
||||||
spd::get("console")->info("loggers can be retrieved from a global registry using the spdlog::get(logger_name) function");
|
spdlog::warn("Easy padding in numbers like {:08d}", 12);
|
||||||
|
spdlog::critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
|
||||||
|
spdlog::info("Support for floats {:03.2f}", 1.23456);
|
||||||
|
spdlog::info("Positional args are {1} {0}..", "too", "supported");
|
||||||
|
spdlog::info("{:>8} aligned, {:<8} aligned", "right", "left");
|
||||||
|
|
||||||
|
// Runtime log levels
|
||||||
|
spdlog::set_level(spdlog::level::info); // Set global log level to info
|
||||||
|
spdlog::debug("This message should not be displayed!");
|
||||||
|
spdlog::set_level(spdlog::level::trace); // Set specific logger's log level
|
||||||
|
spdlog::debug("This message should be displayed..");
|
||||||
|
|
||||||
// Create basic file logger (not rotated)
|
// Customize msg format for all loggers
|
||||||
auto my_logger = spd::basic_logger_mt("basic_logger", "logs/basic-log.txt");
|
spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [thread %t] %v");
|
||||||
my_logger->info("Some log message");
|
spdlog::info("This an info message with custom format");
|
||||||
|
spdlog::set_pattern("%+"); // back to default format
|
||||||
|
spdlog::set_level(spdlog::level::info);
|
||||||
|
|
||||||
// Create a file rotating logger with 5mb size max and 3 rotated files
|
// Backtrace support
|
||||||
auto rotating_logger = spd::rotating_logger_mt("some_logger_name", "logs/rotating.txt", 1048576 * 5, 3);
|
// Loggers can store in a ring buffer all messages (including debug/trace) for later inspection.
|
||||||
for (int i = 0; i < 10; ++i)
|
// When needed, call dump_backtrace() to see what happened:
|
||||||
rotating_logger->info("{} * {} equals {:>10}", i, i, i*i);
|
spdlog::enable_backtrace(10); // create ring buffer with capacity of 10 messages
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
// Create a daily logger - a new file is created every day on 2:30am
|
spdlog::debug("Backtrace message {}", i); // not logged..
|
||||||
auto daily_logger = spd::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);
|
|
||||||
// trigger flush if the log severity is error or higher
|
|
||||||
daily_logger->flush_on(spd::level::err);
|
|
||||||
daily_logger->info(123.44);
|
|
||||||
|
|
||||||
// Customize msg format for all messages
|
|
||||||
spd::set_pattern("*** [%H:%M:%S %z] [thread %t] %v ***");
|
|
||||||
rotating_logger->info("This is another message with custom format");
|
|
||||||
|
|
||||||
|
|
||||||
// Runtime log levels
|
|
||||||
spd::set_level(spd::level::info); //Set global log level to info
|
|
||||||
console->debug("This message shold not be displayed!");
|
|
||||||
console->set_level(spd::level::debug); // Set specific logger's log level
|
|
||||||
console->debug("This message shold be displayed..");
|
|
||||||
|
|
||||||
// Compile time log levels
|
|
||||||
// define SPDLOG_DEBUG_ON or SPDLOG_TRACE_ON
|
|
||||||
SPDLOG_TRACE(console, "Enabled only #ifdef SPDLOG_TRACE_ON..{} ,{}", 1, 3.23);
|
|
||||||
SPDLOG_DEBUG(console, "Enabled only #ifdef SPDLOG_DEBUG_ON.. {} ,{}", 1, 3.23);
|
|
||||||
|
|
||||||
|
|
||||||
// Asynchronous logging is very fast..
|
|
||||||
// Just call spdlog::set_async_mode(q_size) and all created loggers from now on will be asynchronous..
|
|
||||||
async_example();
|
|
||||||
|
|
||||||
// syslog example. linux/osx only
|
|
||||||
syslog_example();
|
|
||||||
|
|
||||||
// android example. compile with NDK
|
|
||||||
android_example();
|
|
||||||
|
|
||||||
// Log user-defined types example
|
|
||||||
user_defined_example();
|
|
||||||
|
|
||||||
// Change default log error handler
|
|
||||||
err_handler_example();
|
|
||||||
|
|
||||||
// Apply a function on all registered loggers
|
|
||||||
spd::apply_all([&](std::shared_ptr<spdlog::logger> l)
|
|
||||||
{
|
|
||||||
l->info("End of example.");
|
|
||||||
});
|
|
||||||
|
|
||||||
// Release and close all loggers
|
|
||||||
spdlog::drop_all();
|
|
||||||
}
|
}
|
||||||
// Exceptions will only be thrown upon failed logger or sink construction (not during logging)
|
// e.g. if some error happened:
|
||||||
catch (const spd::spdlog_ex& ex)
|
spdlog::dump_backtrace(); // log them now!
|
||||||
{
|
|
||||||
std::cout << "Log init failed: " << ex.what() << std::endl;
|
try {
|
||||||
|
stdout_logger_example();
|
||||||
|
basic_example();
|
||||||
|
rotating_example();
|
||||||
|
daily_example();
|
||||||
|
callback_example();
|
||||||
|
async_example();
|
||||||
|
binary_example();
|
||||||
|
vector_example();
|
||||||
|
multi_sink_example();
|
||||||
|
user_defined_example();
|
||||||
|
err_handler_example();
|
||||||
|
trace_example();
|
||||||
|
stopwatch_example();
|
||||||
|
udp_example();
|
||||||
|
custom_flags_example();
|
||||||
|
file_events_example();
|
||||||
|
replace_default_logger_example();
|
||||||
|
mdc_example();
|
||||||
|
|
||||||
|
// Flush all *registered* loggers using a worker thread every 3 seconds.
|
||||||
|
// note: registered loggers *must* be thread safe for this to work correctly!
|
||||||
|
spdlog::flush_every(std::chrono::seconds(3));
|
||||||
|
|
||||||
|
// Apply some function on all registered loggers
|
||||||
|
spdlog::apply_all([&](std::shared_ptr<spdlog::logger> l) { l->info("End of example."); });
|
||||||
|
|
||||||
|
// Release all spdlog resources, and drop all loggers in the registry.
|
||||||
|
// This is optional (only mandatory if using windows + async log).
|
||||||
|
spdlog::shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exceptions will only be thrown upon failed logger or sink construction (not during logging).
|
||||||
|
catch (const spdlog::spdlog_ex &ex) {
|
||||||
|
std::printf("Log initialization failed: %s\n", ex.what());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void async_example()
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||||
{
|
// or #include "spdlog/sinks/stdout_sinks.h" if no colors needed.
|
||||||
size_t q_size = 4096; //queue size must be power of 2
|
void stdout_logger_example() {
|
||||||
spdlog::set_async_mode(q_size);
|
// Create color multi threaded logger.
|
||||||
auto async_file = spd::daily_logger_st("async_file_logger", "logs/async_log.txt");
|
auto console = spdlog::stdout_color_mt("console");
|
||||||
for (int i = 0; i < 100; ++i)
|
// or for stderr:
|
||||||
|
// auto console = spdlog::stderr_color_mt("error-logger");
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "spdlog/sinks/basic_file_sink.h"
|
||||||
|
void basic_example() {
|
||||||
|
// Create basic file logger (not rotated).
|
||||||
|
auto my_logger = spdlog::basic_logger_mt("file_logger", "logs/basic-log.txt", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "spdlog/sinks/rotating_file_sink.h"
|
||||||
|
void rotating_example() {
|
||||||
|
// Create a file rotating logger with 5mb size max and 3 rotated files.
|
||||||
|
auto rotating_logger =
|
||||||
|
spdlog::rotating_logger_mt("some_logger_name", "logs/rotating.txt", 1048576 * 5, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "spdlog/sinks/daily_file_sink.h"
|
||||||
|
void daily_example() {
|
||||||
|
// Create a daily logger - a new file is created every day on 2:30am.
|
||||||
|
auto daily_logger = spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "spdlog/sinks/callback_sink.h"
|
||||||
|
void callback_example() {
|
||||||
|
// Create the logger
|
||||||
|
auto logger = spdlog::callback_logger_mt("custom_callback_logger",
|
||||||
|
[](const spdlog::details::log_msg & /*msg*/) {
|
||||||
|
// do what you need to do with msg
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "spdlog/cfg/env.h"
|
||||||
|
void load_levels_example() {
|
||||||
|
// Set the log level to "info" and mylogger to "trace":
|
||||||
|
// SPDLOG_LEVEL=info,mylogger=trace && ./example
|
||||||
|
spdlog::cfg::load_env_levels();
|
||||||
|
// or specify the env variable name:
|
||||||
|
// MYAPP_LEVEL=info,mylogger=trace && ./example
|
||||||
|
// spdlog::cfg::load_env_levels("MYAPP_LEVEL");
|
||||||
|
// or from command line:
|
||||||
|
// ./example SPDLOG_LEVEL=info,mylogger=trace
|
||||||
|
// #include "spdlog/cfg/argv.h" // for loading levels from argv
|
||||||
|
// spdlog::cfg::load_argv_levels(args, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "spdlog/async.h"
|
||||||
|
void async_example() {
|
||||||
|
// Default thread pool settings can be modified *before* creating the async logger:
|
||||||
|
// spdlog::init_thread_pool(32768, 1); // queue with max 32k items 1 backing thread.
|
||||||
|
auto async_file =
|
||||||
|
spdlog::basic_logger_mt<spdlog::async_factory>("async_file_logger", "logs/async_log.txt");
|
||||||
|
// alternatively:
|
||||||
|
// auto async_file =
|
||||||
|
// spdlog::create_async<spdlog::sinks::basic_file_sink_mt>("async_file_logger",
|
||||||
|
// "logs/async_log.txt");
|
||||||
|
|
||||||
|
for (int i = 1; i < 101; ++i) {
|
||||||
async_file->info("Async message #{}", i);
|
async_file->info("Async message #{}", i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//syslog example (linux/osx/freebsd)
|
// Log binary data as hex.
|
||||||
void syslog_example()
|
// Many types of std::container<char> types can be used.
|
||||||
{
|
// Iterator ranges are supported too.
|
||||||
#ifdef SPDLOG_ENABLE_SYSLOG
|
// Format flags:
|
||||||
std::string ident = "spdlog-example";
|
// {:X} - print in uppercase.
|
||||||
auto syslog_logger = spd::syslog_logger("syslog", ident, LOG_PID);
|
// {:s} - don't separate each byte with space.
|
||||||
syslog_logger->warn("This is warning that will end up in syslog.");
|
// {:p} - don't print the position on each line start.
|
||||||
|
// {:n} - don't split the output to lines.
|
||||||
|
|
||||||
|
#if !defined SPDLOG_USE_STD_FORMAT || defined(_MSC_VER)
|
||||||
|
#include "spdlog/fmt/bin_to_hex.h"
|
||||||
|
void binary_example() {
|
||||||
|
std::vector<char> buf;
|
||||||
|
for (int i = 0; i < 80; i++) {
|
||||||
|
buf.push_back(static_cast<char>(i & 0xff));
|
||||||
|
}
|
||||||
|
spdlog::info("Binary example: {}", spdlog::to_hex(buf));
|
||||||
|
spdlog::info("Another binary example:{:n}",
|
||||||
|
spdlog::to_hex(std::begin(buf), std::begin(buf) + 10));
|
||||||
|
// more examples:
|
||||||
|
// logger->info("uppercase: {:X}", spdlog::to_hex(buf));
|
||||||
|
// logger->info("uppercase, no delimiters: {:Xs}", spdlog::to_hex(buf));
|
||||||
|
// logger->info("uppercase, no delimiters, no position info: {:Xsp}", spdlog::to_hex(buf));
|
||||||
|
// logger->info("hexdump style: {:a}", spdlog::to_hex(buf));
|
||||||
|
// logger->info("hexdump style, 20 chars per line {:a}", spdlog::to_hex(buf, 20));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void binary_example() {
|
||||||
|
// not supported with std::format yet
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Log a vector of numbers
|
||||||
|
#ifndef SPDLOG_USE_STD_FORMAT
|
||||||
|
#include "spdlog/fmt/ranges.h"
|
||||||
|
void vector_example() {
|
||||||
|
std::vector<int> vec = {1, 2, 3};
|
||||||
|
spdlog::info("Vector example: {}", vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Android example
|
#else
|
||||||
void android_example()
|
void vector_example() {}
|
||||||
{
|
|
||||||
#if defined(__ANDROID__)
|
|
||||||
std::string tag = "spdlog-android";
|
|
||||||
auto android_logger = spd::android_logger("android", tag);
|
|
||||||
android_logger->critical("Use \"adb shell logcat\" to view this message.");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ! DSPDLOG_USE_STD_FORMAT
|
||||||
|
|
||||||
|
// Compile time log levels.
|
||||||
|
// define SPDLOG_ACTIVE_LEVEL to required level (e.g. SPDLOG_LEVEL_TRACE)
|
||||||
|
void trace_example() {
|
||||||
|
// trace from default logger
|
||||||
|
SPDLOG_TRACE("Some trace message.. {} ,{}", 1, 3.23);
|
||||||
|
// debug from default logger
|
||||||
|
SPDLOG_DEBUG("Some debug message.. {} ,{}", 1, 3.23);
|
||||||
|
|
||||||
|
// trace from logger object
|
||||||
|
auto logger = spdlog::get("file_logger");
|
||||||
|
SPDLOG_LOGGER_TRACE(logger, "another trace message");
|
||||||
}
|
}
|
||||||
|
|
||||||
// user defined types logging by implementing operator<<
|
// stopwatch example
|
||||||
struct my_type
|
#include "spdlog/stopwatch.h"
|
||||||
{
|
#include <thread>
|
||||||
int i;
|
void stopwatch_example() {
|
||||||
template<typename OStream>
|
spdlog::stopwatch sw;
|
||||||
friend OStream& operator<<(OStream& os, const my_type &c)
|
std::this_thread::sleep_for(std::chrono::milliseconds(123));
|
||||||
{
|
spdlog::info("Stopwatch: {} seconds", sw);
|
||||||
return os << "[my_type i="<<c.i << "]";
|
}
|
||||||
|
|
||||||
|
#include "spdlog/sinks/udp_sink.h"
|
||||||
|
void udp_example() {
|
||||||
|
spdlog::sinks::udp_sink_config cfg("127.0.0.1", 11091);
|
||||||
|
auto my_logger = spdlog::udp_logger_mt("udplog", cfg);
|
||||||
|
my_logger->set_level(spdlog::level::debug);
|
||||||
|
my_logger->info("hello world");
|
||||||
|
}
|
||||||
|
|
||||||
|
// A logger with multiple sinks (stdout and file) - each with a different format and log level.
|
||||||
|
void multi_sink_example() {
|
||||||
|
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
|
||||||
|
console_sink->set_level(spdlog::level::warn);
|
||||||
|
console_sink->set_pattern("[multi_sink_example] [%^%l%$] %v");
|
||||||
|
|
||||||
|
auto file_sink =
|
||||||
|
std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/multisink.txt", true);
|
||||||
|
file_sink->set_level(spdlog::level::trace);
|
||||||
|
|
||||||
|
spdlog::logger logger("multi_sink", {console_sink, file_sink});
|
||||||
|
logger.set_level(spdlog::level::debug);
|
||||||
|
logger.warn("this should appear in both console and file");
|
||||||
|
logger.info("this message should not appear in the console, only in the file");
|
||||||
|
}
|
||||||
|
|
||||||
|
// User defined types logging
|
||||||
|
struct my_type {
|
||||||
|
int i = 0;
|
||||||
|
explicit my_type(int i)
|
||||||
|
: i(i){}
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef SPDLOG_USE_STD_FORMAT // when using fmtlib
|
||||||
|
template <>
|
||||||
|
struct fmt::formatter<my_type> : fmt::formatter<std::string> {
|
||||||
|
auto format(my_type my, format_context &ctx) const -> decltype(ctx.out()) {
|
||||||
|
return fmt::format_to(ctx.out(), "[my_type i={}]", my.i);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "spdlog/fmt/ostr.h" // must be included
|
#else // when using std::format
|
||||||
void user_defined_example()
|
template <>
|
||||||
{
|
struct std::formatter<my_type> : std::formatter<std::string> {
|
||||||
spd::get("console")->info("user defined type: {}", my_type { 14 });
|
auto format(my_type my, format_context &ctx) const -> decltype(ctx.out()) {
|
||||||
|
return std::format_to(ctx.out(), "[my_type i={}]", my.i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void user_defined_example() { spdlog::info("user defined type: {}", my_type(14)); }
|
||||||
|
|
||||||
|
// Custom error handler. Will be triggered on log failure.
|
||||||
|
void err_handler_example() {
|
||||||
|
// can be set globally or per logger(logger->set_error_handler(..))
|
||||||
|
spdlog::set_error_handler([](const std::string &msg) {
|
||||||
|
printf("*** Custom log error handler: %s ***\n", msg.c_str());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// syslog example (linux/osx/freebsd)
|
||||||
//custom error handler
|
#ifndef _WIN32
|
||||||
//
|
#include "spdlog/sinks/syslog_sink.h"
|
||||||
void err_handler_example()
|
void syslog_example() {
|
||||||
{
|
std::string ident = "spdlog-example";
|
||||||
//can be set globaly or per logger(logger->set_error_handler(..))
|
auto syslog_logger = spdlog::syslog_logger_mt("syslog", ident, LOG_PID);
|
||||||
spdlog::set_error_handler([](const std::string& msg)
|
syslog_logger->warn("This is warning that will end up in syslog.");
|
||||||
{
|
|
||||||
std::cerr << "my err handler: " << msg << std::endl;
|
|
||||||
});
|
|
||||||
spd::get("console")->info("some invalid message to trigger an error {}{}{}{}", 3);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Android example.
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
#include "spdlog/sinks/android_sink.h"
|
||||||
|
void android_example() {
|
||||||
|
std::string tag = "spdlog-android";
|
||||||
|
auto android_logger = spdlog::android_logger_mt("android", tag);
|
||||||
|
android_logger->critical("Use \"adb shell logcat\" to view this message.");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Log patterns can contain custom flags.
|
||||||
|
// this will add custom flag '%*' which will be bound to a <my_formatter_flag> instance
|
||||||
|
#include "spdlog/pattern_formatter.h"
|
||||||
|
class my_formatter_flag : public spdlog::custom_flag_formatter {
|
||||||
|
public:
|
||||||
|
void format(const spdlog::details::log_msg &,
|
||||||
|
const std::tm &,
|
||||||
|
spdlog::memory_buf_t &dest) override {
|
||||||
|
std::string some_txt = "custom-flag";
|
||||||
|
dest.append(some_txt.data(), some_txt.data() + some_txt.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<custom_flag_formatter> clone() const override {
|
||||||
|
return spdlog::details::make_unique<my_formatter_flag>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void custom_flags_example() {
|
||||||
|
using spdlog::details::make_unique; // for pre c++14
|
||||||
|
auto formatter = make_unique<spdlog::pattern_formatter>();
|
||||||
|
formatter->add_flag<my_formatter_flag>('*').set_pattern("[%n] [%*] [%^%l%$] %v");
|
||||||
|
// set the new formatter using spdlog::set_formatter(formatter) or
|
||||||
|
// logger->set_formatter(formatter) spdlog::set_formatter(std::move(formatter));
|
||||||
|
}
|
||||||
|
|
||||||
|
void file_events_example() {
|
||||||
|
// pass the spdlog::file_event_handlers to file sinks for open/close log file notifications
|
||||||
|
spdlog::file_event_handlers handlers;
|
||||||
|
handlers.before_open = [](spdlog::filename_t filename) {
|
||||||
|
spdlog::info("Before opening {}", filename);
|
||||||
|
};
|
||||||
|
handlers.after_open = [](spdlog::filename_t filename, std::FILE *fstream) {
|
||||||
|
spdlog::info("After opening {}", filename);
|
||||||
|
fputs("After opening\n", fstream);
|
||||||
|
};
|
||||||
|
handlers.before_close = [](spdlog::filename_t filename, std::FILE *fstream) {
|
||||||
|
spdlog::info("Before closing {}", filename);
|
||||||
|
fputs("Before closing\n", fstream);
|
||||||
|
};
|
||||||
|
handlers.after_close = [](spdlog::filename_t filename) {
|
||||||
|
spdlog::info("After closing {}", filename);
|
||||||
|
};
|
||||||
|
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/events-sample.txt",
|
||||||
|
true, handlers);
|
||||||
|
spdlog::logger my_logger("some_logger", file_sink);
|
||||||
|
my_logger.info("Some log line");
|
||||||
|
}
|
||||||
|
|
||||||
|
void replace_default_logger_example() {
|
||||||
|
// store the old logger so we don't break other examples.
|
||||||
|
auto old_logger = spdlog::default_logger();
|
||||||
|
|
||||||
|
auto new_logger =
|
||||||
|
spdlog::basic_logger_mt("new_default_logger", "logs/new-default-log.txt", true);
|
||||||
|
spdlog::set_default_logger(new_logger);
|
||||||
|
spdlog::set_level(spdlog::level::info);
|
||||||
|
spdlog::debug("This message should not be displayed!");
|
||||||
|
spdlog::set_level(spdlog::level::trace);
|
||||||
|
spdlog::debug("This message should be displayed..");
|
||||||
|
|
||||||
|
spdlog::set_default_logger(old_logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mapped Diagnostic Context (MDC) is a map that stores key-value pairs (string values) in thread local storage.
|
||||||
|
// Each thread maintains its own MDC, which loggers use to append diagnostic information to log outputs.
|
||||||
|
// Note: it is not supported in asynchronous mode due to its reliance on thread-local storage.
|
||||||
|
|
||||||
|
#ifndef SPDLOG_NO_TLS
|
||||||
|
#include "spdlog/mdc.h"
|
||||||
|
void mdc_example()
|
||||||
|
{
|
||||||
|
spdlog::mdc::put("key1", "value1");
|
||||||
|
spdlog::mdc::put("key2", "value2");
|
||||||
|
// if not using the default format, you can use the %& formatter to print mdc data as well
|
||||||
|
spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [%&] %v");
|
||||||
|
spdlog::info("Some log message with context");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void mdc_example() {
|
||||||
|
// if TLS feature is disabled
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio 14
|
|
||||||
VisualStudioVersion = 14.0.25420.1
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcxproj", "{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Win32 = Debug|Win32
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Release|Win32 = Release|Win32
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Debug|x64.ActiveCfg = Debug|Win32
|
|
||||||
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Release|x64.ActiveCfg = Release|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
@ -1,126 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="example.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="..\include\spdlog\async_logger.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\common.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\details\async_logger_impl.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\details\async_log_helper.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\details\file_helper.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\details\logger_impl.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\details\log_msg.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\details\mpmc_bounded_q.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\details\null_mutex.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\details\os.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\details\pattern_formatter_impl.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\details\registry.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\details\spdlog_impl.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\fmt\fmt.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\fmt\ostr.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\formatter.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\logger.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\sinks\android_sink.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\sinks\ansicolor_sink.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\sinks\base_sink.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\sinks\dist_sink.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\sinks\file_sinks.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\sinks\msvc_sink.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\sinks\null_sink.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\sinks\ostream_sink.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\sinks\sink.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\sinks\stdout_sinks.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\sinks\syslog_sink.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\sinks\wincolor_sink.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\spdlog.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\tweakme.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}</ProjectGuid>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<RootNamespace>.</RootNamespace>
|
|
||||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PrecompiledHeaderFile />
|
|
||||||
<PrecompiledHeaderOutputFile />
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PrecompiledHeaderFile />
|
|
||||||
<PrecompiledHeaderOutputFile />
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@ -1,15 +0,0 @@
|
|||||||
# Setup a project
|
|
||||||
LOCAL_PATH := $(call my-dir)
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
LOCAL_MODULE := example
|
|
||||||
LOCAL_SRC_FILES := example.cpp
|
|
||||||
LOCAL_CPPFLAGS += -Wall -Wshadow -Wextra -pedantic -std=c++11 -fPIE -pie
|
|
||||||
LOCAL_LDFLAGS += -fPIE -pie
|
|
||||||
|
|
||||||
# Add exception support and set path for spdlog's headers
|
|
||||||
LOCAL_CPPFLAGS += -fexceptions -I../include
|
|
||||||
# Use android's log library
|
|
||||||
LOCAL_LDFLAGS += -llog
|
|
||||||
|
|
||||||
include $(BUILD_EXECUTABLE)
|
|
@ -1,2 +0,0 @@
|
|||||||
# Exceptions are used in spdlog. Link to an exception-ready C++ runtime.
|
|
||||||
APP_STL = gnustl_static
|
|
@ -1 +0,0 @@
|
|||||||
../example.cpp
|
|
1
example/logs/.gitignore
vendored
1
example/logs/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
*.txt
|
|
@ -1,47 +0,0 @@
|
|||||||
#include "spdlog/spdlog.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace spd = spdlog;
|
|
||||||
int main(int, char*[])
|
|
||||||
{
|
|
||||||
bool enable_debug = true;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// This other example use a single logger with multiple sinks.
|
|
||||||
// This means that the same log_msg is forwarded to multiple sinks;
|
|
||||||
// Each sink can have it's own log level and a message will be logged.
|
|
||||||
std::vector<spdlog::sink_ptr> sinks;
|
|
||||||
sinks.push_back( std::make_shared<spdlog::sinks::stdout_sink_mt>() );
|
|
||||||
sinks.push_back( std::make_shared<spdlog::sinks::simple_file_sink_mt>("./log_regular_file.txt") );
|
|
||||||
sinks.push_back( std::make_shared<spdlog::sinks::simple_file_sink_mt>("./log_debug_file.txt") );
|
|
||||||
|
|
||||||
spdlog::logger console_multisink("multisink", sinks.begin(), sinks.end() );
|
|
||||||
console_multisink.set_level( spdlog::level::warn);
|
|
||||||
|
|
||||||
sinks[0]->set_level( spdlog::level::trace); // console. Allow everything. Default value
|
|
||||||
sinks[1]->set_level( spdlog::level::trace); // regular file. Allow everything. Default value
|
|
||||||
sinks[2]->set_level( spdlog::level::off); // regular file. Ignore everything.
|
|
||||||
|
|
||||||
console_multisink.warn("warn: will print only on console and regular file");
|
|
||||||
|
|
||||||
if( enable_debug )
|
|
||||||
{
|
|
||||||
console_multisink.set_level( spdlog::level::debug); // level of the logger
|
|
||||||
sinks[1]->set_level( spdlog::level::debug); // regular file
|
|
||||||
sinks[2]->set_level( spdlog::level::debug); // debug file
|
|
||||||
}
|
|
||||||
console_multisink.debug("Debug: you should see this on console and both files");
|
|
||||||
|
|
||||||
// Release and close all loggers
|
|
||||||
spdlog::drop_all();
|
|
||||||
}
|
|
||||||
// Exceptions will only be thrown upon failed logger or sink construction (not during logging)
|
|
||||||
catch (const spd::spdlog_ex& ex)
|
|
||||||
{
|
|
||||||
std::cout << "Log init failed: " << ex.what() << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <locale>
|
|
||||||
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline std::string format(const T& value)
|
|
||||||
{
|
|
||||||
static std::locale loc("");
|
|
||||||
std::stringstream ss;
|
|
||||||
ss.imbue(loc);
|
|
||||||
ss << value;
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
inline std::string format(const double & value)
|
|
||||||
{
|
|
||||||
static std::locale loc("");
|
|
||||||
std::stringstream ss;
|
|
||||||
ss.imbue(loc);
|
|
||||||
ss << std::fixed << std::setprecision(1) << value;
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
100
include/spdlog/async.h
Normal file
100
include/spdlog/async.h
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
//
|
||||||
|
// Async logging using global thread pool
|
||||||
|
// All loggers created here share same global thread pool.
|
||||||
|
// Each log message is pushed to a queue along with a shared pointer to the
|
||||||
|
// logger.
|
||||||
|
// If a logger deleted while having pending messages in the queue, it's actual
|
||||||
|
// destruction will defer
|
||||||
|
// until all its messages are processed by the thread pool.
|
||||||
|
// This is because each message in the queue holds a shared_ptr to the
|
||||||
|
// originating logger.
|
||||||
|
|
||||||
|
#include <spdlog/async_logger.h>
|
||||||
|
#include <spdlog/details/registry.h>
|
||||||
|
#include <spdlog/details/thread_pool.h>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
|
||||||
|
namespace details {
|
||||||
|
static const size_t default_async_q_size = 8192;
|
||||||
|
}
|
||||||
|
|
||||||
|
// async logger factory - creates async loggers backed with thread pool.
|
||||||
|
// if a global thread pool doesn't already exist, create it with default queue
|
||||||
|
// size of 8192 items and single thread.
|
||||||
|
template <async_overflow_policy OverflowPolicy = async_overflow_policy::block>
|
||||||
|
struct async_factory_impl {
|
||||||
|
template <typename Sink, typename... SinkArgs>
|
||||||
|
static std::shared_ptr<async_logger> create(std::string logger_name, SinkArgs &&...args) {
|
||||||
|
auto ®istry_inst = details::registry::instance();
|
||||||
|
|
||||||
|
// create global thread pool if not already exists..
|
||||||
|
|
||||||
|
auto &mutex = registry_inst.tp_mutex();
|
||||||
|
std::lock_guard<std::recursive_mutex> tp_lock(mutex);
|
||||||
|
auto tp = registry_inst.get_tp();
|
||||||
|
if (tp == nullptr) {
|
||||||
|
tp = std::make_shared<details::thread_pool>(details::default_async_q_size, 1U);
|
||||||
|
registry_inst.set_tp(tp);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto sink = std::make_shared<Sink>(std::forward<SinkArgs>(args)...);
|
||||||
|
auto new_logger = std::make_shared<async_logger>(std::move(logger_name), std::move(sink),
|
||||||
|
std::move(tp), OverflowPolicy);
|
||||||
|
registry_inst.initialize_logger(new_logger);
|
||||||
|
return new_logger;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
using async_factory = async_factory_impl<async_overflow_policy::block>;
|
||||||
|
using async_factory_nonblock = async_factory_impl<async_overflow_policy::overrun_oldest>;
|
||||||
|
|
||||||
|
template <typename Sink, typename... SinkArgs>
|
||||||
|
inline std::shared_ptr<spdlog::logger> create_async(std::string logger_name,
|
||||||
|
SinkArgs &&...sink_args) {
|
||||||
|
return async_factory::create<Sink>(std::move(logger_name),
|
||||||
|
std::forward<SinkArgs>(sink_args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Sink, typename... SinkArgs>
|
||||||
|
inline std::shared_ptr<spdlog::logger> create_async_nb(std::string logger_name,
|
||||||
|
SinkArgs &&...sink_args) {
|
||||||
|
return async_factory_nonblock::create<Sink>(std::move(logger_name),
|
||||||
|
std::forward<SinkArgs>(sink_args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set global thread pool.
|
||||||
|
inline void init_thread_pool(size_t q_size,
|
||||||
|
size_t thread_count,
|
||||||
|
std::function<void()> on_thread_start,
|
||||||
|
std::function<void()> on_thread_stop) {
|
||||||
|
auto tp = std::make_shared<details::thread_pool>(q_size, thread_count, on_thread_start,
|
||||||
|
on_thread_stop);
|
||||||
|
details::registry::instance().set_tp(std::move(tp));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void init_thread_pool(size_t q_size,
|
||||||
|
size_t thread_count,
|
||||||
|
std::function<void()> on_thread_start) {
|
||||||
|
init_thread_pool(q_size, thread_count, on_thread_start, [] {});
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void init_thread_pool(size_t q_size, size_t thread_count) {
|
||||||
|
init_thread_pool(
|
||||||
|
q_size, thread_count, [] {}, [] {});
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the global thread pool.
|
||||||
|
inline std::shared_ptr<spdlog::details::thread_pool> thread_pool() {
|
||||||
|
return details::registry::instance().get_tp();
|
||||||
|
}
|
||||||
|
} // namespace spdlog
|
84
include/spdlog/async_logger-inl.h
Normal file
84
include/spdlog/async_logger-inl.h
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef SPDLOG_HEADER_ONLY
|
||||||
|
#include <spdlog/async_logger.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <spdlog/details/thread_pool.h>
|
||||||
|
#include <spdlog/sinks/sink.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
SPDLOG_INLINE spdlog::async_logger::async_logger(std::string logger_name,
|
||||||
|
sinks_init_list sinks_list,
|
||||||
|
std::weak_ptr<details::thread_pool> tp,
|
||||||
|
async_overflow_policy overflow_policy)
|
||||||
|
: async_logger(std::move(logger_name),
|
||||||
|
sinks_list.begin(),
|
||||||
|
sinks_list.end(),
|
||||||
|
std::move(tp),
|
||||||
|
overflow_policy) {}
|
||||||
|
|
||||||
|
SPDLOG_INLINE spdlog::async_logger::async_logger(std::string logger_name,
|
||||||
|
sink_ptr single_sink,
|
||||||
|
std::weak_ptr<details::thread_pool> tp,
|
||||||
|
async_overflow_policy overflow_policy)
|
||||||
|
: async_logger(
|
||||||
|
std::move(logger_name), {std::move(single_sink)}, std::move(tp), overflow_policy) {}
|
||||||
|
|
||||||
|
// send the log message to the thread pool
|
||||||
|
SPDLOG_INLINE void spdlog::async_logger::sink_it_(const details::log_msg &msg){
|
||||||
|
SPDLOG_TRY{if (auto pool_ptr = thread_pool_.lock()){
|
||||||
|
pool_ptr->post_log(shared_from_this(), msg, overflow_policy_);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw_spdlog_ex("async log: thread pool doesn't exist anymore");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SPDLOG_LOGGER_CATCH(msg.source)
|
||||||
|
}
|
||||||
|
|
||||||
|
// send flush request to the thread pool
|
||||||
|
SPDLOG_INLINE void spdlog::async_logger::flush_(){
|
||||||
|
SPDLOG_TRY{if (auto pool_ptr = thread_pool_.lock()){
|
||||||
|
pool_ptr->post_flush(shared_from_this(), overflow_policy_);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw_spdlog_ex("async flush: thread pool doesn't exist anymore");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SPDLOG_LOGGER_CATCH(source_loc())
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// backend functions - called from the thread pool to do the actual job
|
||||||
|
//
|
||||||
|
SPDLOG_INLINE void spdlog::async_logger::backend_sink_it_(const details::log_msg &msg) {
|
||||||
|
for (auto &sink : sinks_) {
|
||||||
|
if (sink->should_log(msg.level)) {
|
||||||
|
SPDLOG_TRY { sink->log(msg); }
|
||||||
|
SPDLOG_LOGGER_CATCH(msg.source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (should_flush_(msg)) {
|
||||||
|
backend_flush_();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void spdlog::async_logger::backend_flush_() {
|
||||||
|
for (auto &sink : sinks_) {
|
||||||
|
SPDLOG_TRY { sink->flush(); }
|
||||||
|
SPDLOG_LOGGER_CATCH(source_loc())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE std::shared_ptr<spdlog::logger> spdlog::async_logger::clone(std::string new_name) {
|
||||||
|
auto cloned = std::make_shared<spdlog::async_logger>(*this);
|
||||||
|
cloned->name_ = std::move(new_name);
|
||||||
|
return cloned;
|
||||||
|
}
|
@ -1,82 +1,74 @@
|
|||||||
//
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Very fast asynchronous logger (millions of logs per second on an average desktop)
|
// Fast asynchronous logger.
|
||||||
// Uses pre allocated lockfree queue for maximum throughput even under large number of threads.
|
// Uses pre allocated queue.
|
||||||
// Creates a single back thread to pop messages from the queue and log them.
|
// Creates a single back thread to pop messages from the queue and log them.
|
||||||
//
|
//
|
||||||
// Upon each log write the logger:
|
// Upon each log write the logger:
|
||||||
// 1. Checks if its log level is enough to log the message
|
// 1. Checks if its log level is enough to log the message
|
||||||
// 2. Push a new copy of the message to a queue (or block the caller until space is available in the queue)
|
// 2. Push a new copy of the message to a queue (or block the caller until
|
||||||
// 3. will throw spdlog_ex upon log exceptions
|
// space is available in the queue)
|
||||||
// Upon destruction, logs all remaining messages in the queue before destructing..
|
// Upon destruction, logs all remaining messages in the queue before
|
||||||
|
// destructing..
|
||||||
|
|
||||||
#include "common.h"
|
#include <spdlog/logger.h>
|
||||||
#include "logger.h"
|
|
||||||
|
|
||||||
#include <chrono>
|
namespace spdlog {
|
||||||
#include <functional>
|
|
||||||
#include <string>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace spdlog
|
// Async overflow policy - block by default.
|
||||||
{
|
enum class async_overflow_policy {
|
||||||
|
block, // Block until message can be enqueued
|
||||||
|
overrun_oldest, // Discard oldest message in the queue if full when trying to
|
||||||
|
// add new item.
|
||||||
|
discard_new // Discard new message if the queue is full when trying to add new item.
|
||||||
|
};
|
||||||
|
|
||||||
namespace details
|
namespace details {
|
||||||
{
|
class thread_pool;
|
||||||
class async_log_helper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class async_logger SPDLOG_FINAL :public logger
|
class SPDLOG_API async_logger final : public std::enable_shared_from_this<async_logger>,
|
||||||
{
|
public logger {
|
||||||
|
friend class details::thread_pool;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template<class It>
|
template <typename It>
|
||||||
async_logger(const std::string& name,
|
async_logger(std::string logger_name,
|
||||||
const It& begin,
|
It begin,
|
||||||
const It& end,
|
It end,
|
||||||
size_t queue_size,
|
std::weak_ptr<details::thread_pool> tp,
|
||||||
const async_overflow_policy overflow_policy = async_overflow_policy::block_retry,
|
async_overflow_policy overflow_policy = async_overflow_policy::block)
|
||||||
const std::function<void()>& worker_warmup_cb = nullptr,
|
: logger(std::move(logger_name), begin, end),
|
||||||
const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
|
thread_pool_(std::move(tp)),
|
||||||
const std::function<void()>& worker_teardown_cb = nullptr);
|
overflow_policy_(overflow_policy) {}
|
||||||
|
|
||||||
async_logger(const std::string& logger_name,
|
async_logger(std::string logger_name,
|
||||||
sinks_init_list sinks,
|
sinks_init_list sinks_list,
|
||||||
size_t queue_size,
|
std::weak_ptr<details::thread_pool> tp,
|
||||||
const async_overflow_policy overflow_policy = async_overflow_policy::block_retry,
|
async_overflow_policy overflow_policy = async_overflow_policy::block);
|
||||||
const std::function<void()>& worker_warmup_cb = nullptr,
|
|
||||||
const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
|
|
||||||
const std::function<void()>& worker_teardown_cb = nullptr);
|
|
||||||
|
|
||||||
async_logger(const std::string& logger_name,
|
async_logger(std::string logger_name,
|
||||||
sink_ptr single_sink,
|
sink_ptr single_sink,
|
||||||
size_t queue_size,
|
std::weak_ptr<details::thread_pool> tp,
|
||||||
const async_overflow_policy overflow_policy = async_overflow_policy::block_retry,
|
async_overflow_policy overflow_policy = async_overflow_policy::block);
|
||||||
const std::function<void()>& worker_warmup_cb = nullptr,
|
|
||||||
const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
|
|
||||||
const std::function<void()>& worker_teardown_cb = nullptr);
|
|
||||||
|
|
||||||
//Wait for the queue to be empty, and flush synchronously
|
std::shared_ptr<logger> clone(std::string new_name) override;
|
||||||
//Warning: this can potentially last forever as we wait it to complete
|
|
||||||
void flush() override;
|
|
||||||
|
|
||||||
// Error handler
|
|
||||||
virtual void set_error_handler(log_err_handler) override;
|
|
||||||
virtual log_err_handler error_handler() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _sink_it(details::log_msg& msg) override;
|
void sink_it_(const details::log_msg &msg) override;
|
||||||
void _set_formatter(spdlog::formatter_ptr msg_formatter) override;
|
void flush_() override;
|
||||||
void _set_pattern(const std::string& pattern, pattern_time_type pattern_time) override;
|
void backend_sink_it_(const details::log_msg &incoming_log_msg);
|
||||||
|
void backend_flush_();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<details::async_log_helper> _async_log_helper;
|
std::weak_ptr<details::thread_pool> thread_pool_;
|
||||||
|
async_overflow_policy overflow_policy_;
|
||||||
};
|
};
|
||||||
}
|
} // namespace spdlog
|
||||||
|
|
||||||
|
#ifdef SPDLOG_HEADER_ONLY
|
||||||
#include "details/async_logger_impl.h"
|
#include "async_logger-inl.h"
|
||||||
|
#endif
|
||||||
|
40
include/spdlog/cfg/argv.h
Normal file
40
include/spdlog/cfg/argv.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <spdlog/cfg/helpers.h>
|
||||||
|
#include <spdlog/details/registry.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// Init log levels using each argv entry that starts with "SPDLOG_LEVEL="
|
||||||
|
//
|
||||||
|
// set all loggers to debug level:
|
||||||
|
// example.exe "SPDLOG_LEVEL=debug"
|
||||||
|
|
||||||
|
// set logger1 to trace level
|
||||||
|
// example.exe "SPDLOG_LEVEL=logger1=trace"
|
||||||
|
|
||||||
|
// turn off all logging except for logger1 and logger2:
|
||||||
|
// example.exe "SPDLOG_LEVEL=off,logger1=debug,logger2=info"
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace cfg {
|
||||||
|
|
||||||
|
// search for SPDLOG_LEVEL= in the args and use it to init the levels
|
||||||
|
inline void load_argv_levels(int argc, const char **argv) {
|
||||||
|
const std::string spdlog_level_prefix = "SPDLOG_LEVEL=";
|
||||||
|
for (int i = 1; i < argc; i++) {
|
||||||
|
std::string arg = argv[i];
|
||||||
|
if (arg.find(spdlog_level_prefix) == 0) {
|
||||||
|
auto levels_string = arg.substr(spdlog_level_prefix.size());
|
||||||
|
helpers::load_levels(levels_string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void load_argv_levels(int argc, char **argv) {
|
||||||
|
load_argv_levels(argc, const_cast<const char **>(argv));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace cfg
|
||||||
|
} // namespace spdlog
|
36
include/spdlog/cfg/env.h
Normal file
36
include/spdlog/cfg/env.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <spdlog/cfg/helpers.h>
|
||||||
|
#include <spdlog/details/os.h>
|
||||||
|
#include <spdlog/details/registry.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// Init levels and patterns from env variables SPDLOG_LEVEL
|
||||||
|
// Inspired from Rust's "env_logger" crate (https://crates.io/crates/env_logger).
|
||||||
|
// Note - fallback to "info" level on unrecognized levels
|
||||||
|
//
|
||||||
|
// Examples:
|
||||||
|
//
|
||||||
|
// set global level to debug:
|
||||||
|
// export SPDLOG_LEVEL=debug
|
||||||
|
//
|
||||||
|
// turn off all logging except for logger1:
|
||||||
|
// export SPDLOG_LEVEL="*=off,logger1=debug"
|
||||||
|
//
|
||||||
|
|
||||||
|
// turn off all logging except for logger1 and logger2:
|
||||||
|
// export SPDLOG_LEVEL="off,logger1=debug,logger2=info"
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace cfg {
|
||||||
|
inline void load_env_levels(const char* var = "SPDLOG_LEVEL") {
|
||||||
|
auto env_val = details::os::getenv(var);
|
||||||
|
if (!env_val.empty()) {
|
||||||
|
helpers::load_levels(env_val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace cfg
|
||||||
|
} // namespace spdlog
|
107
include/spdlog/cfg/helpers-inl.h
Normal file
107
include/spdlog/cfg/helpers-inl.h
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef SPDLOG_HEADER_ONLY
|
||||||
|
#include <spdlog/cfg/helpers.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <spdlog/details/os.h>
|
||||||
|
#include <spdlog/details/registry.h>
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace cfg {
|
||||||
|
namespace helpers {
|
||||||
|
|
||||||
|
// inplace convert to lowercase
|
||||||
|
inline std::string &to_lower_(std::string &str) {
|
||||||
|
std::transform(str.begin(), str.end(), str.begin(), [](char ch) {
|
||||||
|
return static_cast<char>((ch >= 'A' && ch <= 'Z') ? ch + ('a' - 'A') : ch);
|
||||||
|
});
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
// inplace trim spaces
|
||||||
|
inline std::string &trim_(std::string &str) {
|
||||||
|
const char *spaces = " \n\r\t";
|
||||||
|
str.erase(str.find_last_not_of(spaces) + 1);
|
||||||
|
str.erase(0, str.find_first_not_of(spaces));
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return (name,value) trimmed pair from given "name=value" string.
|
||||||
|
// return empty string on missing parts
|
||||||
|
// "key=val" => ("key", "val")
|
||||||
|
// " key = val " => ("key", "val")
|
||||||
|
// "key=" => ("key", "")
|
||||||
|
// "val" => ("", "val")
|
||||||
|
|
||||||
|
inline std::pair<std::string, std::string> extract_kv_(char sep, const std::string &str) {
|
||||||
|
auto n = str.find(sep);
|
||||||
|
std::string k, v;
|
||||||
|
if (n == std::string::npos) {
|
||||||
|
v = str;
|
||||||
|
} else {
|
||||||
|
k = str.substr(0, n);
|
||||||
|
v = str.substr(n + 1);
|
||||||
|
}
|
||||||
|
return std::make_pair(trim_(k), trim_(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
// return vector of key/value pairs from sequence of "K1=V1,K2=V2,.."
|
||||||
|
// "a=AAA,b=BBB,c=CCC,.." => {("a","AAA"),("b","BBB"),("c", "CCC"),...}
|
||||||
|
inline std::unordered_map<std::string, std::string> extract_key_vals_(const std::string &str) {
|
||||||
|
std::string token;
|
||||||
|
std::istringstream token_stream(str);
|
||||||
|
std::unordered_map<std::string, std::string> rv{};
|
||||||
|
while (std::getline(token_stream, token, ',')) {
|
||||||
|
if (token.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto kv = extract_kv_('=', token);
|
||||||
|
rv[kv.first] = kv.second;
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void load_levels(const std::string &input) {
|
||||||
|
if (input.empty() || input.size() > 512) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto key_vals = extract_key_vals_(input);
|
||||||
|
std::unordered_map<std::string, level::level_enum> levels;
|
||||||
|
level::level_enum global_level = level::info;
|
||||||
|
bool global_level_found = false;
|
||||||
|
|
||||||
|
for (auto &name_level : key_vals) {
|
||||||
|
auto &logger_name = name_level.first;
|
||||||
|
auto level_name = to_lower_(name_level.second);
|
||||||
|
auto level = level::from_str(level_name);
|
||||||
|
// ignore unrecognized level names
|
||||||
|
if (level == level::off && level_name != "off") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (logger_name.empty()) // no logger name indicate global level
|
||||||
|
{
|
||||||
|
global_level_found = true;
|
||||||
|
global_level = level;
|
||||||
|
} else {
|
||||||
|
levels[logger_name] = level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
details::registry::instance().set_levels(std::move(levels),
|
||||||
|
global_level_found ? &global_level : nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace helpers
|
||||||
|
} // namespace cfg
|
||||||
|
} // namespace spdlog
|
29
include/spdlog/cfg/helpers.h
Normal file
29
include/spdlog/cfg/helpers.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <spdlog/common.h>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace cfg {
|
||||||
|
namespace helpers {
|
||||||
|
//
|
||||||
|
// Init levels from given string
|
||||||
|
//
|
||||||
|
// Examples:
|
||||||
|
//
|
||||||
|
// set global level to debug: "debug"
|
||||||
|
// turn off all logging except for logger1: "off,logger1=debug"
|
||||||
|
// turn off all logging except for logger1 and logger2: "off,logger1=debug,logger2=info"
|
||||||
|
//
|
||||||
|
SPDLOG_API void load_levels(const std::string &txt);
|
||||||
|
} // namespace helpers
|
||||||
|
|
||||||
|
} // namespace cfg
|
||||||
|
} // namespace spdlog
|
||||||
|
|
||||||
|
#ifdef SPDLOG_HEADER_ONLY
|
||||||
|
#include "helpers-inl.h"
|
||||||
|
#endif // SPDLOG_HEADER_ONLY
|
68
include/spdlog/common-inl.h
Normal file
68
include/spdlog/common-inl.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef SPDLOG_HEADER_ONLY
|
||||||
|
#include <spdlog/common.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace level {
|
||||||
|
|
||||||
|
#if __cplusplus >= 201703L
|
||||||
|
constexpr
|
||||||
|
#endif
|
||||||
|
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
|
||||||
|
|
||||||
|
static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES;
|
||||||
|
|
||||||
|
SPDLOG_INLINE const string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT {
|
||||||
|
return level_string_views[l];
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT {
|
||||||
|
return short_level_names[l];
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT {
|
||||||
|
auto it = std::find(std::begin(level_string_views), std::end(level_string_views), name);
|
||||||
|
if (it != std::end(level_string_views))
|
||||||
|
return static_cast<level::level_enum>(std::distance(std::begin(level_string_views), it));
|
||||||
|
|
||||||
|
// check also for "warn" and "err" before giving up..
|
||||||
|
if (name == "warn") {
|
||||||
|
return level::warn;
|
||||||
|
}
|
||||||
|
if (name == "err") {
|
||||||
|
return level::err;
|
||||||
|
}
|
||||||
|
return level::off;
|
||||||
|
}
|
||||||
|
} // namespace level
|
||||||
|
|
||||||
|
SPDLOG_INLINE spdlog_ex::spdlog_ex(std::string msg)
|
||||||
|
: msg_(std::move(msg)) {}
|
||||||
|
|
||||||
|
SPDLOG_INLINE spdlog_ex::spdlog_ex(const std::string &msg, int last_errno) {
|
||||||
|
#ifdef SPDLOG_USE_STD_FORMAT
|
||||||
|
msg_ = std::system_error(std::error_code(last_errno, std::generic_category()), msg).what();
|
||||||
|
#else
|
||||||
|
memory_buf_t outbuf;
|
||||||
|
fmt::format_system_error(outbuf, last_errno, msg.c_str());
|
||||||
|
msg_ = fmt::to_string(outbuf);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE const char *spdlog_ex::what() const SPDLOG_NOEXCEPT { return msg_.c_str(); }
|
||||||
|
|
||||||
|
SPDLOG_INLINE void throw_spdlog_ex(const std::string &msg, int last_errno) {
|
||||||
|
SPDLOG_THROW(spdlog_ex(msg, last_errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void throw_spdlog_ex(std::string msg) { SPDLOG_THROW(spdlog_ex(std::move(msg))); }
|
||||||
|
|
||||||
|
} // namespace spdlog
|
@ -1,161 +1,406 @@
|
|||||||
//
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <spdlog/details/null_mutex.h>
|
||||||
#include <initializer_list>
|
#include <spdlog/tweakme.h>
|
||||||
#include <chrono>
|
|
||||||
#include <memory>
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cstdio>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include<functional>
|
#include <functional>
|
||||||
|
#include <initializer_list>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
#ifdef SPDLOG_USE_STD_FORMAT
|
||||||
#include <codecvt>
|
#include <version>
|
||||||
#include <locale>
|
#if __cpp_lib_format >= 202207L
|
||||||
|
#include <format>
|
||||||
|
#else
|
||||||
|
#include <string_view>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "details/null_mutex.h"
|
#ifdef SPDLOG_COMPILED_LIB
|
||||||
|
#undef SPDLOG_HEADER_ONLY
|
||||||
|
#if defined(SPDLOG_SHARED_LIB)
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#ifdef spdlog_EXPORTS
|
||||||
|
#define SPDLOG_API __declspec(dllexport)
|
||||||
|
#else // !spdlog_EXPORTS
|
||||||
|
#define SPDLOG_API __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#else // !defined(_WIN32)
|
||||||
|
#define SPDLOG_API __attribute__((visibility("default")))
|
||||||
|
#endif
|
||||||
|
#else // !defined(SPDLOG_SHARED_LIB)
|
||||||
|
#define SPDLOG_API
|
||||||
|
#endif
|
||||||
|
#define SPDLOG_INLINE
|
||||||
|
#else // !defined(SPDLOG_COMPILED_LIB)
|
||||||
|
#define SPDLOG_API
|
||||||
|
#define SPDLOG_HEADER_ONLY
|
||||||
|
#define SPDLOG_INLINE inline
|
||||||
|
#endif // #ifdef SPDLOG_COMPILED_LIB
|
||||||
|
|
||||||
//visual studio upto 2013 does not support noexcept nor constexpr
|
#include <spdlog/fmt/fmt.h>
|
||||||
|
|
||||||
|
#if !defined(SPDLOG_USE_STD_FORMAT) && \
|
||||||
|
FMT_VERSION >= 80000 // backward compatibility with fmt versions older than 8
|
||||||
|
#define SPDLOG_FMT_RUNTIME(format_string) fmt::runtime(format_string)
|
||||||
|
#define SPDLOG_FMT_STRING(format_string) FMT_STRING(format_string)
|
||||||
|
#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||||
|
#include <spdlog/fmt/xchar.h>
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define SPDLOG_FMT_RUNTIME(format_string) format_string
|
||||||
|
#define SPDLOG_FMT_STRING(format_string) format_string
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// visual studio up to 2013 does not support noexcept nor constexpr
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||||
#define SPDLOG_NOEXCEPT throw()
|
#define SPDLOG_NOEXCEPT _NOEXCEPT
|
||||||
#define SPDLOG_CONSTEXPR
|
#define SPDLOG_CONSTEXPR
|
||||||
#else
|
#else
|
||||||
#define SPDLOG_NOEXCEPT noexcept
|
#define SPDLOG_NOEXCEPT noexcept
|
||||||
#define SPDLOG_CONSTEXPR constexpr
|
#define SPDLOG_CONSTEXPR constexpr
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// final keyword support. On by default. See tweakme.h
|
// If building with std::format, can just use constexpr, otherwise if building with fmt
|
||||||
#if defined(SPDLOG_NO_FINAL)
|
// SPDLOG_CONSTEXPR_FUNC needs to be set the same as FMT_CONSTEXPR to avoid situations where
|
||||||
#define SPDLOG_FINAL
|
// a constexpr function in spdlog could end up calling a non-constexpr function in fmt
|
||||||
#else
|
// depending on the compiler
|
||||||
#define SPDLOG_FINAL final
|
// If fmt determines it can't use constexpr, we should inline the function instead
|
||||||
|
#ifdef SPDLOG_USE_STD_FORMAT
|
||||||
|
#define SPDLOG_CONSTEXPR_FUNC constexpr
|
||||||
|
#else // Being built with fmt
|
||||||
|
#if FMT_USE_CONSTEXPR
|
||||||
|
#define SPDLOG_CONSTEXPR_FUNC FMT_CONSTEXPR
|
||||||
|
#else
|
||||||
|
#define SPDLOG_CONSTEXPR_FUNC inline
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#define SPDLOG_DEPRECATED __attribute__((deprecated))
|
#define SPDLOG_DEPRECATED __attribute__((deprecated))
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
#define SPDLOG_DEPRECATED __declspec(deprecated)
|
#define SPDLOG_DEPRECATED __declspec(deprecated)
|
||||||
#else
|
#else
|
||||||
#define SPDLOG_DEPRECATED
|
#define SPDLOG_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "fmt/fmt.h"
|
// disable thread local on msvc 2013
|
||||||
|
#ifndef SPDLOG_NO_TLS
|
||||||
|
#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__cplusplus_winrt)
|
||||||
|
#define SPDLOG_NO_TLS 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace spdlog
|
#ifndef SPDLOG_FUNCTION
|
||||||
{
|
#define SPDLOG_FUNCTION static_cast<const char *>(__FUNCTION__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SPDLOG_NO_EXCEPTIONS
|
||||||
|
#define SPDLOG_TRY
|
||||||
|
#define SPDLOG_THROW(ex) \
|
||||||
|
do { \
|
||||||
|
printf("spdlog fatal error: %s\n", ex.what()); \
|
||||||
|
std::abort(); \
|
||||||
|
} while (0)
|
||||||
|
#define SPDLOG_CATCH_STD
|
||||||
|
#else
|
||||||
|
#define SPDLOG_TRY try
|
||||||
|
#define SPDLOG_THROW(ex) throw(ex)
|
||||||
|
#define SPDLOG_CATCH_STD \
|
||||||
|
catch (const std::exception &) { \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
|
||||||
class formatter;
|
class formatter;
|
||||||
|
|
||||||
namespace sinks
|
namespace sinks {
|
||||||
{
|
|
||||||
class sink;
|
class sink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
||||||
|
using filename_t = std::wstring;
|
||||||
|
// allow macro expansion to occur in SPDLOG_FILENAME_T
|
||||||
|
#define SPDLOG_FILENAME_T_INNER(s) L##s
|
||||||
|
#define SPDLOG_FILENAME_T(s) SPDLOG_FILENAME_T_INNER(s)
|
||||||
|
#else
|
||||||
|
using filename_t = std::string;
|
||||||
|
#define SPDLOG_FILENAME_T(s) s
|
||||||
|
#endif
|
||||||
|
|
||||||
using log_clock = std::chrono::system_clock;
|
using log_clock = std::chrono::system_clock;
|
||||||
using sink_ptr = std::shared_ptr < sinks::sink >;
|
using sink_ptr = std::shared_ptr<sinks::sink>;
|
||||||
using sinks_init_list = std::initializer_list < sink_ptr >;
|
using sinks_init_list = std::initializer_list<sink_ptr>;
|
||||||
using formatter_ptr = std::shared_ptr<spdlog::formatter>;
|
using err_handler = std::function<void(const std::string &err_msg)>;
|
||||||
|
#ifdef SPDLOG_USE_STD_FORMAT
|
||||||
|
namespace fmt_lib = std;
|
||||||
|
|
||||||
|
using string_view_t = std::string_view;
|
||||||
|
using memory_buf_t = std::string;
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
#if __cpp_lib_format >= 202207L
|
||||||
|
using format_string_t = std::format_string<Args...>;
|
||||||
|
#else
|
||||||
|
using format_string_t = std::string_view;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <class T, class Char = char>
|
||||||
|
struct is_convertible_to_basic_format_string
|
||||||
|
: std::integral_constant<bool, std::is_convertible<T, std::basic_string_view<Char>>::value> {};
|
||||||
|
|
||||||
|
#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||||
|
using wstring_view_t = std::wstring_view;
|
||||||
|
using wmemory_buf_t = std::wstring;
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
#if __cpp_lib_format >= 202207L
|
||||||
|
using wformat_string_t = std::wformat_string<Args...>;
|
||||||
|
#else
|
||||||
|
using wformat_string_t = std::wstring_view;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#define SPDLOG_BUF_TO_STRING(x) x
|
||||||
|
#else // use fmt lib instead of std::format
|
||||||
|
namespace fmt_lib = fmt;
|
||||||
|
|
||||||
|
using string_view_t = fmt::basic_string_view<char>;
|
||||||
|
using memory_buf_t = fmt::basic_memory_buffer<char, 250>;
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
using format_string_t = fmt::format_string<Args...>;
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
using remove_cvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
|
||||||
|
|
||||||
|
template <typename Char>
|
||||||
|
#if FMT_VERSION >= 90101
|
||||||
|
using fmt_runtime_string = fmt::runtime_format_string<Char>;
|
||||||
|
#else
|
||||||
|
using fmt_runtime_string = fmt::basic_runtime<Char>;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// clang doesn't like SFINAE disabled constructor in std::is_convertible<> so have to repeat the
|
||||||
|
// condition from basic_format_string here, in addition, fmt::basic_runtime<Char> is only
|
||||||
|
// convertible to basic_format_string<Char> but not basic_string_view<Char>
|
||||||
|
template <class T, class Char = char>
|
||||||
|
struct is_convertible_to_basic_format_string
|
||||||
|
: std::integral_constant<bool,
|
||||||
|
std::is_convertible<T, fmt::basic_string_view<Char>>::value ||
|
||||||
|
std::is_same<remove_cvref_t<T>, fmt_runtime_string<Char>>::value> {
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||||
|
using wstring_view_t = fmt::basic_string_view<wchar_t>;
|
||||||
|
using wmemory_buf_t = fmt::basic_memory_buffer<wchar_t, 250>;
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
using wformat_string_t = fmt::wformat_string<Args...>;
|
||||||
|
#endif
|
||||||
|
#define SPDLOG_BUF_TO_STRING(x) fmt::to_string(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||||
|
#ifndef _WIN32
|
||||||
|
#error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows
|
||||||
|
#endif // _WIN32
|
||||||
|
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct is_convertible_to_any_format_string
|
||||||
|
: std::integral_constant<bool,
|
||||||
|
is_convertible_to_basic_format_string<T, char>::value ||
|
||||||
|
is_convertible_to_basic_format_string<T, wchar_t>::value> {};
|
||||||
|
|
||||||
#if defined(SPDLOG_NO_ATOMIC_LEVELS)
|
#if defined(SPDLOG_NO_ATOMIC_LEVELS)
|
||||||
using level_t = details::null_atomic_int;
|
using level_t = details::null_atomic_int;
|
||||||
#else
|
#else
|
||||||
using level_t = std::atomic<int>;
|
using level_t = std::atomic<int>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using log_err_handler = std::function<void(const std::string &err_msg)>;
|
#define SPDLOG_LEVEL_TRACE 0
|
||||||
|
#define SPDLOG_LEVEL_DEBUG 1
|
||||||
|
#define SPDLOG_LEVEL_INFO 2
|
||||||
|
#define SPDLOG_LEVEL_WARN 3
|
||||||
|
#define SPDLOG_LEVEL_ERROR 4
|
||||||
|
#define SPDLOG_LEVEL_CRITICAL 5
|
||||||
|
#define SPDLOG_LEVEL_OFF 6
|
||||||
|
|
||||||
//Log level enum
|
#if !defined(SPDLOG_ACTIVE_LEVEL)
|
||||||
namespace level
|
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
|
||||||
{
|
#endif
|
||||||
typedef enum
|
|
||||||
{
|
// Log level enum
|
||||||
trace = 0,
|
namespace level {
|
||||||
debug = 1,
|
enum level_enum : int {
|
||||||
info = 2,
|
trace = SPDLOG_LEVEL_TRACE,
|
||||||
warn = 3,
|
debug = SPDLOG_LEVEL_DEBUG,
|
||||||
err = 4,
|
info = SPDLOG_LEVEL_INFO,
|
||||||
critical = 5,
|
warn = SPDLOG_LEVEL_WARN,
|
||||||
off = 6
|
err = SPDLOG_LEVEL_ERROR,
|
||||||
} level_enum;
|
critical = SPDLOG_LEVEL_CRITICAL,
|
||||||
|
off = SPDLOG_LEVEL_OFF,
|
||||||
|
n_levels
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SPDLOG_LEVEL_NAME_TRACE spdlog::string_view_t("trace", 5)
|
||||||
|
#define SPDLOG_LEVEL_NAME_DEBUG spdlog::string_view_t("debug", 5)
|
||||||
|
#define SPDLOG_LEVEL_NAME_INFO spdlog::string_view_t("info", 4)
|
||||||
|
#define SPDLOG_LEVEL_NAME_WARNING spdlog::string_view_t("warning", 7)
|
||||||
|
#define SPDLOG_LEVEL_NAME_ERROR spdlog::string_view_t("error", 5)
|
||||||
|
#define SPDLOG_LEVEL_NAME_CRITICAL spdlog::string_view_t("critical", 8)
|
||||||
|
#define SPDLOG_LEVEL_NAME_OFF spdlog::string_view_t("off", 3)
|
||||||
|
|
||||||
#if !defined(SPDLOG_LEVEL_NAMES)
|
#if !defined(SPDLOG_LEVEL_NAMES)
|
||||||
#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "critical", "off" }
|
#define SPDLOG_LEVEL_NAMES \
|
||||||
|
{ \
|
||||||
|
SPDLOG_LEVEL_NAME_TRACE, SPDLOG_LEVEL_NAME_DEBUG, SPDLOG_LEVEL_NAME_INFO, \
|
||||||
|
SPDLOG_LEVEL_NAME_WARNING, SPDLOG_LEVEL_NAME_ERROR, SPDLOG_LEVEL_NAME_CRITICAL, \
|
||||||
|
SPDLOG_LEVEL_NAME_OFF \
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
static const char* level_names[] SPDLOG_LEVEL_NAMES;
|
|
||||||
|
|
||||||
static const char* short_level_names[] { "T", "D", "I", "W", "E", "C", "O" };
|
#if !defined(SPDLOG_SHORT_LEVEL_NAMES)
|
||||||
|
|
||||||
inline const char* to_str(spdlog::level::level_enum l)
|
#define SPDLOG_SHORT_LEVEL_NAMES \
|
||||||
{
|
{ "T", "D", "I", "W", "E", "C", "O" }
|
||||||
return level_names[l];
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
inline const char* to_short_str(spdlog::level::level_enum l)
|
SPDLOG_API const string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT;
|
||||||
{
|
SPDLOG_API const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT;
|
||||||
return short_level_names[l];
|
SPDLOG_API spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT;
|
||||||
}
|
|
||||||
} //level
|
|
||||||
|
|
||||||
|
} // namespace level
|
||||||
|
|
||||||
//
|
//
|
||||||
// Async overflow policy - block by default.
|
// Color mode used by sinks with color support.
|
||||||
//
|
//
|
||||||
enum class async_overflow_policy
|
enum class color_mode { always, automatic, never };
|
||||||
{
|
|
||||||
block_retry, // Block / yield / sleep until message can be enqueued
|
|
||||||
discard_log_msg // Discard the message it enqueue fails
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Pattern time - specific time getting to use for pattern_formatter.
|
// Pattern time - specific time getting to use for pattern_formatter.
|
||||||
// local time by default
|
// local time by default
|
||||||
//
|
//
|
||||||
enum class pattern_time_type
|
enum class pattern_time_type {
|
||||||
{
|
local, // log localtime
|
||||||
local, // log localtime
|
utc // log utc
|
||||||
utc // log utc
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Log exception
|
// Log exception
|
||||||
//
|
//
|
||||||
namespace details
|
class SPDLOG_API spdlog_ex : public std::exception {
|
||||||
{
|
|
||||||
namespace os
|
|
||||||
{
|
|
||||||
std::string errno_str(int err_num);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class spdlog_ex: public std::exception
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
spdlog_ex(const std::string& msg):_msg(msg)
|
explicit spdlog_ex(std::string msg);
|
||||||
{}
|
spdlog_ex(const std::string &msg, int last_errno);
|
||||||
spdlog_ex(const std::string& msg, int last_errno)
|
const char *what() const SPDLOG_NOEXCEPT override;
|
||||||
{
|
|
||||||
_msg = msg + ": " + details::os::errno_str(last_errno);
|
|
||||||
}
|
|
||||||
const char* what() const SPDLOG_NOEXCEPT override
|
|
||||||
{
|
|
||||||
return _msg.c_str();
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
std::string _msg;
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string msg_;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
[[noreturn]] SPDLOG_API void throw_spdlog_ex(const std::string &msg, int last_errno);
|
||||||
// wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
|
[[noreturn]] SPDLOG_API void throw_spdlog_ex(std::string msg);
|
||||||
//
|
|
||||||
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
struct source_loc {
|
||||||
using filename_t = std::wstring;
|
SPDLOG_CONSTEXPR source_loc() = default;
|
||||||
#else
|
SPDLOG_CONSTEXPR source_loc(const char *filename_in, int line_in, const char *funcname_in)
|
||||||
using filename_t = std::string;
|
: filename{filename_in},
|
||||||
|
line{line_in},
|
||||||
|
funcname{funcname_in} {}
|
||||||
|
|
||||||
|
SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT { return line <= 0; }
|
||||||
|
const char *filename{nullptr};
|
||||||
|
int line{0};
|
||||||
|
const char *funcname{nullptr};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct file_event_handlers {
|
||||||
|
file_event_handlers()
|
||||||
|
: before_open(nullptr),
|
||||||
|
after_open(nullptr),
|
||||||
|
before_close(nullptr),
|
||||||
|
after_close(nullptr) {}
|
||||||
|
|
||||||
|
std::function<void(const filename_t &filename)> before_open;
|
||||||
|
std::function<void(const filename_t &filename, std::FILE *file_stream)> after_open;
|
||||||
|
std::function<void(const filename_t &filename, std::FILE *file_stream)> before_close;
|
||||||
|
std::function<void(const filename_t &filename)> after_close;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
// to_string_view
|
||||||
|
|
||||||
|
SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(const memory_buf_t &buf)
|
||||||
|
SPDLOG_NOEXCEPT {
|
||||||
|
return spdlog::string_view_t{buf.data(), buf.size()};
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(spdlog::string_view_t str)
|
||||||
|
SPDLOG_NOEXCEPT {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||||
|
SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(const wmemory_buf_t &buf)
|
||||||
|
SPDLOG_NOEXCEPT {
|
||||||
|
return spdlog::wstring_view_t{buf.data(), buf.size()};
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(spdlog::wstring_view_t str)
|
||||||
|
SPDLOG_NOEXCEPT {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(SPDLOG_USE_STD_FORMAT) && __cpp_lib_format >= 202207L
|
||||||
|
template <typename T, typename... Args>
|
||||||
|
SPDLOG_CONSTEXPR_FUNC std::basic_string_view<T> to_string_view(
|
||||||
|
std::basic_format_string<T, Args...> fmt) SPDLOG_NOEXCEPT {
|
||||||
|
return fmt.get();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} //spdlog
|
// make_unique support for pre c++14
|
||||||
|
#if __cplusplus >= 201402L // C++14 and beyond
|
||||||
|
using std::enable_if_t;
|
||||||
|
using std::make_unique;
|
||||||
|
#else
|
||||||
|
template <bool B, class T = void>
|
||||||
|
using enable_if_t = typename std::enable_if<B, T>::type;
|
||||||
|
|
||||||
|
template <typename T, typename... Args>
|
||||||
|
std::unique_ptr<T> make_unique(Args &&...args) {
|
||||||
|
static_assert(!std::is_array<T>::value, "arrays not supported");
|
||||||
|
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324)
|
||||||
|
template <typename T, typename U, enable_if_t<!std::is_same<T, U>::value, int> = 0>
|
||||||
|
constexpr T conditional_static_cast(U value) {
|
||||||
|
return static_cast<T>(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename U, enable_if_t<std::is_same<T, U>::value, int> = 0>
|
||||||
|
constexpr T conditional_static_cast(U value) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
||||||
|
|
||||||
|
#ifdef SPDLOG_HEADER_ONLY
|
||||||
|
#include "common-inl.h"
|
||||||
|
#endif
|
||||||
|
@ -1,399 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
// async log helper :
|
|
||||||
// Process logs asynchronously using a back thread.
|
|
||||||
//
|
|
||||||
// If the internal queue of log messages reaches its max size,
|
|
||||||
// then the client call will block until there is more room.
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../common.h"
|
|
||||||
#include "../sinks/sink.h"
|
|
||||||
#include "../details/mpmc_bounded_q.h"
|
|
||||||
#include "../details/log_msg.h"
|
|
||||||
#include "../details/os.h"
|
|
||||||
#include "../formatter.h"
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <exception>
|
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <thread>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace spdlog
|
|
||||||
{
|
|
||||||
namespace details
|
|
||||||
{
|
|
||||||
|
|
||||||
class async_log_helper
|
|
||||||
{
|
|
||||||
// Async msg to move to/from the queue
|
|
||||||
// Movable only. should never be copied
|
|
||||||
enum class async_msg_type
|
|
||||||
{
|
|
||||||
log,
|
|
||||||
flush,
|
|
||||||
terminate
|
|
||||||
};
|
|
||||||
struct async_msg
|
|
||||||
{
|
|
||||||
std::string logger_name;
|
|
||||||
level::level_enum level;
|
|
||||||
log_clock::time_point time;
|
|
||||||
size_t thread_id;
|
|
||||||
std::string txt;
|
|
||||||
async_msg_type msg_type;
|
|
||||||
size_t msg_id;
|
|
||||||
|
|
||||||
async_msg() = default;
|
|
||||||
~async_msg() = default;
|
|
||||||
|
|
||||||
|
|
||||||
async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
|
|
||||||
logger_name(std::move(other.logger_name)),
|
|
||||||
level(std::move(other.level)),
|
|
||||||
time(std::move(other.time)),
|
|
||||||
thread_id(other.thread_id),
|
|
||||||
txt(std::move(other.txt)),
|
|
||||||
msg_type(std::move(other.msg_type)),
|
|
||||||
msg_id(other.msg_id)
|
|
||||||
{}
|
|
||||||
|
|
||||||
async_msg(async_msg_type m_type):
|
|
||||||
level(level::info),
|
|
||||||
thread_id(0),
|
|
||||||
msg_type(m_type),
|
|
||||||
msg_id(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
async_msg& operator=(async_msg&& other) SPDLOG_NOEXCEPT
|
|
||||||
{
|
|
||||||
logger_name = std::move(other.logger_name);
|
|
||||||
level = other.level;
|
|
||||||
time = std::move(other.time);
|
|
||||||
thread_id = other.thread_id;
|
|
||||||
txt = std::move(other.txt);
|
|
||||||
msg_type = other.msg_type;
|
|
||||||
msg_id = other.msg_id;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// never copy or assign. should only be moved..
|
|
||||||
async_msg(const async_msg&) = delete;
|
|
||||||
async_msg& operator=(const async_msg& other) = delete;
|
|
||||||
|
|
||||||
// construct from log_msg
|
|
||||||
async_msg(const details::log_msg& m):
|
|
||||||
level(m.level),
|
|
||||||
time(m.time),
|
|
||||||
thread_id(m.thread_id),
|
|
||||||
txt(m.raw.data(), m.raw.size()),
|
|
||||||
msg_type(async_msg_type::log),
|
|
||||||
msg_id(m.msg_id)
|
|
||||||
{
|
|
||||||
#ifndef SPDLOG_NO_NAME
|
|
||||||
logger_name = *m.logger_name;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// copy into log_msg
|
|
||||||
void fill_log_msg(log_msg &msg)
|
|
||||||
{
|
|
||||||
msg.logger_name = &logger_name;
|
|
||||||
msg.level = level;
|
|
||||||
msg.time = time;
|
|
||||||
msg.thread_id = thread_id;
|
|
||||||
msg.raw << txt;
|
|
||||||
msg.msg_id = msg_id;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
using item_type = async_msg;
|
|
||||||
using q_type = details::mpmc_bounded_queue<item_type>;
|
|
||||||
|
|
||||||
using clock = std::chrono::steady_clock;
|
|
||||||
|
|
||||||
|
|
||||||
async_log_helper(formatter_ptr formatter,
|
|
||||||
const std::vector<sink_ptr>& sinks,
|
|
||||||
size_t queue_size,
|
|
||||||
const log_err_handler err_handler,
|
|
||||||
const async_overflow_policy overflow_policy = async_overflow_policy::block_retry,
|
|
||||||
const std::function<void()>& worker_warmup_cb = nullptr,
|
|
||||||
const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
|
|
||||||
const std::function<void()>& worker_teardown_cb = nullptr);
|
|
||||||
|
|
||||||
void log(const details::log_msg& msg);
|
|
||||||
|
|
||||||
// stop logging and join the back thread
|
|
||||||
~async_log_helper();
|
|
||||||
|
|
||||||
void set_formatter(formatter_ptr);
|
|
||||||
|
|
||||||
void flush(bool wait_for_q);
|
|
||||||
|
|
||||||
void set_error_handler(spdlog::log_err_handler err_handler);
|
|
||||||
|
|
||||||
private:
|
|
||||||
formatter_ptr _formatter;
|
|
||||||
std::vector<std::shared_ptr<sinks::sink>> _sinks;
|
|
||||||
|
|
||||||
// queue of messages to log
|
|
||||||
q_type _q;
|
|
||||||
|
|
||||||
log_err_handler _err_handler;
|
|
||||||
|
|
||||||
bool _flush_requested;
|
|
||||||
|
|
||||||
bool _terminate_requested;
|
|
||||||
|
|
||||||
|
|
||||||
// overflow policy
|
|
||||||
const async_overflow_policy _overflow_policy;
|
|
||||||
|
|
||||||
// worker thread warmup callback - one can set thread priority, affinity, etc
|
|
||||||
const std::function<void()> _worker_warmup_cb;
|
|
||||||
|
|
||||||
// auto periodic sink flush parameter
|
|
||||||
const std::chrono::milliseconds _flush_interval_ms;
|
|
||||||
|
|
||||||
// worker thread teardown callback
|
|
||||||
const std::function<void()> _worker_teardown_cb;
|
|
||||||
|
|
||||||
// worker thread
|
|
||||||
std::thread _worker_thread;
|
|
||||||
|
|
||||||
void push_msg(async_msg&& new_msg);
|
|
||||||
|
|
||||||
// worker thread main loop
|
|
||||||
void worker_loop();
|
|
||||||
|
|
||||||
// pop next message from the queue and process it. will set the last_pop to the pop time
|
|
||||||
// return false if termination of the queue is required
|
|
||||||
bool process_next_msg(log_clock::time_point& last_pop, log_clock::time_point& last_flush);
|
|
||||||
|
|
||||||
void handle_flush_interval(log_clock::time_point& now, log_clock::time_point& last_flush);
|
|
||||||
|
|
||||||
// sleep,yield or return immediately using the time passed since last message as a hint
|
|
||||||
static void sleep_or_yield(const spdlog::log_clock::time_point& now, const log_clock::time_point& last_op_time);
|
|
||||||
|
|
||||||
// wait until the queue is empty
|
|
||||||
void wait_empty_q();
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// async_sink class implementation
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
inline spdlog::details::async_log_helper::async_log_helper(
|
|
||||||
formatter_ptr formatter,
|
|
||||||
const std::vector<sink_ptr>& sinks,
|
|
||||||
size_t queue_size,
|
|
||||||
log_err_handler err_handler,
|
|
||||||
const async_overflow_policy overflow_policy,
|
|
||||||
const std::function<void()>& worker_warmup_cb,
|
|
||||||
const std::chrono::milliseconds& flush_interval_ms,
|
|
||||||
const std::function<void()>& worker_teardown_cb):
|
|
||||||
_formatter(formatter),
|
|
||||||
_sinks(sinks),
|
|
||||||
_q(queue_size),
|
|
||||||
_err_handler(err_handler),
|
|
||||||
_flush_requested(false),
|
|
||||||
_terminate_requested(false),
|
|
||||||
_overflow_policy(overflow_policy),
|
|
||||||
_worker_warmup_cb(worker_warmup_cb),
|
|
||||||
_flush_interval_ms(flush_interval_ms),
|
|
||||||
_worker_teardown_cb(worker_teardown_cb),
|
|
||||||
_worker_thread(&async_log_helper::worker_loop, this)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// Send to the worker thread termination message(level=off)
|
|
||||||
// and wait for it to finish gracefully
|
|
||||||
inline spdlog::details::async_log_helper::~async_log_helper()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
push_msg(async_msg(async_msg_type::terminate));
|
|
||||||
_worker_thread.join();
|
|
||||||
}
|
|
||||||
catch (...) // don't crash in destructor
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Try to push and block until succeeded (if the policy is not to discard when the queue is full)
|
|
||||||
inline void spdlog::details::async_log_helper::log(const details::log_msg& msg)
|
|
||||||
{
|
|
||||||
push_msg(async_msg(msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::details::async_log_helper::push_msg(details::async_log_helper::async_msg&& new_msg)
|
|
||||||
{
|
|
||||||
if (!_q.enqueue(std::move(new_msg)) && _overflow_policy != async_overflow_policy::discard_log_msg)
|
|
||||||
{
|
|
||||||
auto last_op_time = details::os::now();
|
|
||||||
auto now = last_op_time;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
now = details::os::now();
|
|
||||||
sleep_or_yield(now, last_op_time);
|
|
||||||
}
|
|
||||||
while (!_q.enqueue(std::move(new_msg)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// optionally wait for the queue be empty and request flush from the sinks
|
|
||||||
inline void spdlog::details::async_log_helper::flush(bool wait_for_q)
|
|
||||||
{
|
|
||||||
push_msg(async_msg(async_msg_type::flush));
|
|
||||||
if (wait_for_q)
|
|
||||||
wait_empty_q(); //return when queue is empty
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::details::async_log_helper::worker_loop()
|
|
||||||
{
|
|
||||||
if (_worker_warmup_cb) _worker_warmup_cb();
|
|
||||||
auto last_pop = details::os::now();
|
|
||||||
auto last_flush = last_pop;
|
|
||||||
auto active = true;
|
|
||||||
while (active)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
active = process_next_msg(last_pop, last_flush);
|
|
||||||
}
|
|
||||||
catch (const std::exception &ex)
|
|
||||||
{
|
|
||||||
_err_handler(ex.what());
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
_err_handler("Unknown exeption in async logger worker loop.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_worker_teardown_cb) _worker_teardown_cb();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// process next message in the queue
|
|
||||||
// return true if this thread should still be active (while no terminate msg was received)
|
|
||||||
inline bool spdlog::details::async_log_helper::process_next_msg(log_clock::time_point& last_pop, log_clock::time_point& last_flush)
|
|
||||||
{
|
|
||||||
async_msg incoming_async_msg;
|
|
||||||
|
|
||||||
if (_q.dequeue(incoming_async_msg))
|
|
||||||
{
|
|
||||||
last_pop = details::os::now();
|
|
||||||
switch (incoming_async_msg.msg_type)
|
|
||||||
{
|
|
||||||
case async_msg_type::flush:
|
|
||||||
_flush_requested = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case async_msg_type::terminate:
|
|
||||||
_flush_requested = true;
|
|
||||||
_terminate_requested = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
log_msg incoming_log_msg;
|
|
||||||
incoming_async_msg.fill_log_msg(incoming_log_msg);
|
|
||||||
_formatter->format(incoming_log_msg);
|
|
||||||
for (auto &s : _sinks)
|
|
||||||
{
|
|
||||||
if (s->should_log(incoming_log_msg.level))
|
|
||||||
{
|
|
||||||
s->log(incoming_log_msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle empty queue..
|
|
||||||
// This is the only place where the queue can terminate or flush to avoid losing messages already in the queue
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto now = details::os::now();
|
|
||||||
handle_flush_interval(now, last_flush);
|
|
||||||
sleep_or_yield(now, last_pop);
|
|
||||||
return !_terminate_requested;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// flush all sinks if _flush_interval_ms has expired
|
|
||||||
inline void spdlog::details::async_log_helper::handle_flush_interval(log_clock::time_point& now, log_clock::time_point& last_flush)
|
|
||||||
{
|
|
||||||
auto should_flush = _flush_requested || (_flush_interval_ms != std::chrono::milliseconds::zero() && now - last_flush >= _flush_interval_ms);
|
|
||||||
if (should_flush)
|
|
||||||
{
|
|
||||||
for (auto &s : _sinks)
|
|
||||||
s->flush();
|
|
||||||
now = last_flush = details::os::now();
|
|
||||||
_flush_requested = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::details::async_log_helper::set_formatter(formatter_ptr msg_formatter)
|
|
||||||
{
|
|
||||||
_formatter = msg_formatter;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// spin, yield or sleep. use the time passed since last message as a hint
|
|
||||||
inline void spdlog::details::async_log_helper::sleep_or_yield(const spdlog::log_clock::time_point& now, const spdlog::log_clock::time_point& last_op_time)
|
|
||||||
{
|
|
||||||
using namespace std::this_thread;
|
|
||||||
using std::chrono::milliseconds;
|
|
||||||
using std::chrono::microseconds;
|
|
||||||
|
|
||||||
auto time_since_op = now - last_op_time;
|
|
||||||
|
|
||||||
// spin upto 50 micros
|
|
||||||
if (time_since_op <= microseconds(50))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// yield upto 150 micros
|
|
||||||
if (time_since_op <= microseconds(100))
|
|
||||||
return std::this_thread::yield();
|
|
||||||
|
|
||||||
// sleep for 20 ms upto 200 ms
|
|
||||||
if (time_since_op <= milliseconds(200))
|
|
||||||
return sleep_for(milliseconds(20));
|
|
||||||
|
|
||||||
// sleep for 500 ms
|
|
||||||
return sleep_for(milliseconds(500));
|
|
||||||
}
|
|
||||||
|
|
||||||
// wait for the queue to be empty
|
|
||||||
inline void spdlog::details::async_log_helper::wait_empty_q()
|
|
||||||
{
|
|
||||||
auto last_op = details::os::now();
|
|
||||||
while (!_q.is_empty())
|
|
||||||
{
|
|
||||||
sleep_or_yield(details::os::now(), last_op);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::details::async_log_helper::set_error_handler(spdlog::log_err_handler err_handler)
|
|
||||||
{
|
|
||||||
_err_handler = err_handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,107 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// Async Logger implementation
|
|
||||||
// Use an async_sink (queue per logger) to perform the logging in a worker thread
|
|
||||||
|
|
||||||
#include "../details/async_log_helper.h"
|
|
||||||
#include "../async_logger.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <functional>
|
|
||||||
#include <chrono>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
template<class It>
|
|
||||||
inline spdlog::async_logger::async_logger(const std::string& logger_name,
|
|
||||||
const It& begin,
|
|
||||||
const It& end,
|
|
||||||
size_t queue_size,
|
|
||||||
const async_overflow_policy overflow_policy,
|
|
||||||
const std::function<void()>& worker_warmup_cb,
|
|
||||||
const std::chrono::milliseconds& flush_interval_ms,
|
|
||||||
const std::function<void()>& worker_teardown_cb) :
|
|
||||||
logger(logger_name, begin, end),
|
|
||||||
_async_log_helper(new details::async_log_helper(_formatter, _sinks, queue_size, _err_handler, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline spdlog::async_logger::async_logger(const std::string& logger_name,
|
|
||||||
sinks_init_list sinks_list,
|
|
||||||
size_t queue_size,
|
|
||||||
const async_overflow_policy overflow_policy,
|
|
||||||
const std::function<void()>& worker_warmup_cb,
|
|
||||||
const std::chrono::milliseconds& flush_interval_ms,
|
|
||||||
const std::function<void()>& worker_teardown_cb) :
|
|
||||||
async_logger(logger_name, sinks_list.begin(), sinks_list.end(), queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb) {}
|
|
||||||
|
|
||||||
inline spdlog::async_logger::async_logger(const std::string& logger_name,
|
|
||||||
sink_ptr single_sink,
|
|
||||||
size_t queue_size,
|
|
||||||
const async_overflow_policy overflow_policy,
|
|
||||||
const std::function<void()>& worker_warmup_cb,
|
|
||||||
const std::chrono::milliseconds& flush_interval_ms,
|
|
||||||
const std::function<void()>& worker_teardown_cb) :
|
|
||||||
async_logger(logger_name,
|
|
||||||
{
|
|
||||||
single_sink
|
|
||||||
}, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb) {}
|
|
||||||
|
|
||||||
|
|
||||||
inline void spdlog::async_logger::flush()
|
|
||||||
{
|
|
||||||
_async_log_helper->flush(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error handler
|
|
||||||
inline void spdlog::async_logger::set_error_handler(spdlog::log_err_handler err_handler)
|
|
||||||
{
|
|
||||||
_err_handler = err_handler;
|
|
||||||
_async_log_helper->set_error_handler(err_handler);
|
|
||||||
|
|
||||||
}
|
|
||||||
inline spdlog::log_err_handler spdlog::async_logger::error_handler()
|
|
||||||
{
|
|
||||||
return _err_handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void spdlog::async_logger::_set_formatter(spdlog::formatter_ptr msg_formatter)
|
|
||||||
{
|
|
||||||
_formatter = msg_formatter;
|
|
||||||
_async_log_helper->set_formatter(_formatter);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::async_logger::_set_pattern(const std::string& pattern, pattern_time_type pattern_time)
|
|
||||||
{
|
|
||||||
_formatter = std::make_shared<pattern_formatter>(pattern, pattern_time);
|
|
||||||
_async_log_helper->set_formatter(_formatter);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void spdlog::async_logger::_sink_it(details::log_msg& msg)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
|
|
||||||
_incr_msg_counter(msg);
|
|
||||||
#endif
|
|
||||||
_async_log_helper->log(msg);
|
|
||||||
if (_should_flush_on(msg))
|
|
||||||
_async_log_helper->flush(false); // do async flush
|
|
||||||
}
|
|
||||||
catch (const std::exception &ex)
|
|
||||||
{
|
|
||||||
_err_handler(ex.what());
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
_err_handler("Unknown exception in logger " + _name);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
63
include/spdlog/details/backtracer-inl.h
Normal file
63
include/spdlog/details/backtracer-inl.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef SPDLOG_HEADER_ONLY
|
||||||
|
#include <spdlog/details/backtracer.h>
|
||||||
|
#endif
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
SPDLOG_INLINE backtracer::backtracer(const backtracer &other) {
|
||||||
|
std::lock_guard<std::mutex> lock(other.mutex_);
|
||||||
|
enabled_ = other.enabled();
|
||||||
|
messages_ = other.messages_;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE backtracer::backtracer(backtracer &&other) SPDLOG_NOEXCEPT {
|
||||||
|
std::lock_guard<std::mutex> lock(other.mutex_);
|
||||||
|
enabled_ = other.enabled();
|
||||||
|
messages_ = std::move(other.messages_);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE backtracer &backtracer::operator=(backtracer other) {
|
||||||
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
|
enabled_ = other.enabled();
|
||||||
|
messages_ = std::move(other.messages_);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void backtracer::enable(size_t size) {
|
||||||
|
std::lock_guard<std::mutex> lock{mutex_};
|
||||||
|
enabled_.store(true, std::memory_order_relaxed);
|
||||||
|
messages_ = circular_q<log_msg_buffer>{size};
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void backtracer::disable() {
|
||||||
|
std::lock_guard<std::mutex> lock{mutex_};
|
||||||
|
enabled_.store(false, std::memory_order_relaxed);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE bool backtracer::enabled() const { return enabled_.load(std::memory_order_relaxed); }
|
||||||
|
|
||||||
|
SPDLOG_INLINE void backtracer::push_back(const log_msg &msg) {
|
||||||
|
std::lock_guard<std::mutex> lock{mutex_};
|
||||||
|
messages_.push_back(log_msg_buffer{msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE bool backtracer::empty() const {
|
||||||
|
std::lock_guard<std::mutex> lock{mutex_};
|
||||||
|
return messages_.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
// pop all items in the q and apply the given fun on each of them.
|
||||||
|
SPDLOG_INLINE void backtracer::foreach_pop(std::function<void(const details::log_msg &)> fun) {
|
||||||
|
std::lock_guard<std::mutex> lock{mutex_};
|
||||||
|
while (!messages_.empty()) {
|
||||||
|
auto &front_msg = messages_.front();
|
||||||
|
fun(front_msg);
|
||||||
|
messages_.pop_front();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
45
include/spdlog/details/backtracer.h
Normal file
45
include/spdlog/details/backtracer.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <spdlog/details/circular_q.h>
|
||||||
|
#include <spdlog/details/log_msg_buffer.h>
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <functional>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
// Store log messages in circular buffer.
|
||||||
|
// Useful for storing debug data in case of error/warning happens.
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
class SPDLOG_API backtracer {
|
||||||
|
mutable std::mutex mutex_;
|
||||||
|
std::atomic<bool> enabled_{false};
|
||||||
|
circular_q<log_msg_buffer> messages_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
backtracer() = default;
|
||||||
|
backtracer(const backtracer &other);
|
||||||
|
|
||||||
|
backtracer(backtracer &&other) SPDLOG_NOEXCEPT;
|
||||||
|
backtracer &operator=(backtracer other);
|
||||||
|
|
||||||
|
void enable(size_t size);
|
||||||
|
void disable();
|
||||||
|
bool enabled() const;
|
||||||
|
void push_back(const log_msg &msg);
|
||||||
|
bool empty() const;
|
||||||
|
|
||||||
|
// pop all items in the q and apply the given fun on each of them.
|
||||||
|
void foreach_pop(std::function<void(const details::log_msg &)> fun);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
||||||
|
|
||||||
|
#ifdef SPDLOG_HEADER_ONLY
|
||||||
|
#include "backtracer-inl.h"
|
||||||
|
#endif
|
115
include/spdlog/details/circular_q.h
Normal file
115
include/spdlog/details/circular_q.h
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
// circular q view of std::vector.
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "spdlog/common.h"
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
template <typename T>
|
||||||
|
class circular_q {
|
||||||
|
size_t max_items_ = 0;
|
||||||
|
typename std::vector<T>::size_type head_ = 0;
|
||||||
|
typename std::vector<T>::size_type tail_ = 0;
|
||||||
|
size_t overrun_counter_ = 0;
|
||||||
|
std::vector<T> v_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using value_type = T;
|
||||||
|
|
||||||
|
// empty ctor - create a disabled queue with no elements allocated at all
|
||||||
|
circular_q() = default;
|
||||||
|
|
||||||
|
explicit circular_q(size_t max_items)
|
||||||
|
: max_items_(max_items + 1) // one item is reserved as marker for full q
|
||||||
|
,
|
||||||
|
v_(max_items_) {}
|
||||||
|
|
||||||
|
circular_q(const circular_q &) = default;
|
||||||
|
circular_q &operator=(const circular_q &) = default;
|
||||||
|
|
||||||
|
// move cannot be default,
|
||||||
|
// since we need to reset head_, tail_, etc to zero in the moved object
|
||||||
|
circular_q(circular_q &&other) SPDLOG_NOEXCEPT { copy_moveable(std::move(other)); }
|
||||||
|
|
||||||
|
circular_q &operator=(circular_q &&other) SPDLOG_NOEXCEPT {
|
||||||
|
copy_moveable(std::move(other));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// push back, overrun (oldest) item if no room left
|
||||||
|
void push_back(T &&item) {
|
||||||
|
if (max_items_ > 0) {
|
||||||
|
v_[tail_] = std::move(item);
|
||||||
|
tail_ = (tail_ + 1) % max_items_;
|
||||||
|
|
||||||
|
if (tail_ == head_) // overrun last item if full
|
||||||
|
{
|
||||||
|
head_ = (head_ + 1) % max_items_;
|
||||||
|
++overrun_counter_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return reference to the front item.
|
||||||
|
// If there are no elements in the container, the behavior is undefined.
|
||||||
|
const T &front() const { return v_[head_]; }
|
||||||
|
|
||||||
|
T &front() { return v_[head_]; }
|
||||||
|
|
||||||
|
// Return number of elements actually stored
|
||||||
|
size_t size() const {
|
||||||
|
if (tail_ >= head_) {
|
||||||
|
return tail_ - head_;
|
||||||
|
} else {
|
||||||
|
return max_items_ - (head_ - tail_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return const reference to item by index.
|
||||||
|
// If index is out of range 0…size()-1, the behavior is undefined.
|
||||||
|
const T &at(size_t i) const {
|
||||||
|
assert(i < size());
|
||||||
|
return v_[(head_ + i) % max_items_];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pop item from front.
|
||||||
|
// If there are no elements in the container, the behavior is undefined.
|
||||||
|
void pop_front() { head_ = (head_ + 1) % max_items_; }
|
||||||
|
|
||||||
|
bool empty() const { return tail_ == head_; }
|
||||||
|
|
||||||
|
bool full() const {
|
||||||
|
// head is ahead of the tail by 1
|
||||||
|
if (max_items_ > 0) {
|
||||||
|
return ((tail_ + 1) % max_items_) == head_;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t overrun_counter() const { return overrun_counter_; }
|
||||||
|
|
||||||
|
void reset_overrun_counter() { overrun_counter_ = 0; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// copy from other&& and reset it to disabled state
|
||||||
|
void copy_moveable(circular_q &&other) SPDLOG_NOEXCEPT {
|
||||||
|
max_items_ = other.max_items_;
|
||||||
|
head_ = other.head_;
|
||||||
|
tail_ = other.tail_;
|
||||||
|
overrun_counter_ = other.overrun_counter_;
|
||||||
|
v_ = std::move(other.v_);
|
||||||
|
|
||||||
|
// put &&other in disabled, but valid state
|
||||||
|
other.max_items_ = 0;
|
||||||
|
other.head_ = other.tail_ = 0;
|
||||||
|
other.overrun_counter_ = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
28
include/spdlog/details/console_globals.h
Normal file
28
include/spdlog/details/console_globals.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
#include <spdlog/details/null_mutex.h>
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
struct console_mutex {
|
||||||
|
using mutex_t = std::mutex;
|
||||||
|
static mutex_t &mutex() {
|
||||||
|
static mutex_t s_mutex;
|
||||||
|
return s_mutex;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct console_nullmutex {
|
||||||
|
using mutex_t = null_mutex;
|
||||||
|
static mutex_t &mutex() {
|
||||||
|
static mutex_t s_mutex;
|
||||||
|
return s_mutex;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
153
include/spdlog/details/file_helper-inl.h
Normal file
153
include/spdlog/details/file_helper-inl.h
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef SPDLOG_HEADER_ONLY
|
||||||
|
#include <spdlog/details/file_helper.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <spdlog/common.h>
|
||||||
|
#include <spdlog/details/os.h>
|
||||||
|
|
||||||
|
#include <cerrno>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
SPDLOG_INLINE file_helper::file_helper(const file_event_handlers &event_handlers)
|
||||||
|
: event_handlers_(event_handlers) {}
|
||||||
|
|
||||||
|
SPDLOG_INLINE file_helper::~file_helper() { close(); }
|
||||||
|
|
||||||
|
SPDLOG_INLINE void file_helper::open(const filename_t &fname, bool truncate) {
|
||||||
|
close();
|
||||||
|
filename_ = fname;
|
||||||
|
|
||||||
|
auto *mode = SPDLOG_FILENAME_T("ab");
|
||||||
|
auto *trunc_mode = SPDLOG_FILENAME_T("wb");
|
||||||
|
|
||||||
|
if (event_handlers_.before_open) {
|
||||||
|
event_handlers_.before_open(filename_);
|
||||||
|
}
|
||||||
|
for (int tries = 0; tries < open_tries_; ++tries) {
|
||||||
|
// create containing folder if not exists already.
|
||||||
|
os::create_dir(os::dir_name(fname));
|
||||||
|
if (truncate) {
|
||||||
|
// Truncate by opening-and-closing a tmp file in "wb" mode, always
|
||||||
|
// opening the actual log-we-write-to in "ab" mode, since that
|
||||||
|
// interacts more politely with eternal processes that might
|
||||||
|
// rotate/truncate the file underneath us.
|
||||||
|
std::FILE *tmp;
|
||||||
|
if (os::fopen_s(&tmp, fname, trunc_mode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::fclose(tmp);
|
||||||
|
}
|
||||||
|
if (!os::fopen_s(&fd_, fname, mode)) {
|
||||||
|
if (event_handlers_.after_open) {
|
||||||
|
event_handlers_.after_open(filename_, fd_);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
details::os::sleep_for_millis(open_interval_);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw_spdlog_ex("Failed opening file " + os::filename_to_str(filename_) + " for writing",
|
||||||
|
errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void file_helper::reopen(bool truncate) {
|
||||||
|
if (filename_.empty()) {
|
||||||
|
throw_spdlog_ex("Failed re opening file - was not opened before");
|
||||||
|
}
|
||||||
|
this->open(filename_, truncate);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void file_helper::flush() {
|
||||||
|
if (std::fflush(fd_) != 0) {
|
||||||
|
throw_spdlog_ex("Failed flush to file " + os::filename_to_str(filename_), errno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void file_helper::sync() {
|
||||||
|
if (!os::fsync(fd_)) {
|
||||||
|
throw_spdlog_ex("Failed to fsync file " + os::filename_to_str(filename_), errno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void file_helper::close() {
|
||||||
|
if (fd_ != nullptr) {
|
||||||
|
if (event_handlers_.before_close) {
|
||||||
|
event_handlers_.before_close(filename_, fd_);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::fclose(fd_);
|
||||||
|
fd_ = nullptr;
|
||||||
|
|
||||||
|
if (event_handlers_.after_close) {
|
||||||
|
event_handlers_.after_close(filename_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void file_helper::write(const memory_buf_t &buf) {
|
||||||
|
if (fd_ == nullptr) return;
|
||||||
|
size_t msg_size = buf.size();
|
||||||
|
auto data = buf.data();
|
||||||
|
|
||||||
|
if (!details::os::fwrite_bytes(data, msg_size, fd_)) {
|
||||||
|
throw_spdlog_ex("Failed writing to file " + os::filename_to_str(filename_), errno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE size_t file_helper::size() const {
|
||||||
|
if (fd_ == nullptr) {
|
||||||
|
throw_spdlog_ex("Cannot use size() on closed file " + os::filename_to_str(filename_));
|
||||||
|
}
|
||||||
|
return os::filesize(fd_);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE const filename_t &file_helper::filename() const { return filename_; }
|
||||||
|
|
||||||
|
//
|
||||||
|
// return file path and its extension:
|
||||||
|
//
|
||||||
|
// "mylog.txt" => ("mylog", ".txt")
|
||||||
|
// "mylog" => ("mylog", "")
|
||||||
|
// "mylog." => ("mylog.", "")
|
||||||
|
// "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt")
|
||||||
|
//
|
||||||
|
// the starting dot in filenames is ignored (hidden files):
|
||||||
|
//
|
||||||
|
// ".mylog" => (".mylog". "")
|
||||||
|
// "my_folder/.mylog" => ("my_folder/.mylog", "")
|
||||||
|
// "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt")
|
||||||
|
SPDLOG_INLINE std::tuple<filename_t, filename_t> file_helper::split_by_extension(
|
||||||
|
const filename_t &fname) {
|
||||||
|
auto ext_index = fname.rfind('.');
|
||||||
|
|
||||||
|
// no valid extension found - return whole path and empty string as
|
||||||
|
// extension
|
||||||
|
if (ext_index == filename_t::npos || ext_index == 0 || ext_index == fname.size() - 1) {
|
||||||
|
return std::make_tuple(fname, filename_t());
|
||||||
|
}
|
||||||
|
|
||||||
|
// treat cases like "/etc/rc.d/somelogfile or "/abc/.hiddenfile"
|
||||||
|
auto folder_index = fname.find_last_of(details::os::folder_seps_filename);
|
||||||
|
if (folder_index != filename_t::npos && folder_index >= ext_index - 1) {
|
||||||
|
return std::make_tuple(fname, filename_t());
|
||||||
|
}
|
||||||
|
|
||||||
|
// finally - return a valid base and extension tuple
|
||||||
|
return std::make_tuple(fname.substr(0, ext_index), fname.substr(ext_index));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
@ -1,137 +1,61 @@
|
|||||||
//
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Helper class for file sink
|
#include <spdlog/common.h>
|
||||||
// When failing to open a file, retry several times(5) with small delay between the tries(10 ms)
|
|
||||||
// Throw spdlog_ex exception on errors
|
|
||||||
|
|
||||||
#include "../details/os.h"
|
|
||||||
#include "../details/log_msg.h"
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <string>
|
|
||||||
#include <thread>
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <cerrno>
|
|
||||||
|
|
||||||
namespace spdlog
|
namespace spdlog {
|
||||||
{
|
namespace details {
|
||||||
namespace details
|
|
||||||
{
|
|
||||||
|
|
||||||
class file_helper
|
// Helper class for file sinks.
|
||||||
{
|
// When failing to open a file, retry several times(5) with a delay interval(10 ms).
|
||||||
|
// Throw spdlog_ex exception on errors.
|
||||||
|
|
||||||
|
class SPDLOG_API file_helper {
|
||||||
public:
|
public:
|
||||||
const int open_tries = 5;
|
file_helper() = default;
|
||||||
const int open_interval = 10;
|
explicit file_helper(const file_event_handlers &event_handlers);
|
||||||
|
|
||||||
explicit file_helper() :
|
file_helper(const file_helper &) = delete;
|
||||||
_fd(nullptr)
|
file_helper &operator=(const file_helper &) = delete;
|
||||||
{}
|
~file_helper();
|
||||||
|
|
||||||
file_helper(const file_helper&) = delete;
|
void open(const filename_t &fname, bool truncate = false);
|
||||||
file_helper& operator=(const file_helper&) = delete;
|
void reopen(bool truncate);
|
||||||
|
void flush();
|
||||||
~file_helper()
|
void sync();
|
||||||
{
|
void close();
|
||||||
close();
|
void write(const memory_buf_t &buf);
|
||||||
}
|
size_t size() const;
|
||||||
|
const filename_t &filename() const;
|
||||||
|
|
||||||
void open(const filename_t& fname, bool truncate = false)
|
|
||||||
{
|
|
||||||
|
|
||||||
close();
|
|
||||||
auto *mode = truncate ? SPDLOG_FILENAME_T("wb") : SPDLOG_FILENAME_T("ab");
|
|
||||||
_filename = fname;
|
|
||||||
for (int tries = 0; tries < open_tries; ++tries)
|
|
||||||
{
|
|
||||||
if (!os::fopen_s(&_fd, fname, mode))
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(open_interval));
|
|
||||||
}
|
|
||||||
|
|
||||||
throw spdlog_ex("Failed opening file " + os::filename_to_str(_filename) + " for writing", errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
void reopen(bool truncate)
|
|
||||||
{
|
|
||||||
if (_filename.empty())
|
|
||||||
throw spdlog_ex("Failed re opening file - was not opened before");
|
|
||||||
open(_filename, truncate);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void flush()
|
|
||||||
{
|
|
||||||
std::fflush(_fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void close()
|
|
||||||
{
|
|
||||||
if (_fd)
|
|
||||||
{
|
|
||||||
std::fclose(_fd);
|
|
||||||
_fd = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void write(const log_msg& msg)
|
|
||||||
{
|
|
||||||
size_t msg_size = msg.formatted.size();
|
|
||||||
auto data = msg.formatted.data();
|
|
||||||
if (std::fwrite(data, 1, msg_size, _fd) != msg_size)
|
|
||||||
throw spdlog_ex("Failed writing to file " + os::filename_to_str(_filename), errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size() const
|
|
||||||
{
|
|
||||||
if (!_fd)
|
|
||||||
throw spdlog_ex("Cannot use size() on closed file " + os::filename_to_str(_filename));
|
|
||||||
return os::filesize(_fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
const filename_t& filename() const
|
|
||||||
{
|
|
||||||
return _filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool file_exists(const filename_t& fname)
|
|
||||||
{
|
|
||||||
return os::file_exists(fname);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// return basename and extension:
|
// return file path and its extension:
|
||||||
//
|
//
|
||||||
// "mylog.txt" => ("mylog", ".txt")
|
// "mylog.txt" => ("mylog", ".txt")
|
||||||
// "mylog" => ("mylog", "")
|
// "mylog" => ("mylog", "")
|
||||||
|
// "mylog." => ("mylog.", "")
|
||||||
|
// "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt")
|
||||||
//
|
//
|
||||||
// the starting dot in filenames is ignored (hidden files):
|
// the starting dot in filenames is ignored (hidden files):
|
||||||
//
|
//
|
||||||
// "my_folder/.mylog" => ("my_folder/.mylog")
|
// ".mylog" => (".mylog". "")
|
||||||
|
// "my_folder/.mylog" => ("my_folder/.mylog", "")
|
||||||
// "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt")
|
// "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt")
|
||||||
|
static std::tuple<filename_t, filename_t> split_by_extension(const filename_t &fname);
|
||||||
static std::tuple<filename_t, filename_t> split_by_extenstion(const filename_t& fname)
|
|
||||||
{
|
|
||||||
auto index = fname.rfind('.');
|
|
||||||
bool found_ext = index != filename_t::npos && index !=0 && fname[index - 1] != details::os::folder_sep;
|
|
||||||
if (found_ext)
|
|
||||||
return std::make_tuple(fname.substr(0, index), fname.substr(index));
|
|
||||||
else
|
|
||||||
return std::make_tuple(fname, filename_t());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FILE* _fd;
|
const int open_tries_ = 5;
|
||||||
filename_t _filename;
|
const unsigned int open_interval_ = 10;
|
||||||
|
std::FILE *fd_{nullptr};
|
||||||
|
filename_t filename_;
|
||||||
|
file_event_handlers event_handlers_;
|
||||||
};
|
};
|
||||||
}
|
} // namespace details
|
||||||
}
|
} // namespace spdlog
|
||||||
|
|
||||||
|
#ifdef SPDLOG_HEADER_ONLY
|
||||||
|
#include "file_helper-inl.h"
|
||||||
|
#endif
|
||||||
|
141
include/spdlog/details/fmt_helper.h
Normal file
141
include/spdlog/details/fmt_helper.h
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <iterator>
|
||||||
|
#include <spdlog/common.h>
|
||||||
|
#include <spdlog/fmt/fmt.h>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#ifdef SPDLOG_USE_STD_FORMAT
|
||||||
|
#include <charconv>
|
||||||
|
#include <limits>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Some fmt helpers to efficiently format and pad ints and strings
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
namespace fmt_helper {
|
||||||
|
|
||||||
|
inline void append_string_view(spdlog::string_view_t view, memory_buf_t &dest) {
|
||||||
|
auto *buf_ptr = view.data();
|
||||||
|
dest.append(buf_ptr, buf_ptr + view.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SPDLOG_USE_STD_FORMAT
|
||||||
|
template <typename T>
|
||||||
|
inline void append_int(T n, memory_buf_t &dest) {
|
||||||
|
// Buffer should be large enough to hold all digits (digits10 + 1) and a sign
|
||||||
|
SPDLOG_CONSTEXPR const auto BUF_SIZE = std::numeric_limits<T>::digits10 + 2;
|
||||||
|
char buf[BUF_SIZE];
|
||||||
|
|
||||||
|
auto [ptr, ec] = std::to_chars(buf, buf + BUF_SIZE, n, 10);
|
||||||
|
if (ec == std::errc()) {
|
||||||
|
dest.append(buf, ptr);
|
||||||
|
} else {
|
||||||
|
throw_spdlog_ex("Failed to format int", static_cast<int>(ec));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
template <typename T>
|
||||||
|
inline void append_int(T n, memory_buf_t &dest) {
|
||||||
|
fmt::format_int i(n);
|
||||||
|
dest.append(i.data(), i.data() + i.size());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
SPDLOG_CONSTEXPR_FUNC unsigned int count_digits_fallback(T n) {
|
||||||
|
// taken from fmt: https://github.com/fmtlib/fmt/blob/8.0.1/include/fmt/format.h#L899-L912
|
||||||
|
unsigned int count = 1;
|
||||||
|
for (;;) {
|
||||||
|
// Integer division is slow so do it for a group of four digits instead
|
||||||
|
// of for every digit. The idea comes from the talk by Alexandrescu
|
||||||
|
// "Three Optimization Tips for C++". See speed-test for a comparison.
|
||||||
|
if (n < 10) return count;
|
||||||
|
if (n < 100) return count + 1;
|
||||||
|
if (n < 1000) return count + 2;
|
||||||
|
if (n < 10000) return count + 3;
|
||||||
|
n /= 10000u;
|
||||||
|
count += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline unsigned int count_digits(T n) {
|
||||||
|
using count_type =
|
||||||
|
typename std::conditional<(sizeof(T) > sizeof(uint32_t)), uint64_t, uint32_t>::type;
|
||||||
|
#ifdef SPDLOG_USE_STD_FORMAT
|
||||||
|
return count_digits_fallback(static_cast<count_type>(n));
|
||||||
|
#else
|
||||||
|
return static_cast<unsigned int>(fmt::
|
||||||
|
// fmt 7.0.0 renamed the internal namespace to detail.
|
||||||
|
// See: https://github.com/fmtlib/fmt/issues/1538
|
||||||
|
#if FMT_VERSION < 70000
|
||||||
|
internal
|
||||||
|
#else
|
||||||
|
detail
|
||||||
|
#endif
|
||||||
|
::count_digits(static_cast<count_type>(n)));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void pad2(int n, memory_buf_t &dest) {
|
||||||
|
if (n >= 0 && n < 100) // 0-99
|
||||||
|
{
|
||||||
|
dest.push_back(static_cast<char>('0' + n / 10));
|
||||||
|
dest.push_back(static_cast<char>('0' + n % 10));
|
||||||
|
} else // unlikely, but just in case, let fmt deal with it
|
||||||
|
{
|
||||||
|
fmt_lib::format_to(std::back_inserter(dest), SPDLOG_FMT_STRING("{:02}"), n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline void pad_uint(T n, unsigned int width, memory_buf_t &dest) {
|
||||||
|
static_assert(std::is_unsigned<T>::value, "pad_uint must get unsigned T");
|
||||||
|
for (auto digits = count_digits(n); digits < width; digits++) {
|
||||||
|
dest.push_back('0');
|
||||||
|
}
|
||||||
|
append_int(n, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline void pad3(T n, memory_buf_t &dest) {
|
||||||
|
static_assert(std::is_unsigned<T>::value, "pad3 must get unsigned T");
|
||||||
|
if (n < 1000) {
|
||||||
|
dest.push_back(static_cast<char>(n / 100 + '0'));
|
||||||
|
n = n % 100;
|
||||||
|
dest.push_back(static_cast<char>((n / 10) + '0'));
|
||||||
|
dest.push_back(static_cast<char>((n % 10) + '0'));
|
||||||
|
} else {
|
||||||
|
append_int(n, dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline void pad6(T n, memory_buf_t &dest) {
|
||||||
|
pad_uint(n, 6, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline void pad9(T n, memory_buf_t &dest) {
|
||||||
|
pad_uint(n, 9, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return fraction of a second of the given time_point.
|
||||||
|
// e.g.
|
||||||
|
// fraction<std::milliseconds>(tp) -> will return the millis part of the second
|
||||||
|
template <typename ToDuration>
|
||||||
|
inline ToDuration time_fraction(log_clock::time_point tp) {
|
||||||
|
using std::chrono::duration_cast;
|
||||||
|
using std::chrono::seconds;
|
||||||
|
auto duration = tp.time_since_epoch();
|
||||||
|
auto secs = duration_cast<seconds>(duration);
|
||||||
|
return duration_cast<ToDuration>(duration) - duration_cast<ToDuration>(secs);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace fmt_helper
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
44
include/spdlog/details/log_msg-inl.h
Normal file
44
include/spdlog/details/log_msg-inl.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef SPDLOG_HEADER_ONLY
|
||||||
|
#include <spdlog/details/log_msg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <spdlog/details/os.h>
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
SPDLOG_INLINE log_msg::log_msg(spdlog::log_clock::time_point log_time,
|
||||||
|
spdlog::source_loc loc,
|
||||||
|
string_view_t a_logger_name,
|
||||||
|
spdlog::level::level_enum lvl,
|
||||||
|
spdlog::string_view_t msg)
|
||||||
|
: logger_name(a_logger_name),
|
||||||
|
level(lvl),
|
||||||
|
time(log_time)
|
||||||
|
#ifndef SPDLOG_NO_THREAD_ID
|
||||||
|
,
|
||||||
|
thread_id(os::thread_id())
|
||||||
|
#endif
|
||||||
|
,
|
||||||
|
source(loc),
|
||||||
|
payload(msg) {
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE log_msg::log_msg(spdlog::source_loc loc,
|
||||||
|
string_view_t a_logger_name,
|
||||||
|
spdlog::level::level_enum lvl,
|
||||||
|
spdlog::string_view_t msg)
|
||||||
|
: log_msg(os::now(), loc, a_logger_name, lvl, msg) {}
|
||||||
|
|
||||||
|
SPDLOG_INLINE log_msg::log_msg(string_view_t a_logger_name,
|
||||||
|
spdlog::level::level_enum lvl,
|
||||||
|
spdlog::string_view_t msg)
|
||||||
|
: log_msg(os::now(), source_loc{}, a_logger_name, lvl, msg) {}
|
||||||
|
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
@ -1,50 +1,40 @@
|
|||||||
//
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../common.h"
|
#include <spdlog/common.h>
|
||||||
#include "../details/os.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace spdlog
|
namespace spdlog {
|
||||||
{
|
namespace details {
|
||||||
namespace details
|
struct SPDLOG_API log_msg {
|
||||||
{
|
|
||||||
struct log_msg
|
|
||||||
{
|
|
||||||
log_msg() = default;
|
log_msg() = default;
|
||||||
log_msg(const std::string *loggers_name, level::level_enum lvl) :
|
log_msg(log_clock::time_point log_time,
|
||||||
logger_name(loggers_name),
|
source_loc loc,
|
||||||
level(lvl),
|
string_view_t logger_name,
|
||||||
msg_id(0)
|
level::level_enum lvl,
|
||||||
{
|
string_view_t msg);
|
||||||
#ifndef SPDLOG_NO_DATETIME
|
log_msg(source_loc loc, string_view_t logger_name, level::level_enum lvl, string_view_t msg);
|
||||||
time = os::now();
|
log_msg(string_view_t logger_name, level::level_enum lvl, string_view_t msg);
|
||||||
#endif
|
log_msg(const log_msg &other) = default;
|
||||||
|
log_msg &operator=(const log_msg &other) = default;
|
||||||
|
|
||||||
#ifndef SPDLOG_NO_THREAD_ID
|
string_view_t logger_name;
|
||||||
thread_id = os::thread_id();
|
level::level_enum level{level::off};
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
log_msg(const log_msg& other) = delete;
|
|
||||||
log_msg& operator=(log_msg&& other) = delete;
|
|
||||||
log_msg(log_msg&& other) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
const std::string *logger_name;
|
|
||||||
level::level_enum level;
|
|
||||||
log_clock::time_point time;
|
log_clock::time_point time;
|
||||||
size_t thread_id;
|
size_t thread_id{0};
|
||||||
fmt::MemoryWriter raw;
|
|
||||||
fmt::MemoryWriter formatted;
|
// wrapping the formatted text with color (updated by pattern_formatter).
|
||||||
size_t msg_id;
|
mutable size_t color_range_start{0};
|
||||||
|
mutable size_t color_range_end{0};
|
||||||
|
|
||||||
|
source_loc source;
|
||||||
|
string_view_t payload;
|
||||||
};
|
};
|
||||||
}
|
} // namespace details
|
||||||
}
|
} // namespace spdlog
|
||||||
|
|
||||||
|
#ifdef SPDLOG_HEADER_ONLY
|
||||||
|
#include "log_msg-inl.h"
|
||||||
|
#endif
|
||||||
|
54
include/spdlog/details/log_msg_buffer-inl.h
Normal file
54
include/spdlog/details/log_msg_buffer-inl.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef SPDLOG_HEADER_ONLY
|
||||||
|
#include <spdlog/details/log_msg_buffer.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg &orig_msg)
|
||||||
|
: log_msg{orig_msg} {
|
||||||
|
buffer.append(logger_name.begin(), logger_name.end());
|
||||||
|
buffer.append(payload.begin(), payload.end());
|
||||||
|
update_string_views();
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg_buffer &other)
|
||||||
|
: log_msg{other} {
|
||||||
|
buffer.append(logger_name.begin(), logger_name.end());
|
||||||
|
buffer.append(payload.begin(), payload.end());
|
||||||
|
update_string_views();
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE log_msg_buffer::log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT
|
||||||
|
: log_msg{other},
|
||||||
|
buffer{std::move(other.buffer)} {
|
||||||
|
update_string_views();
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(const log_msg_buffer &other) {
|
||||||
|
log_msg::operator=(other);
|
||||||
|
buffer.clear();
|
||||||
|
buffer.append(other.buffer.data(), other.buffer.data() + other.buffer.size());
|
||||||
|
update_string_views();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT {
|
||||||
|
log_msg::operator=(other);
|
||||||
|
buffer = std::move(other.buffer);
|
||||||
|
update_string_views();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void log_msg_buffer::update_string_views() {
|
||||||
|
logger_name = string_view_t{buffer.data(), logger_name.size()};
|
||||||
|
payload = string_view_t{buffer.data() + logger_name.size(), payload.size()};
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
32
include/spdlog/details/log_msg_buffer.h
Normal file
32
include/spdlog/details/log_msg_buffer.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <spdlog/details/log_msg.h>
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
// Extend log_msg with internal buffer to store its payload.
|
||||||
|
// This is needed since log_msg holds string_views that points to stack data.
|
||||||
|
|
||||||
|
class SPDLOG_API log_msg_buffer : public log_msg {
|
||||||
|
memory_buf_t buffer;
|
||||||
|
void update_string_views();
|
||||||
|
|
||||||
|
public:
|
||||||
|
log_msg_buffer() = default;
|
||||||
|
explicit log_msg_buffer(const log_msg &orig_msg);
|
||||||
|
log_msg_buffer(const log_msg_buffer &other);
|
||||||
|
log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT;
|
||||||
|
log_msg_buffer &operator=(const log_msg_buffer &other);
|
||||||
|
log_msg_buffer &operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
||||||
|
|
||||||
|
#ifdef SPDLOG_HEADER_ONLY
|
||||||
|
#include "log_msg_buffer-inl.h"
|
||||||
|
#endif
|
@ -1,363 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../logger.h"
|
|
||||||
#include "../sinks/stdout_sinks.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
// create logger with given name, sinks and the default pattern formatter
|
|
||||||
// all other ctors will call this one
|
|
||||||
template<class It>
|
|
||||||
inline spdlog::logger::logger(const std::string& logger_name, const It& begin, const It& end):
|
|
||||||
_name(logger_name),
|
|
||||||
_sinks(begin, end),
|
|
||||||
_formatter(std::make_shared<pattern_formatter>("%+")),
|
|
||||||
_level(level::info),
|
|
||||||
_flush_level(level::off),
|
|
||||||
_last_err_time(0),
|
|
||||||
_msg_counter(1) // message counter will start from 1. 0-message id will be reserved for controll messages
|
|
||||||
{
|
|
||||||
_err_handler = [this](const std::string &msg)
|
|
||||||
{
|
|
||||||
this->_default_err_handler(msg);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// ctor with sinks as init list
|
|
||||||
inline spdlog::logger::logger(const std::string& logger_name, sinks_init_list sinks_list):
|
|
||||||
logger(logger_name, sinks_list.begin(), sinks_list.end())
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// ctor with single sink
|
|
||||||
inline spdlog::logger::logger(const std::string& logger_name, spdlog::sink_ptr single_sink):
|
|
||||||
logger(logger_name,
|
|
||||||
{
|
|
||||||
single_sink
|
|
||||||
})
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
inline spdlog::logger::~logger() = default;
|
|
||||||
|
|
||||||
|
|
||||||
inline void spdlog::logger::set_formatter(spdlog::formatter_ptr msg_formatter)
|
|
||||||
{
|
|
||||||
_set_formatter(msg_formatter);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::logger::set_pattern(const std::string& pattern, pattern_time_type pattern_time)
|
|
||||||
{
|
|
||||||
_set_pattern(pattern, pattern_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
inline void spdlog::logger::log(level::level_enum lvl, const char* fmt, const Args&... args)
|
|
||||||
{
|
|
||||||
if (!should_log(lvl)) return;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
details::log_msg log_msg(&_name, lvl);
|
|
||||||
|
|
||||||
#if defined(SPDLOG_FMT_PRINTF)
|
|
||||||
fmt::printf(log_msg.raw, fmt, args...);
|
|
||||||
#else
|
|
||||||
log_msg.raw.write(fmt, args...);
|
|
||||||
#endif
|
|
||||||
_sink_it(log_msg);
|
|
||||||
}
|
|
||||||
catch (const std::exception &ex)
|
|
||||||
{
|
|
||||||
_err_handler(ex.what());
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
_err_handler("Unknown exception in logger " + _name);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
inline void spdlog::logger::log(level::level_enum lvl, const char* msg)
|
|
||||||
{
|
|
||||||
if (!should_log(lvl)) return;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
details::log_msg log_msg(&_name, lvl);
|
|
||||||
log_msg.raw << msg;
|
|
||||||
_sink_it(log_msg);
|
|
||||||
}
|
|
||||||
catch (const std::exception &ex)
|
|
||||||
{
|
|
||||||
_err_handler(ex.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline void spdlog::logger::log(level::level_enum lvl, const T& msg)
|
|
||||||
{
|
|
||||||
if (!should_log(lvl)) return;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
details::log_msg log_msg(&_name, lvl);
|
|
||||||
log_msg.raw << msg;
|
|
||||||
_sink_it(log_msg);
|
|
||||||
}
|
|
||||||
catch (const std::exception &ex)
|
|
||||||
{
|
|
||||||
_err_handler(ex.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <typename Arg1, typename... Args>
|
|
||||||
inline void spdlog::logger::trace(const char* fmt, const Arg1 &arg1, const Args&... args)
|
|
||||||
{
|
|
||||||
log(level::trace, fmt, arg1, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Arg1, typename... Args>
|
|
||||||
inline void spdlog::logger::debug(const char* fmt, const Arg1 &arg1, const Args&... args)
|
|
||||||
{
|
|
||||||
log(level::debug, fmt, arg1, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Arg1, typename... Args>
|
|
||||||
inline void spdlog::logger::info(const char* fmt, const Arg1 &arg1, const Args&... args)
|
|
||||||
{
|
|
||||||
log(level::info, fmt, arg1, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Arg1, typename... Args>
|
|
||||||
inline void spdlog::logger::warn(const char* fmt, const Arg1 &arg1, const Args&... args)
|
|
||||||
{
|
|
||||||
log(level::warn, fmt, arg1, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Arg1, typename... Args>
|
|
||||||
inline void spdlog::logger::error(const char* fmt, const Arg1 &arg1, const Args&... args)
|
|
||||||
{
|
|
||||||
log(level::err, fmt, arg1, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Arg1, typename... Args>
|
|
||||||
inline void spdlog::logger::critical(const char* fmt, const Arg1 &arg1, const Args&... args)
|
|
||||||
{
|
|
||||||
log(level::critical, fmt, arg1, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline void spdlog::logger::trace(const T& msg)
|
|
||||||
{
|
|
||||||
log(level::trace, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline void spdlog::logger::debug(const T& msg)
|
|
||||||
{
|
|
||||||
log(level::debug, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline void spdlog::logger::info(const T& msg)
|
|
||||||
{
|
|
||||||
log(level::info, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline void spdlog::logger::warn(const T& msg)
|
|
||||||
{
|
|
||||||
log(level::warn, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline void spdlog::logger::error(const T& msg)
|
|
||||||
{
|
|
||||||
log(level::err, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline void spdlog::logger::critical(const T& msg)
|
|
||||||
{
|
|
||||||
log(level::critical, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
|
||||||
#include <codecvt>
|
|
||||||
#include <locale>
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
inline void spdlog::logger::log(level::level_enum lvl, const wchar_t* msg)
|
|
||||||
{
|
|
||||||
std::wstring_convert<std::codecvt_utf8<wchar_t> > conv;
|
|
||||||
|
|
||||||
log(lvl, conv.to_bytes(msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
inline void spdlog::logger::log(level::level_enum lvl, const wchar_t* fmt, const Args&... args)
|
|
||||||
{
|
|
||||||
fmt::WMemoryWriter wWriter;
|
|
||||||
|
|
||||||
wWriter.write(fmt, args...);
|
|
||||||
log(lvl, wWriter.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
inline void spdlog::logger::trace(const wchar_t* fmt, const Args&... args)
|
|
||||||
{
|
|
||||||
log(level::trace, fmt, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
inline void spdlog::logger::debug(const wchar_t* fmt, const Args&... args)
|
|
||||||
{
|
|
||||||
log(level::debug, fmt, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
inline void spdlog::logger::info(const wchar_t* fmt, const Args&... args)
|
|
||||||
{
|
|
||||||
log(level::info, fmt, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
inline void spdlog::logger::warn(const wchar_t* fmt, const Args&... args)
|
|
||||||
{
|
|
||||||
log(level::warn, fmt, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
inline void spdlog::logger::error(const wchar_t* fmt, const Args&... args)
|
|
||||||
{
|
|
||||||
log(level::err, fmt, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
inline void spdlog::logger::critical(const wchar_t* fmt, const Args&... args)
|
|
||||||
{
|
|
||||||
log(level::critical, fmt, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// name and level
|
|
||||||
//
|
|
||||||
inline const std::string& spdlog::logger::name() const
|
|
||||||
{
|
|
||||||
return _name;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::logger::set_level(spdlog::level::level_enum log_level)
|
|
||||||
{
|
|
||||||
_level.store(log_level);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::logger::set_error_handler(spdlog::log_err_handler err_handler)
|
|
||||||
{
|
|
||||||
_err_handler = err_handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline spdlog::log_err_handler spdlog::logger::error_handler()
|
|
||||||
{
|
|
||||||
return _err_handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void spdlog::logger::flush_on(level::level_enum log_level)
|
|
||||||
{
|
|
||||||
_flush_level.store(log_level);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline spdlog::level::level_enum spdlog::logger::level() const
|
|
||||||
{
|
|
||||||
return static_cast<spdlog::level::level_enum>(_level.load(std::memory_order_relaxed));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) const
|
|
||||||
{
|
|
||||||
return msg_level >= _level.load(std::memory_order_relaxed);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// protected virtual called at end of each user log call (if enabled) by the line_logger
|
|
||||||
//
|
|
||||||
inline void spdlog::logger::_sink_it(details::log_msg& msg)
|
|
||||||
{
|
|
||||||
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
|
|
||||||
_incr_msg_counter(msg);
|
|
||||||
#endif
|
|
||||||
_formatter->format(msg);
|
|
||||||
for (auto &sink : _sinks)
|
|
||||||
{
|
|
||||||
if( sink->should_log( msg.level))
|
|
||||||
{
|
|
||||||
sink->log(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_should_flush_on(msg))
|
|
||||||
flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::logger::_set_pattern(const std::string& pattern, pattern_time_type pattern_time)
|
|
||||||
{
|
|
||||||
_formatter = std::make_shared<pattern_formatter>(pattern, pattern_time);
|
|
||||||
}
|
|
||||||
inline void spdlog::logger::_set_formatter(formatter_ptr msg_formatter)
|
|
||||||
{
|
|
||||||
_formatter = msg_formatter;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::logger::flush()
|
|
||||||
{
|
|
||||||
for (auto& sink : _sinks)
|
|
||||||
sink->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::logger::_default_err_handler(const std::string &msg)
|
|
||||||
{
|
|
||||||
auto now = time(nullptr);
|
|
||||||
if (now - _last_err_time < 60)
|
|
||||||
return;
|
|
||||||
auto tm_time = details::os::localtime(now);
|
|
||||||
char date_buf[100];
|
|
||||||
std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time);
|
|
||||||
details::log_msg err_msg;
|
|
||||||
err_msg.formatted.write("[*** LOG ERROR ***] [{}] [{}] [{}]{}", name(), msg, date_buf, details::os::eol);
|
|
||||||
sinks::stderr_sink_mt::instance()->log(err_msg);
|
|
||||||
_last_err_time = now;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool spdlog::logger::_should_flush_on(const details::log_msg &msg)
|
|
||||||
{
|
|
||||||
const auto flush_level = _flush_level.load(std::memory_order_relaxed);
|
|
||||||
return (msg.level >= flush_level) && (msg.level != level::off);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::logger::_incr_msg_counter(details::log_msg &msg)
|
|
||||||
{
|
|
||||||
msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const std::vector<spdlog::sink_ptr>& spdlog::logger::sinks() const
|
|
||||||
{
|
|
||||||
return _sinks;
|
|
||||||
}
|
|
||||||
|
|
177
include/spdlog/details/mpmc_blocking_q.h
Normal file
177
include/spdlog/details/mpmc_blocking_q.h
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// multi producer-multi consumer blocking queue.
|
||||||
|
// enqueue(..) - will block until room found to put the new message.
|
||||||
|
// enqueue_nowait(..) - will return immediately with false if no room left in
|
||||||
|
// the queue.
|
||||||
|
// dequeue_for(..) - will block until the queue is not empty or timeout have
|
||||||
|
// passed.
|
||||||
|
|
||||||
|
#include <spdlog/details/circular_q.h>
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class mpmc_blocking_queue {
|
||||||
|
public:
|
||||||
|
using item_type = T;
|
||||||
|
explicit mpmc_blocking_queue(size_t max_items)
|
||||||
|
: q_(max_items) {}
|
||||||
|
|
||||||
|
#ifndef __MINGW32__
|
||||||
|
// try to enqueue and block if no room left
|
||||||
|
void enqueue(T &&item) {
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||||
|
pop_cv_.wait(lock, [this] { return !this->q_.full(); });
|
||||||
|
q_.push_back(std::move(item));
|
||||||
|
}
|
||||||
|
push_cv_.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
|
// enqueue immediately. overrun oldest message in the queue if no room left.
|
||||||
|
void enqueue_nowait(T &&item) {
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||||
|
q_.push_back(std::move(item));
|
||||||
|
}
|
||||||
|
push_cv_.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
|
void enqueue_if_have_room(T &&item) {
|
||||||
|
bool pushed = false;
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||||
|
if (!q_.full()) {
|
||||||
|
q_.push_back(std::move(item));
|
||||||
|
pushed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pushed) {
|
||||||
|
push_cv_.notify_one();
|
||||||
|
} else {
|
||||||
|
++discard_counter_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// dequeue with a timeout.
|
||||||
|
// Return true, if succeeded dequeue item, false otherwise
|
||||||
|
bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration) {
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||||
|
if (!push_cv_.wait_for(lock, wait_duration, [this] { return !this->q_.empty(); })) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
popped_item = std::move(q_.front());
|
||||||
|
q_.pop_front();
|
||||||
|
}
|
||||||
|
pop_cv_.notify_one();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// blocking dequeue without a timeout.
|
||||||
|
void dequeue(T &popped_item) {
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||||
|
push_cv_.wait(lock, [this] { return !this->q_.empty(); });
|
||||||
|
popped_item = std::move(q_.front());
|
||||||
|
q_.pop_front();
|
||||||
|
}
|
||||||
|
pop_cv_.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
// apparently mingw deadlocks if the mutex is released before cv.notify_one(),
|
||||||
|
// so release the mutex at the very end each function.
|
||||||
|
|
||||||
|
// try to enqueue and block if no room left
|
||||||
|
void enqueue(T &&item) {
|
||||||
|
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||||
|
pop_cv_.wait(lock, [this] { return !this->q_.full(); });
|
||||||
|
q_.push_back(std::move(item));
|
||||||
|
push_cv_.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
|
// enqueue immediately. overrun oldest message in the queue if no room left.
|
||||||
|
void enqueue_nowait(T &&item) {
|
||||||
|
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||||
|
q_.push_back(std::move(item));
|
||||||
|
push_cv_.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
|
void enqueue_if_have_room(T &&item) {
|
||||||
|
bool pushed = false;
|
||||||
|
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||||
|
if (!q_.full()) {
|
||||||
|
q_.push_back(std::move(item));
|
||||||
|
pushed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pushed) {
|
||||||
|
push_cv_.notify_one();
|
||||||
|
} else {
|
||||||
|
++discard_counter_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// dequeue with a timeout.
|
||||||
|
// Return true, if succeeded dequeue item, false otherwise
|
||||||
|
bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration) {
|
||||||
|
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||||
|
if (!push_cv_.wait_for(lock, wait_duration, [this] { return !this->q_.empty(); })) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
popped_item = std::move(q_.front());
|
||||||
|
q_.pop_front();
|
||||||
|
pop_cv_.notify_one();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// blocking dequeue without a timeout.
|
||||||
|
void dequeue(T &popped_item) {
|
||||||
|
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||||
|
push_cv_.wait(lock, [this] { return !this->q_.empty(); });
|
||||||
|
popped_item = std::move(q_.front());
|
||||||
|
q_.pop_front();
|
||||||
|
pop_cv_.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
size_t overrun_counter() {
|
||||||
|
std::lock_guard<std::mutex> lock(queue_mutex_);
|
||||||
|
return q_.overrun_counter();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t discard_counter() { return discard_counter_.load(std::memory_order_relaxed); }
|
||||||
|
|
||||||
|
size_t size() {
|
||||||
|
std::lock_guard<std::mutex> lock(queue_mutex_);
|
||||||
|
return q_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset_overrun_counter() {
|
||||||
|
std::lock_guard<std::mutex> lock(queue_mutex_);
|
||||||
|
q_.reset_overrun_counter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset_discard_counter() { discard_counter_.store(0, std::memory_order_relaxed); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::mutex queue_mutex_;
|
||||||
|
std::condition_variable push_cv_;
|
||||||
|
std::condition_variable pop_cv_;
|
||||||
|
spdlog::details::circular_q<T> q_;
|
||||||
|
std::atomic<size_t> discard_counter_{0};
|
||||||
|
};
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
@ -1,176 +0,0 @@
|
|||||||
/*
|
|
||||||
A modified version of Bounded MPMC queue by Dmitry Vyukov.
|
|
||||||
|
|
||||||
Original code from:
|
|
||||||
http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue
|
|
||||||
|
|
||||||
licensed by Dmitry Vyukov under the terms below:
|
|
||||||
|
|
||||||
Simplified BSD license
|
|
||||||
|
|
||||||
Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved.
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
conditions and the following disclaimer.
|
|
||||||
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY DMITRY VYUKOV "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
||||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
||||||
SHALL DMITRY VYUKOV OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
||||||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
||||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
The views and conclusions contained in the software and documentation are those of the authors and
|
|
||||||
should not be interpreted as representing official policies, either expressed or implied, of Dmitry Vyukov.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
The code in its current form adds the license below:
|
|
||||||
|
|
||||||
Copyright(c) 2015 Gabi Melman.
|
|
||||||
Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../common.h"
|
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace spdlog
|
|
||||||
{
|
|
||||||
namespace details
|
|
||||||
{
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class mpmc_bounded_queue
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
using item_type = T;
|
|
||||||
mpmc_bounded_queue(size_t buffer_size)
|
|
||||||
:max_size_(buffer_size),
|
|
||||||
buffer_(new cell_t[buffer_size]),
|
|
||||||
buffer_mask_(buffer_size - 1)
|
|
||||||
{
|
|
||||||
//queue size must be power of two
|
|
||||||
if (!((buffer_size >= 2) && ((buffer_size & (buffer_size - 1)) == 0)))
|
|
||||||
throw spdlog_ex("async logger queue size must be power of two");
|
|
||||||
|
|
||||||
for (size_t i = 0; i != buffer_size; i += 1)
|
|
||||||
buffer_[i].sequence_.store(i, std::memory_order_relaxed);
|
|
||||||
enqueue_pos_.store(0, std::memory_order_relaxed);
|
|
||||||
dequeue_pos_.store(0, std::memory_order_relaxed);
|
|
||||||
}
|
|
||||||
|
|
||||||
~mpmc_bounded_queue()
|
|
||||||
{
|
|
||||||
delete[] buffer_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool enqueue(T&& data)
|
|
||||||
{
|
|
||||||
cell_t* cell;
|
|
||||||
size_t pos = enqueue_pos_.load(std::memory_order_relaxed);
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
cell = &buffer_[pos & buffer_mask_];
|
|
||||||
size_t seq = cell->sequence_.load(std::memory_order_acquire);
|
|
||||||
intptr_t dif = static_cast<intptr_t>(seq) - static_cast<intptr_t>(pos);
|
|
||||||
if (dif == 0)
|
|
||||||
{
|
|
||||||
if (enqueue_pos_.compare_exchange_weak(pos, pos + 1, std::memory_order_relaxed))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (dif < 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pos = enqueue_pos_.load(std::memory_order_relaxed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cell->data_ = std::move(data);
|
|
||||||
cell->sequence_.store(pos + 1, std::memory_order_release);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dequeue(T& data)
|
|
||||||
{
|
|
||||||
cell_t* cell;
|
|
||||||
size_t pos = dequeue_pos_.load(std::memory_order_relaxed);
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
cell = &buffer_[pos & buffer_mask_];
|
|
||||||
size_t seq =
|
|
||||||
cell->sequence_.load(std::memory_order_acquire);
|
|
||||||
intptr_t dif = static_cast<intptr_t>(seq) - static_cast<intptr_t>(pos + 1);
|
|
||||||
if (dif == 0)
|
|
||||||
{
|
|
||||||
if (dequeue_pos_.compare_exchange_weak(pos, pos + 1, std::memory_order_relaxed))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (dif < 0)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
pos = dequeue_pos_.load(std::memory_order_relaxed);
|
|
||||||
}
|
|
||||||
data = std::move(cell->data_);
|
|
||||||
cell->sequence_.store(pos + buffer_mask_ + 1, std::memory_order_release);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_empty()
|
|
||||||
{
|
|
||||||
size_t front, front1, back;
|
|
||||||
// try to take a consistent snapshot of front/tail.
|
|
||||||
do
|
|
||||||
{
|
|
||||||
front = enqueue_pos_.load(std::memory_order_acquire);
|
|
||||||
back = dequeue_pos_.load(std::memory_order_acquire);
|
|
||||||
front1 = enqueue_pos_.load(std::memory_order_relaxed);
|
|
||||||
}
|
|
||||||
while (front != front1);
|
|
||||||
return back == front;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct cell_t
|
|
||||||
{
|
|
||||||
std::atomic<size_t> sequence_;
|
|
||||||
T data_;
|
|
||||||
};
|
|
||||||
|
|
||||||
size_t const max_size_;
|
|
||||||
|
|
||||||
static size_t const cacheline_size = 64;
|
|
||||||
typedef char cacheline_pad_t[cacheline_size];
|
|
||||||
|
|
||||||
cacheline_pad_t pad0_;
|
|
||||||
cell_t* const buffer_;
|
|
||||||
size_t const buffer_mask_;
|
|
||||||
cacheline_pad_t pad1_;
|
|
||||||
std::atomic<size_t> enqueue_pos_;
|
|
||||||
cacheline_pad_t pad2_;
|
|
||||||
std::atomic<size_t> dequeue_pos_;
|
|
||||||
cacheline_pad_t pad3_;
|
|
||||||
|
|
||||||
mpmc_bounded_queue(mpmc_bounded_queue const&) = delete;
|
|
||||||
void operator= (mpmc_bounded_queue const&) = delete;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // ns details
|
|
||||||
} // ns spdlog
|
|
@ -1,45 +1,35 @@
|
|||||||
//
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <utility>
|
||||||
// null, no cost dummy "mutex" and dummy "atomic" int
|
// null, no cost dummy "mutex" and dummy "atomic" int
|
||||||
|
|
||||||
namespace spdlog
|
namespace spdlog {
|
||||||
{
|
namespace details {
|
||||||
namespace details
|
struct null_mutex {
|
||||||
{
|
void lock() const {}
|
||||||
struct null_mutex
|
void unlock() const {}
|
||||||
{
|
|
||||||
void lock() {}
|
|
||||||
void unlock() {}
|
|
||||||
bool try_lock()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct null_atomic_int
|
struct null_atomic_int {
|
||||||
{
|
|
||||||
int value;
|
int value;
|
||||||
null_atomic_int() = default;
|
null_atomic_int() = default;
|
||||||
|
|
||||||
null_atomic_int(int val):value(val)
|
explicit null_atomic_int(int new_value)
|
||||||
{}
|
: value(new_value) {}
|
||||||
|
|
||||||
int load(std::memory_order) const
|
int load(std::memory_order = std::memory_order_relaxed) const { return value; }
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void store(int val)
|
void store(int new_value, std::memory_order = std::memory_order_relaxed) { value = new_value; }
|
||||||
{
|
|
||||||
value = val;
|
int exchange(int new_value, std::memory_order = std::memory_order_relaxed) {
|
||||||
|
std::swap(new_value, value);
|
||||||
|
return new_value; // return value before the call
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace details
|
||||||
}
|
} // namespace spdlog
|
||||||
|
607
include/spdlog/details/os-inl.h
Normal file
607
include/spdlog/details/os-inl.h
Normal file
@ -0,0 +1,607 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef SPDLOG_HEADER_ONLY
|
||||||
|
#include <spdlog/details/os.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <spdlog/common.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <ctime>
|
||||||
|
#include <string>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <spdlog/details/windows_include.h>
|
||||||
|
#include <fileapi.h> // for FlushFileBuffers
|
||||||
|
#include <io.h> // for _get_osfhandle, _isatty, _fileno
|
||||||
|
#include <process.h> // for _get_pid
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#include <share.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)
|
||||||
|
#include <cassert>
|
||||||
|
#include <limits>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <direct.h> // for _mkdir/_wmkdir
|
||||||
|
|
||||||
|
#else // unix
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
|
||||||
|
|
||||||
|
#elif defined(_AIX)
|
||||||
|
#include <pthread.h> // for pthread_getthrds_np
|
||||||
|
|
||||||
|
#elif defined(__DragonFly__) || defined(__FreeBSD__)
|
||||||
|
#include <pthread_np.h> // for pthread_getthreadid_np
|
||||||
|
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
#include <lwp.h> // for _lwp_self
|
||||||
|
|
||||||
|
#elif defined(__sun)
|
||||||
|
#include <thread.h> // for thr_self
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // unix
|
||||||
|
|
||||||
|
#if defined __APPLE__
|
||||||
|
#include <AvailabilityMacros.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __has_feature // Clang - feature checking macros.
|
||||||
|
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
namespace os {
|
||||||
|
|
||||||
|
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT {
|
||||||
|
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
|
||||||
|
timespec ts;
|
||||||
|
::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
|
||||||
|
return std::chrono::time_point<log_clock, typename log_clock::duration>(
|
||||||
|
std::chrono::duration_cast<typename log_clock::duration>(
|
||||||
|
std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec)));
|
||||||
|
|
||||||
|
#else
|
||||||
|
return log_clock::now();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::tm tm;
|
||||||
|
::localtime_s(&tm, &time_tt);
|
||||||
|
#else
|
||||||
|
std::tm tm;
|
||||||
|
::localtime_r(&time_tt, &tm);
|
||||||
|
#endif
|
||||||
|
return tm;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE std::tm localtime() SPDLOG_NOEXCEPT {
|
||||||
|
std::time_t now_t = ::time(nullptr);
|
||||||
|
return localtime(now_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::tm tm;
|
||||||
|
::gmtime_s(&tm, &time_tt);
|
||||||
|
#else
|
||||||
|
std::tm tm;
|
||||||
|
::gmtime_r(&time_tt, &tm);
|
||||||
|
#endif
|
||||||
|
return tm;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE std::tm gmtime() SPDLOG_NOEXCEPT {
|
||||||
|
std::time_t now_t = ::time(nullptr);
|
||||||
|
return gmtime(now_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fopen_s on non windows for writing
|
||||||
|
SPDLOG_INLINE bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mode) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifdef SPDLOG_WCHAR_FILENAMES
|
||||||
|
*fp = ::_wfsopen((filename.c_str()), mode.c_str(), _SH_DENYNO);
|
||||||
|
#else
|
||||||
|
*fp = ::_fsopen((filename.c_str()), mode.c_str(), _SH_DENYNO);
|
||||||
|
#endif
|
||||||
|
#if defined(SPDLOG_PREVENT_CHILD_FD)
|
||||||
|
if (*fp != nullptr) {
|
||||||
|
auto file_handle = reinterpret_cast<HANDLE>(_get_osfhandle(::_fileno(*fp)));
|
||||||
|
if (!::SetHandleInformation(file_handle, HANDLE_FLAG_INHERIT, 0)) {
|
||||||
|
::fclose(*fp);
|
||||||
|
*fp = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#else // unix
|
||||||
|
#if defined(SPDLOG_PREVENT_CHILD_FD)
|
||||||
|
const int mode_flag = mode == SPDLOG_FILENAME_T("ab") ? O_APPEND : O_TRUNC;
|
||||||
|
const int fd =
|
||||||
|
::open((filename.c_str()), O_CREAT | O_WRONLY | O_CLOEXEC | mode_flag, mode_t(0644));
|
||||||
|
if (fd == -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*fp = ::fdopen(fd, mode.c_str());
|
||||||
|
if (*fp == nullptr) {
|
||||||
|
::close(fd);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
*fp = ::fopen((filename.c_str()), mode.c_str());
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return *fp == nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE int remove(const filename_t &filename) SPDLOG_NOEXCEPT {
|
||||||
|
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
||||||
|
return ::_wremove(filename.c_str());
|
||||||
|
#else
|
||||||
|
return std::remove(filename.c_str());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT {
|
||||||
|
return path_exists(filename) ? remove(filename) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT {
|
||||||
|
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
||||||
|
return ::_wrename(filename1.c_str(), filename2.c_str());
|
||||||
|
#else
|
||||||
|
return std::rename(filename1.c_str(), filename2.c_str());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return true if path exists (file or directory)
|
||||||
|
SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT {
|
||||||
|
#ifdef _WIN32
|
||||||
|
struct _stat buffer;
|
||||||
|
#ifdef SPDLOG_WCHAR_FILENAMES
|
||||||
|
return (::_wstat(filename.c_str(), &buffer) == 0);
|
||||||
|
#else
|
||||||
|
return (::_stat(filename.c_str(), &buffer) == 0);
|
||||||
|
#endif
|
||||||
|
#else // common linux/unix all have the stat system call
|
||||||
|
struct stat buffer;
|
||||||
|
return (::stat(filename.c_str(), &buffer) == 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// avoid warning about unreachable statement at the end of filesize()
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4702)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Return file size according to open FILE* object
|
||||||
|
SPDLOG_INLINE size_t filesize(FILE *f) {
|
||||||
|
if (f == nullptr) {
|
||||||
|
throw_spdlog_ex("Failed getting file size. fd is null");
|
||||||
|
}
|
||||||
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
int fd = ::_fileno(f);
|
||||||
|
#if defined(_WIN64) // 64 bits
|
||||||
|
__int64 ret = ::_filelengthi64(fd);
|
||||||
|
if (ret >= 0) {
|
||||||
|
return static_cast<size_t>(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // windows 32 bits
|
||||||
|
long ret = ::_filelength(fd);
|
||||||
|
if (ret >= 0) {
|
||||||
|
return static_cast<size_t>(ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else // unix
|
||||||
|
// OpenBSD and AIX doesn't compile with :: before the fileno(..)
|
||||||
|
#if defined(__OpenBSD__) || defined(_AIX)
|
||||||
|
int fd = fileno(f);
|
||||||
|
#else
|
||||||
|
int fd = ::fileno(f);
|
||||||
|
#endif
|
||||||
|
// 64 bits(but not in osx, linux/musl or cygwin, where fstat64 is deprecated)
|
||||||
|
#if ((defined(__linux__) && defined(__GLIBC__)) || defined(__sun) || defined(_AIX)) && \
|
||||||
|
(defined(__LP64__) || defined(_LP64))
|
||||||
|
struct stat64 st;
|
||||||
|
if (::fstat64(fd, &st) == 0) {
|
||||||
|
return static_cast<size_t>(st.st_size);
|
||||||
|
}
|
||||||
|
#else // other unix or linux 32 bits or cygwin
|
||||||
|
struct stat st;
|
||||||
|
if (::fstat(fd, &st) == 0) {
|
||||||
|
return static_cast<size_t>(st.st_size);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
throw_spdlog_ex("Failed getting file size from fd", errno);
|
||||||
|
return 0; // will not be reached.
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Return utc offset in minutes or throw spdlog_ex on failure
|
||||||
|
SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
#if _WIN32_WINNT < _WIN32_WINNT_WS08
|
||||||
|
TIME_ZONE_INFORMATION tzinfo;
|
||||||
|
auto rv = ::GetTimeZoneInformation(&tzinfo);
|
||||||
|
#else
|
||||||
|
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
|
||||||
|
auto rv = ::GetDynamicTimeZoneInformation(&tzinfo);
|
||||||
|
#endif
|
||||||
|
if (rv == TIME_ZONE_ID_INVALID) throw_spdlog_ex("Failed getting timezone info. ", errno);
|
||||||
|
|
||||||
|
int offset = -tzinfo.Bias;
|
||||||
|
if (tm.tm_isdst) {
|
||||||
|
offset -= tzinfo.DaylightBias;
|
||||||
|
} else {
|
||||||
|
offset -= tzinfo.StandardBias;
|
||||||
|
}
|
||||||
|
return offset;
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if defined(sun) || defined(__sun) || defined(_AIX) || \
|
||||||
|
(defined(__NEWLIB__) && !defined(__TM_GMTOFF)) || \
|
||||||
|
(!defined(__APPLE__) && !defined(_BSD_SOURCE) && !defined(_GNU_SOURCE) && \
|
||||||
|
(!defined(_POSIX_VERSION) || (_POSIX_VERSION < 202405L)))
|
||||||
|
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
|
||||||
|
struct helper {
|
||||||
|
static long int calculate_gmt_offset(const std::tm &localtm = details::os::localtime(),
|
||||||
|
const std::tm &gmtm = details::os::gmtime()) {
|
||||||
|
int local_year = localtm.tm_year + (1900 - 1);
|
||||||
|
int gmt_year = gmtm.tm_year + (1900 - 1);
|
||||||
|
|
||||||
|
long int days = (
|
||||||
|
// difference in day of year
|
||||||
|
localtm.tm_yday -
|
||||||
|
gmtm.tm_yday
|
||||||
|
|
||||||
|
// + intervening leap days
|
||||||
|
+ ((local_year >> 2) - (gmt_year >> 2)) - (local_year / 100 - gmt_year / 100) +
|
||||||
|
((local_year / 100 >> 2) - (gmt_year / 100 >> 2))
|
||||||
|
|
||||||
|
// + difference in years * 365 */
|
||||||
|
+ static_cast<long int>(local_year - gmt_year) * 365);
|
||||||
|
|
||||||
|
long int hours = (24 * days) + (localtm.tm_hour - gmtm.tm_hour);
|
||||||
|
long int mins = (60 * hours) + (localtm.tm_min - gmtm.tm_min);
|
||||||
|
long int secs = (60 * mins) + (localtm.tm_sec - gmtm.tm_sec);
|
||||||
|
|
||||||
|
return secs;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto offset_seconds = helper::calculate_gmt_offset(tm);
|
||||||
|
#else
|
||||||
|
auto offset_seconds = tm.tm_gmtoff;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return static_cast<int>(offset_seconds / 60);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return current thread id as size_t
|
||||||
|
// It exists because the std::this_thread::get_id() is much slower(especially
|
||||||
|
// under VS 2013)
|
||||||
|
SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT {
|
||||||
|
#ifdef _WIN32
|
||||||
|
return static_cast<size_t>(::GetCurrentThreadId());
|
||||||
|
#elif defined(__linux__)
|
||||||
|
#if defined(__ANDROID__) && defined(__ANDROID_API__) && (__ANDROID_API__ < 21)
|
||||||
|
#define SYS_gettid __NR_gettid
|
||||||
|
#endif
|
||||||
|
return static_cast<size_t>(::syscall(SYS_gettid));
|
||||||
|
#elif defined(_AIX)
|
||||||
|
struct __pthrdsinfo buf;
|
||||||
|
int reg_size = 0;
|
||||||
|
pthread_t pt = pthread_self();
|
||||||
|
int retval = pthread_getthrds_np(&pt, PTHRDSINFO_QUERY_TID, &buf, sizeof(buf), NULL, ®_size);
|
||||||
|
int tid = (!retval) ? buf.__pi_tid : 0;
|
||||||
|
return static_cast<size_t>(tid);
|
||||||
|
#elif defined(__DragonFly__) || defined(__FreeBSD__)
|
||||||
|
return static_cast<size_t>(::pthread_getthreadid_np());
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
return static_cast<size_t>(::_lwp_self());
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
return static_cast<size_t>(::getthrid());
|
||||||
|
#elif defined(__sun)
|
||||||
|
return static_cast<size_t>(::thr_self());
|
||||||
|
#elif __APPLE__
|
||||||
|
uint64_t tid;
|
||||||
|
// There is no pthread_threadid_np prior to Mac OS X 10.6, and it is not supported on any PPC,
|
||||||
|
// including 10.6.8 Rosetta. __POWERPC__ is Apple-specific define encompassing ppc and ppc64.
|
||||||
|
#ifdef MAC_OS_X_VERSION_MAX_ALLOWED
|
||||||
|
{
|
||||||
|
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || defined(__POWERPC__)
|
||||||
|
tid = pthread_mach_thread_np(pthread_self());
|
||||||
|
#elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||||
|
if (&pthread_threadid_np) {
|
||||||
|
pthread_threadid_np(nullptr, &tid);
|
||||||
|
} else {
|
||||||
|
tid = pthread_mach_thread_np(pthread_self());
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
pthread_threadid_np(nullptr, &tid);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
pthread_threadid_np(nullptr, &tid);
|
||||||
|
#endif
|
||||||
|
return static_cast<size_t>(tid);
|
||||||
|
#else // Default to standard C++11 (other Unix)
|
||||||
|
return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return current thread id as size_t (from thread local storage)
|
||||||
|
SPDLOG_INLINE size_t thread_id() SPDLOG_NOEXCEPT {
|
||||||
|
#if defined(SPDLOG_NO_TLS)
|
||||||
|
return _thread_id();
|
||||||
|
#else // cache thread id in tls
|
||||||
|
static thread_local const size_t tid = _thread_id();
|
||||||
|
return tid;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is avoid msvc issue in sleep_for that happens if the clock changes.
|
||||||
|
// See https://github.com/gabime/spdlog/issues/609
|
||||||
|
SPDLOG_INLINE void sleep_for_millis(unsigned int milliseconds) SPDLOG_NOEXCEPT {
|
||||||
|
#if defined(_WIN32)
|
||||||
|
::Sleep(milliseconds);
|
||||||
|
#else
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
|
||||||
|
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
||||||
|
SPDLOG_INLINE std::string filename_to_str(const filename_t &filename) {
|
||||||
|
memory_buf_t buf;
|
||||||
|
wstr_to_utf8buf(filename, buf);
|
||||||
|
return SPDLOG_BUF_TO_STRING(buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
SPDLOG_INLINE std::string filename_to_str(const filename_t &filename) { return filename; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SPDLOG_INLINE int pid() SPDLOG_NOEXCEPT {
|
||||||
|
#ifdef _WIN32
|
||||||
|
return conditional_static_cast<int>(::GetCurrentProcessId());
|
||||||
|
#else
|
||||||
|
return conditional_static_cast<int>(::getpid());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine if the terminal supports colors
|
||||||
|
// Based on: https://github.com/agauniyal/rang/
|
||||||
|
SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT {
|
||||||
|
#ifdef _WIN32
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
|
||||||
|
static const bool result = []() {
|
||||||
|
const char *env_colorterm_p = std::getenv("COLORTERM");
|
||||||
|
if (env_colorterm_p != nullptr) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr std::array<const char *, 16> terms = {
|
||||||
|
{"ansi", "color", "console", "cygwin", "gnome", "konsole", "kterm", "linux", "msys",
|
||||||
|
"putty", "rxvt", "screen", "vt100", "xterm", "alacritty", "vt102"}};
|
||||||
|
|
||||||
|
const char *env_term_p = std::getenv("TERM");
|
||||||
|
if (env_term_p == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::any_of(terms.begin(), terms.end(), [&](const char *term) {
|
||||||
|
return std::strstr(env_term_p, term) != nullptr;
|
||||||
|
});
|
||||||
|
}();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine if the terminal attached
|
||||||
|
// Source: https://github.com/agauniyal/rang/
|
||||||
|
SPDLOG_INLINE bool in_terminal(FILE *file) SPDLOG_NOEXCEPT {
|
||||||
|
#ifdef _WIN32
|
||||||
|
return ::_isatty(_fileno(file)) != 0;
|
||||||
|
#else
|
||||||
|
return ::isatty(fileno(file)) != 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
|
||||||
|
SPDLOG_INLINE void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target) {
|
||||||
|
if (wstr.size() > static_cast<size_t>((std::numeric_limits<int>::max)()) / 4 - 1) {
|
||||||
|
throw_spdlog_ex("UTF-16 string is too big to be converted to UTF-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
int wstr_size = static_cast<int>(wstr.size());
|
||||||
|
if (wstr_size == 0) {
|
||||||
|
target.resize(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int result_size = static_cast<int>(target.capacity());
|
||||||
|
if ((wstr_size + 1) * 4 > result_size) {
|
||||||
|
result_size =
|
||||||
|
::WideCharToMultiByte(CP_UTF8, 0, wstr.data(), wstr_size, NULL, 0, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result_size > 0) {
|
||||||
|
target.resize(result_size);
|
||||||
|
result_size = ::WideCharToMultiByte(CP_UTF8, 0, wstr.data(), wstr_size, target.data(),
|
||||||
|
result_size, NULL, NULL);
|
||||||
|
|
||||||
|
if (result_size > 0) {
|
||||||
|
target.resize(result_size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw_spdlog_ex(
|
||||||
|
fmt_lib::format("WideCharToMultiByte failed. Last error: {}", ::GetLastError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target) {
|
||||||
|
if (str.size() > static_cast<size_t>((std::numeric_limits<int>::max)()) - 1) {
|
||||||
|
throw_spdlog_ex("UTF-8 string is too big to be converted to UTF-16");
|
||||||
|
}
|
||||||
|
|
||||||
|
int str_size = static_cast<int>(str.size());
|
||||||
|
if (str_size == 0) {
|
||||||
|
target.resize(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find the size to allocate for the result buffer
|
||||||
|
int result_size =
|
||||||
|
::MultiByteToWideChar(CP_UTF8, 0, str.data(), str_size, NULL, 0);
|
||||||
|
|
||||||
|
if (result_size > 0) {
|
||||||
|
target.resize(result_size);
|
||||||
|
result_size = ::MultiByteToWideChar(CP_UTF8, 0, str.data(), str_size, target.data(),
|
||||||
|
result_size);
|
||||||
|
if (result_size > 0) {
|
||||||
|
assert(result_size == target.size());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw_spdlog_ex(
|
||||||
|
fmt_lib::format("MultiByteToWideChar failed. Last error: {}", ::GetLastError()));
|
||||||
|
}
|
||||||
|
#endif // (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) &&
|
||||||
|
// defined(_WIN32)
|
||||||
|
|
||||||
|
// return true on success
|
||||||
|
static SPDLOG_INLINE bool mkdir_(const filename_t &path) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifdef SPDLOG_WCHAR_FILENAMES
|
||||||
|
return ::_wmkdir(path.c_str()) == 0;
|
||||||
|
#else
|
||||||
|
return ::_mkdir(path.c_str()) == 0;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
return ::mkdir(path.c_str(), mode_t(0755)) == 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the given directory - and all directories leading to it
|
||||||
|
// return true on success or if the directory already exists
|
||||||
|
SPDLOG_INLINE bool create_dir(const filename_t &path) {
|
||||||
|
if (path_exists(path)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t search_offset = 0;
|
||||||
|
do {
|
||||||
|
auto token_pos = path.find_first_of(folder_seps_filename, search_offset);
|
||||||
|
// treat the entire path as a folder if no folder separator not found
|
||||||
|
if (token_pos == filename_t::npos) {
|
||||||
|
token_pos = path.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto subdir = path.substr(0, token_pos);
|
||||||
|
#ifdef _WIN32
|
||||||
|
// if subdir is just a drive letter, add a slash e.g. "c:"=>"c:\",
|
||||||
|
// otherwise path_exists(subdir) returns false (issue #3079)
|
||||||
|
const bool is_drive = subdir.length() == 2 && subdir[1] == ':';
|
||||||
|
if (is_drive) {
|
||||||
|
subdir += '\\';
|
||||||
|
token_pos++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!subdir.empty() && !path_exists(subdir) && !mkdir_(subdir)) {
|
||||||
|
return false; // return error if failed creating dir
|
||||||
|
}
|
||||||
|
search_offset = token_pos + 1;
|
||||||
|
} while (search_offset < path.size());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return directory name from given path or empty string
|
||||||
|
// "abc/file" => "abc"
|
||||||
|
// "abc/" => "abc"
|
||||||
|
// "abc" => ""
|
||||||
|
// "abc///" => "abc//"
|
||||||
|
SPDLOG_INLINE filename_t dir_name(const filename_t &path) {
|
||||||
|
auto pos = path.find_last_of(folder_seps_filename);
|
||||||
|
return pos != filename_t::npos ? path.substr(0, pos) : filename_t{};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SPDLOG_INLINE getenv(const char *field) {
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#if defined(__cplusplus_winrt)
|
||||||
|
return std::string{}; // not supported under uwp
|
||||||
|
#else
|
||||||
|
size_t len = 0;
|
||||||
|
char buf[128];
|
||||||
|
bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0;
|
||||||
|
return ok ? buf : std::string{};
|
||||||
|
#endif
|
||||||
|
#else // revert to getenv
|
||||||
|
char *buf = ::getenv(field);
|
||||||
|
return buf ? buf : std::string{};
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do fsync by FILE handlerpointer
|
||||||
|
// Return true on success
|
||||||
|
SPDLOG_INLINE bool fsync(FILE *fp) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
return FlushFileBuffers(reinterpret_cast<HANDLE>(_get_osfhandle(_fileno(fp)))) != 0;
|
||||||
|
#else
|
||||||
|
return ::fsync(fileno(fp)) == 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do non-locking fwrite if possible by the os or use the regular locking fwrite
|
||||||
|
// Return true on success.
|
||||||
|
SPDLOG_INLINE bool fwrite_bytes(const void *ptr, const size_t n_bytes, FILE *fp) {
|
||||||
|
#if defined(_WIN32) && defined(SPDLOG_FWRITE_UNLOCKED)
|
||||||
|
return _fwrite_nolock(ptr, 1, n_bytes, fp) == n_bytes;
|
||||||
|
#elif defined(SPDLOG_FWRITE_UNLOCKED)
|
||||||
|
return ::fwrite_unlocked(ptr, 1, n_bytes, fp) == n_bytes;
|
||||||
|
#else
|
||||||
|
return std::fwrite(ptr, 1, n_bytes, fp) == n_bytes;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace os
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
@ -1,479 +1,127 @@
|
|||||||
//
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
//
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../common.h"
|
#include <ctime> // std::time_t
|
||||||
|
#include <spdlog/common.h>
|
||||||
|
|
||||||
#include <cstdio>
|
namespace spdlog {
|
||||||
#include <ctime>
|
namespace details {
|
||||||
#include <functional>
|
namespace os {
|
||||||
#include <string>
|
|
||||||
#include <chrono>
|
|
||||||
#include <thread>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstring>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
SPDLOG_API spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT;
|
||||||
|
|
||||||
#ifndef NOMINMAX
|
SPDLOG_API std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT;
|
||||||
#define NOMINMAX //prevent windows redefining min/max
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
SPDLOG_API std::tm localtime() SPDLOG_NOEXCEPT;
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#include <process.h> // _get_pid support
|
|
||||||
#include <io.h> // _get_osfhandle and _isatty support
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
SPDLOG_API std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT;
|
||||||
#include <share.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else // unix
|
SPDLOG_API std::tm gmtime() SPDLOG_NOEXCEPT;
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
#include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
|
|
||||||
|
|
||||||
#elif __FreeBSD__
|
|
||||||
#include <sys/thr.h> //Use thr_self() syscall under FreeBSD to get thread id
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif //unix
|
|
||||||
|
|
||||||
#ifndef __has_feature // Clang - feature checking macros.
|
|
||||||
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace spdlog
|
|
||||||
{
|
|
||||||
namespace details
|
|
||||||
{
|
|
||||||
namespace os
|
|
||||||
{
|
|
||||||
|
|
||||||
inline spdlog::log_clock::time_point now()
|
|
||||||
{
|
|
||||||
|
|
||||||
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
|
|
||||||
timespec ts;
|
|
||||||
::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
|
|
||||||
return std::chrono::time_point<log_clock, typename log_clock::duration>(
|
|
||||||
std::chrono::duration_cast<typename log_clock::duration>(
|
|
||||||
std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec)));
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
return log_clock::now();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
inline std::tm localtime(const std::time_t &time_tt)
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
std::tm tm;
|
|
||||||
localtime_s(&tm, &time_tt);
|
|
||||||
#else
|
|
||||||
std::tm tm;
|
|
||||||
localtime_r(&time_tt, &tm);
|
|
||||||
#endif
|
|
||||||
return tm;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::tm localtime()
|
|
||||||
{
|
|
||||||
std::time_t now_t = time(nullptr);
|
|
||||||
return localtime(now_t);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline std::tm gmtime(const std::time_t &time_tt)
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
std::tm tm;
|
|
||||||
gmtime_s(&tm, &time_tt);
|
|
||||||
#else
|
|
||||||
std::tm tm;
|
|
||||||
gmtime_r(&time_tt, &tm);
|
|
||||||
#endif
|
|
||||||
return tm;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::tm gmtime()
|
|
||||||
{
|
|
||||||
std::time_t now_t = time(nullptr);
|
|
||||||
return gmtime(now_t);
|
|
||||||
}
|
|
||||||
inline bool operator==(const std::tm& tm1, const std::tm& tm2)
|
|
||||||
{
|
|
||||||
return (tm1.tm_sec == tm2.tm_sec &&
|
|
||||||
tm1.tm_min == tm2.tm_min &&
|
|
||||||
tm1.tm_hour == tm2.tm_hour &&
|
|
||||||
tm1.tm_mday == tm2.tm_mday &&
|
|
||||||
tm1.tm_mon == tm2.tm_mon &&
|
|
||||||
tm1.tm_year == tm2.tm_year &&
|
|
||||||
tm1.tm_isdst == tm2.tm_isdst);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool operator!=(const std::tm& tm1, const std::tm& tm2)
|
|
||||||
{
|
|
||||||
return !(tm1 == tm2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// eol definition
|
// eol definition
|
||||||
#if !defined (SPDLOG_EOL)
|
#if !defined(SPDLOG_EOL)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define SPDLOG_EOL "\r\n"
|
#define SPDLOG_EOL "\r\n"
|
||||||
#else
|
#else
|
||||||
#define SPDLOG_EOL "\n"
|
#define SPDLOG_EOL "\n"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SPDLOG_CONSTEXPR static const char* eol = SPDLOG_EOL;
|
SPDLOG_CONSTEXPR static const char *default_eol = SPDLOG_EOL;
|
||||||
SPDLOG_CONSTEXPR static int eol_size = sizeof(SPDLOG_EOL) - 1;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// folder separator
|
// folder separator
|
||||||
#ifdef _WIN32
|
#if !defined(SPDLOG_FOLDER_SEPS)
|
||||||
SPDLOG_CONSTEXPR static const char folder_sep = '\\';
|
#ifdef _WIN32
|
||||||
#else
|
#define SPDLOG_FOLDER_SEPS "\\/"
|
||||||
SPDLOG_CONSTEXPR static const char folder_sep = '/';
|
#else
|
||||||
|
#define SPDLOG_FOLDER_SEPS "/"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SPDLOG_CONSTEXPR static const char folder_seps[] = SPDLOG_FOLDER_SEPS;
|
||||||
|
SPDLOG_CONSTEXPR static const filename_t::value_type folder_seps_filename[] =
|
||||||
|
SPDLOG_FILENAME_T(SPDLOG_FOLDER_SEPS);
|
||||||
|
|
||||||
inline void prevent_child_fd(FILE *f)
|
// fopen_s on non windows for writing
|
||||||
{
|
SPDLOG_API bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mode);
|
||||||
#ifdef _WIN32
|
|
||||||
auto file_handle = (HANDLE)_get_osfhandle(_fileno(f));
|
|
||||||
if (!::SetHandleInformation(file_handle, HANDLE_FLAG_INHERIT, 0))
|
|
||||||
throw spdlog_ex("SetHandleInformation failed", errno);
|
|
||||||
#else
|
|
||||||
auto fd = fileno(f);
|
|
||||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
|
||||||
throw spdlog_ex("fcntl with FD_CLOEXEC failed", errno);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Remove filename. return 0 on success
|
||||||
|
SPDLOG_API int remove(const filename_t &filename) SPDLOG_NOEXCEPT;
|
||||||
|
|
||||||
//fopen_s on non windows for writing
|
// Remove file if exists. return 0 on success
|
||||||
inline int fopen_s(FILE** fp, const filename_t& filename, const filename_t& mode)
|
// Note: Non atomic (might return failure to delete if concurrently deleted by other process/thread)
|
||||||
{
|
SPDLOG_API int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
|
||||||
#ifdef _WIN32
|
|
||||||
#ifdef SPDLOG_WCHAR_FILENAMES
|
|
||||||
*fp = _wfsopen((filename.c_str()), mode.c_str(), _SH_DENYWR);
|
|
||||||
#else
|
|
||||||
*fp = _fsopen((filename.c_str()), mode.c_str(), _SH_DENYWR);
|
|
||||||
#endif
|
|
||||||
#else //unix
|
|
||||||
*fp = fopen((filename.c_str()), mode.c_str());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SPDLOG_PREVENT_CHILD_FD
|
SPDLOG_API int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT;
|
||||||
if (*fp != nullptr)
|
|
||||||
prevent_child_fd(*fp);
|
|
||||||
#endif
|
|
||||||
return *fp == nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Return if file exists.
|
||||||
|
SPDLOG_API bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
|
||||||
|
|
||||||
inline int remove(const filename_t &filename)
|
// Return file size according to open FILE* object
|
||||||
{
|
SPDLOG_API size_t filesize(FILE *f);
|
||||||
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
|
||||||
return _wremove(filename.c_str());
|
|
||||||
#else
|
|
||||||
return std::remove(filename.c_str());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int rename(const filename_t& filename1, const filename_t& filename2)
|
// Return utc offset in minutes or throw spdlog_ex on failure
|
||||||
{
|
SPDLOG_API int utc_minutes_offset(const std::tm &tm = details::os::localtime());
|
||||||
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
|
||||||
return _wrename(filename1.c_str(), filename2.c_str());
|
|
||||||
#else
|
|
||||||
return std::rename(filename1.c_str(), filename2.c_str());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Return current thread id as size_t
|
||||||
|
// It exists because the std::this_thread::get_id() is much slower(especially
|
||||||
|
// under VS 2013)
|
||||||
|
SPDLOG_API size_t _thread_id() SPDLOG_NOEXCEPT;
|
||||||
|
|
||||||
//Return if file exists
|
// Return current thread id as size_t (from thread local storage)
|
||||||
inline bool file_exists(const filename_t& filename)
|
SPDLOG_API size_t thread_id() SPDLOG_NOEXCEPT;
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
#ifdef SPDLOG_WCHAR_FILENAMES
|
|
||||||
auto attribs = GetFileAttributesW(filename.c_str());
|
|
||||||
#else
|
|
||||||
auto attribs = GetFileAttributesA(filename.c_str());
|
|
||||||
#endif
|
|
||||||
return (attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY));
|
|
||||||
#else //common linux/unix all have the stat system call
|
|
||||||
struct stat buffer;
|
|
||||||
return (stat(filename.c_str(), &buffer) == 0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// This is avoid msvc issue in sleep_for that happens if the clock changes.
|
||||||
|
// See https://github.com/gabime/spdlog/issues/609
|
||||||
|
SPDLOG_API void sleep_for_millis(unsigned int milliseconds) SPDLOG_NOEXCEPT;
|
||||||
|
|
||||||
|
SPDLOG_API std::string filename_to_str(const filename_t &filename);
|
||||||
|
|
||||||
|
SPDLOG_API int pid() SPDLOG_NOEXCEPT;
|
||||||
//Return file size according to open FILE* object
|
|
||||||
inline size_t filesize(FILE *f)
|
|
||||||
{
|
|
||||||
if (f == nullptr)
|
|
||||||
throw spdlog_ex("Failed getting file size. fd is null");
|
|
||||||
#if defined ( _WIN32) && !defined(__CYGWIN__)
|
|
||||||
int fd = _fileno(f);
|
|
||||||
#if _WIN64 //64 bits
|
|
||||||
struct _stat64 st;
|
|
||||||
if (_fstat64(fd, &st) == 0)
|
|
||||||
return st.st_size;
|
|
||||||
|
|
||||||
#else //windows 32 bits
|
|
||||||
long ret = _filelength(fd);
|
|
||||||
if (ret >= 0)
|
|
||||||
return static_cast<size_t>(ret);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else // unix
|
|
||||||
int fd = fileno(f);
|
|
||||||
//64 bits(but not in osx or cygwin, where fstat64 is deprecated)
|
|
||||||
#if !defined(__FreeBSD__) && !defined(__APPLE__) && (defined(__x86_64__) || defined(__ppc64__)) && !defined(__CYGWIN__)
|
|
||||||
struct stat64 st;
|
|
||||||
if (fstat64(fd, &st) == 0)
|
|
||||||
return static_cast<size_t>(st.st_size);
|
|
||||||
#else // unix 32 bits or cygwin
|
|
||||||
struct stat st;
|
|
||||||
if (fstat(fd, &st) == 0)
|
|
||||||
return static_cast<size_t>(st.st_size);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
throw spdlog_ex("Failed getting file size from fd", errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Return utc offset in minutes or throw spdlog_ex on failure
|
|
||||||
inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#if _WIN32_WINNT < _WIN32_WINNT_WS08
|
|
||||||
TIME_ZONE_INFORMATION tzinfo;
|
|
||||||
auto rv = GetTimeZoneInformation(&tzinfo);
|
|
||||||
#else
|
|
||||||
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
|
|
||||||
auto rv = GetDynamicTimeZoneInformation(&tzinfo);
|
|
||||||
#endif
|
|
||||||
if (rv == TIME_ZONE_ID_INVALID)
|
|
||||||
throw spdlog::spdlog_ex("Failed getting timezone info. ", errno);
|
|
||||||
|
|
||||||
int offset = -tzinfo.Bias;
|
|
||||||
if (tm.tm_isdst)
|
|
||||||
offset -= tzinfo.DaylightBias;
|
|
||||||
else
|
|
||||||
offset -= tzinfo.StandardBias;
|
|
||||||
return offset;
|
|
||||||
#else
|
|
||||||
|
|
||||||
#if defined(sun) || defined(__sun)
|
|
||||||
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
|
|
||||||
struct helper
|
|
||||||
{
|
|
||||||
static long int calculate_gmt_offset(const std::tm & localtm = details::os::localtime(), const std::tm & gmtm = details::os::gmtime())
|
|
||||||
{
|
|
||||||
int local_year = localtm.tm_year + (1900 - 1);
|
|
||||||
int gmt_year = gmtm.tm_year + (1900 - 1);
|
|
||||||
|
|
||||||
long int days = (
|
|
||||||
// difference in day of year
|
|
||||||
localtm.tm_yday - gmtm.tm_yday
|
|
||||||
|
|
||||||
// + intervening leap days
|
|
||||||
+ ((local_year >> 2) - (gmt_year >> 2))
|
|
||||||
- (local_year / 100 - gmt_year / 100)
|
|
||||||
+ ((local_year / 100 >> 2) - (gmt_year / 100 >> 2))
|
|
||||||
|
|
||||||
// + difference in years * 365 */
|
|
||||||
+ (long int)(local_year - gmt_year) * 365
|
|
||||||
);
|
|
||||||
|
|
||||||
long int hours = (24 * days) + (localtm.tm_hour - gmtm.tm_hour);
|
|
||||||
long int mins = (60 * hours) + (localtm.tm_min - gmtm.tm_min);
|
|
||||||
long int secs = (60 * mins) + (localtm.tm_sec - gmtm.tm_sec);
|
|
||||||
|
|
||||||
return secs;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
long int offset_seconds = helper::calculate_gmt_offset(tm);
|
|
||||||
#else
|
|
||||||
long int offset_seconds = tm.tm_gmtoff;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return static_cast<int>(offset_seconds / 60);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//Return current thread id as size_t
|
|
||||||
//It exists because the std::this_thread::get_id() is much slower(especially under VS 2013)
|
|
||||||
inline size_t _thread_id()
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
return static_cast<size_t>(::GetCurrentThreadId());
|
|
||||||
#elif __linux__
|
|
||||||
# if defined(__ANDROID__) && defined(__ANDROID_API__) && (__ANDROID_API__ < 21)
|
|
||||||
# define SYS_gettid __NR_gettid
|
|
||||||
# endif
|
|
||||||
return static_cast<size_t>(syscall(SYS_gettid));
|
|
||||||
#elif __FreeBSD__
|
|
||||||
long tid;
|
|
||||||
thr_self(&tid);
|
|
||||||
return static_cast<size_t>(tid);
|
|
||||||
#elif __APPLE__
|
|
||||||
uint64_t tid;
|
|
||||||
pthread_threadid_np(nullptr, &tid);
|
|
||||||
return static_cast<size_t>(tid);
|
|
||||||
#else //Default to standard C++11 (other Unix)
|
|
||||||
return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//Return current thread id as size_t (from thread local storage)
|
|
||||||
inline size_t thread_id()
|
|
||||||
{
|
|
||||||
#if defined(SPDLOG_DISABLE_TID_CACHING) || (defined(_MSC_VER) && (_MSC_VER < 1900)) || (defined(__clang__) && !__has_feature(cxx_thread_local))
|
|
||||||
return _thread_id();
|
|
||||||
#else // cache thread id in tls
|
|
||||||
static thread_local const size_t tid = _thread_id();
|
|
||||||
return tid;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
|
|
||||||
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
|
||||||
#define SPDLOG_FILENAME_T(s) L ## s
|
|
||||||
inline std::string filename_to_str(const filename_t& filename)
|
|
||||||
{
|
|
||||||
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> c;
|
|
||||||
return c.to_bytes(filename);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define SPDLOG_FILENAME_T(s) s
|
|
||||||
inline std::string filename_to_str(const filename_t& filename)
|
|
||||||
{
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline std::string errno_to_string(char[256], char* res)
|
|
||||||
{
|
|
||||||
return std::string(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string errno_to_string(char buf[256], int res)
|
|
||||||
{
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return std::string(buf);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "Unknown error";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return errno string (thread safe)
|
|
||||||
inline std::string errno_str(int err_num)
|
|
||||||
{
|
|
||||||
char buf[256];
|
|
||||||
SPDLOG_CONSTEXPR auto buf_size = sizeof(buf);
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (strerror_s(buf, buf_size, err_num) == 0)
|
|
||||||
return std::string(buf);
|
|
||||||
else
|
|
||||||
return "Unknown error";
|
|
||||||
|
|
||||||
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(ANDROID) || defined(__SUNPRO_CC) || \
|
|
||||||
((_POSIX_C_SOURCE >= 200112L) && ! defined(_GNU_SOURCE)) // posix version
|
|
||||||
|
|
||||||
if (strerror_r(err_num, buf, buf_size) == 0)
|
|
||||||
return std::string(buf);
|
|
||||||
else
|
|
||||||
return "Unknown error";
|
|
||||||
|
|
||||||
#else // gnu version (might not use the given buf, so its retval pointer must be used)
|
|
||||||
auto err = strerror_r(err_num, buf, buf_size); // let compiler choose type
|
|
||||||
return errno_to_string(buf, err); // use overloading to select correct stringify function
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int pid()
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
return ::_getpid();
|
|
||||||
#else
|
|
||||||
return static_cast<int>(::getpid());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Determine if the terminal supports colors
|
// Determine if the terminal supports colors
|
||||||
// Source: https://github.com/agauniyal/rang/
|
// Source: https://github.com/agauniyal/rang/
|
||||||
inline bool is_color_terminal()
|
SPDLOG_API bool is_color_terminal() SPDLOG_NOEXCEPT;
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
static constexpr const char* Terms[] =
|
|
||||||
{
|
|
||||||
"ansi", "color", "console", "cygwin", "gnome", "konsole", "kterm",
|
|
||||||
"linux", "msys", "putty", "rxvt", "screen", "vt100", "xterm"
|
|
||||||
};
|
|
||||||
|
|
||||||
const char *env_p = std::getenv("TERM");
|
// Determine if the terminal attached
|
||||||
if (env_p == nullptr)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const bool result = std::any_of(
|
|
||||||
std::begin(Terms), std::end(Terms), [&](const char* term)
|
|
||||||
{
|
|
||||||
return std::strstr(env_p, term) != nullptr;
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Detrmine if the terminal attached
|
|
||||||
// Source: https://github.com/agauniyal/rang/
|
// Source: https://github.com/agauniyal/rang/
|
||||||
inline bool in_terminal(FILE* file)
|
SPDLOG_API bool in_terminal(FILE *file) SPDLOG_NOEXCEPT;
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
|
||||||
return _isatty(_fileno(file)) ? true : false;
|
SPDLOG_API void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target);
|
||||||
#else
|
|
||||||
return isatty(fileno(file)) ? true : false;
|
SPDLOG_API void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Return directory name from given path or empty string
|
||||||
|
// "abc/file" => "abc"
|
||||||
|
// "abc/" => "abc"
|
||||||
|
// "abc" => ""
|
||||||
|
// "abc///" => "abc//"
|
||||||
|
SPDLOG_API filename_t dir_name(const filename_t &path);
|
||||||
|
|
||||||
|
// Create a dir from the given path.
|
||||||
|
// Return true if succeeded or if this dir already exists.
|
||||||
|
SPDLOG_API bool create_dir(const filename_t &path);
|
||||||
|
|
||||||
|
// non thread safe, cross platform getenv/getenv_s
|
||||||
|
// return empty string if field not found
|
||||||
|
SPDLOG_API std::string getenv(const char *field);
|
||||||
|
|
||||||
|
// Do fsync by FILE objectpointer.
|
||||||
|
// Return true on success.
|
||||||
|
SPDLOG_API bool fsync(FILE *fp);
|
||||||
|
|
||||||
|
// Do non-locking fwrite if possible by the os or use the regular locking fwrite
|
||||||
|
// Return true on success.
|
||||||
|
SPDLOG_API bool fwrite_bytes(const void *ptr, const size_t n_bytes, FILE *fp);
|
||||||
|
|
||||||
|
} // namespace os
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
||||||
|
|
||||||
|
#ifdef SPDLOG_HEADER_ONLY
|
||||||
|
#include "os-inl.h"
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
} //os
|
|
||||||
} //details
|
|
||||||
} //spdlog
|
|
||||||
|
@ -1,686 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../formatter.h"
|
|
||||||
#include "../details/log_msg.h"
|
|
||||||
#include "../details/os.h"
|
|
||||||
#include "../fmt/fmt.h"
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <ctime>
|
|
||||||
#include <memory>
|
|
||||||
#include <mutex>
|
|
||||||
#include <string>
|
|
||||||
#include <thread>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
namespace spdlog
|
|
||||||
{
|
|
||||||
namespace details
|
|
||||||
{
|
|
||||||
class flag_formatter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~flag_formatter()
|
|
||||||
{}
|
|
||||||
virtual void format(details::log_msg& msg, const std::tm& tm_time) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// name & level pattern appenders
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
class name_formatter:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
msg.formatted << *msg.logger_name;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// log level appender
|
|
||||||
class level_formatter:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
msg.formatted << level::to_str(msg.level);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// short log level appender
|
|
||||||
class short_level_formatter:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
msg.formatted << level::to_short_str(msg.level);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// Date time pattern appenders
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static const char* ampm(const tm& t)
|
|
||||||
{
|
|
||||||
return t.tm_hour >= 12 ? "PM" : "AM";
|
|
||||||
}
|
|
||||||
|
|
||||||
static int to12h(const tm& t)
|
|
||||||
{
|
|
||||||
return t.tm_hour > 12 ? t.tm_hour - 12 : t.tm_hour;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Abbreviated weekday name
|
|
||||||
static const std::string days[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
|
||||||
class a_formatter:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << days[tm_time.tm_wday];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//Full weekday name
|
|
||||||
static const std::string full_days[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
|
|
||||||
class A_formatter:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << full_days[tm_time.tm_wday];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//Abbreviated month
|
|
||||||
static const std::string months[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };
|
|
||||||
class b_formatter:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << months[tm_time.tm_mon];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//Full month name
|
|
||||||
static const std::string full_months[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
|
|
||||||
class B_formatter:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << full_months[tm_time.tm_mon];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//write 2 ints separated by sep with padding of 2
|
|
||||||
static fmt::MemoryWriter& pad_n_join(fmt::MemoryWriter& w, int v1, int v2, char sep)
|
|
||||||
{
|
|
||||||
w << fmt::pad(v1, 2, '0') << sep << fmt::pad(v2, 2, '0');
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
//write 3 ints separated by sep with padding of 2
|
|
||||||
static fmt::MemoryWriter& pad_n_join(fmt::MemoryWriter& w, int v1, int v2, int v3, char sep)
|
|
||||||
{
|
|
||||||
w << fmt::pad(v1, 2, '0') << sep << fmt::pad(v2, 2, '0') << sep << fmt::pad(v3, 2, '0');
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Date and time representation (Thu Aug 23 15:35:46 2014)
|
|
||||||
class c_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << days[tm_time.tm_wday] << ' ' << months[tm_time.tm_mon] << ' ' << tm_time.tm_mday << ' ';
|
|
||||||
pad_n_join(msg.formatted, tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec, ':') << ' ' << tm_time.tm_year + 1900;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// year - 2 digit
|
|
||||||
class C_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << fmt::pad(tm_time.tm_year % 100, 2, '0');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Short MM/DD/YY date, equivalent to %m/%d/%y 08/23/01
|
|
||||||
class D_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
pad_n_join(msg.formatted, tm_time.tm_mon + 1, tm_time.tm_mday, tm_time.tm_year % 100, '/');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// year - 4 digit
|
|
||||||
class Y_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << tm_time.tm_year + 1900;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// month 1-12
|
|
||||||
class m_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << fmt::pad(tm_time.tm_mon + 1, 2, '0');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// day of month 1-31
|
|
||||||
class d_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << fmt::pad(tm_time.tm_mday, 2, '0');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// hours in 24 format 0-23
|
|
||||||
class H_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << fmt::pad(tm_time.tm_hour, 2, '0');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// hours in 12 format 1-12
|
|
||||||
class I_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << fmt::pad(to12h(tm_time), 2, '0');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// minutes 0-59
|
|
||||||
class M_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << fmt::pad(tm_time.tm_min, 2, '0');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// seconds 0-59
|
|
||||||
class S_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << fmt::pad(tm_time.tm_sec, 2, '0');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// milliseconds
|
|
||||||
class e_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
auto duration = msg.time.time_since_epoch();
|
|
||||||
auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count() % 1000;
|
|
||||||
msg.formatted << fmt::pad(static_cast<int>(millis), 3, '0');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// microseconds
|
|
||||||
class f_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
auto duration = msg.time.time_since_epoch();
|
|
||||||
auto micros = std::chrono::duration_cast<std::chrono::microseconds>(duration).count() % 1000000;
|
|
||||||
msg.formatted << fmt::pad(static_cast<int>(micros), 6, '0');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// nanoseconds
|
|
||||||
class F_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
auto duration = msg.time.time_since_epoch();
|
|
||||||
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count() % 1000000000;
|
|
||||||
msg.formatted << fmt::pad(static_cast<int>(ns), 9, '0');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class E_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
auto duration = msg.time.time_since_epoch();
|
|
||||||
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration).count();
|
|
||||||
msg.formatted << seconds;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// AM/PM
|
|
||||||
class p_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
msg.formatted << ampm(tm_time);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 12 hour clock 02:55:02 pm
|
|
||||||
class r_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
pad_n_join(msg.formatted, to12h(tm_time), tm_time.tm_min, tm_time.tm_sec, ':') << ' ' << ampm(tm_time);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 24-hour HH:MM time, equivalent to %H:%M
|
|
||||||
class R_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
pad_n_join(msg.formatted, tm_time.tm_hour, tm_time.tm_min, ':');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S
|
|
||||||
class T_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
pad_n_join(msg.formatted, tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec, ':');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ISO 8601 offset from UTC in timezone (+-HH:MM)
|
|
||||||
class z_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
const std::chrono::seconds cache_refresh = std::chrono::seconds(5);
|
|
||||||
|
|
||||||
z_formatter():_last_update(std::chrono::seconds(0)), _offset_minutes(0)
|
|
||||||
{}
|
|
||||||
z_formatter(const z_formatter&) = delete;
|
|
||||||
z_formatter& operator=(const z_formatter&) = delete;
|
|
||||||
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
int total_minutes = get_cached_offset(msg, tm_time);
|
|
||||||
#else
|
|
||||||
// No need to chache under gcc,
|
|
||||||
// it is very fast (already stored in tm.tm_gmtoff)
|
|
||||||
int total_minutes = os::utc_minutes_offset(tm_time);
|
|
||||||
#endif
|
|
||||||
bool is_negative = total_minutes < 0;
|
|
||||||
char sign;
|
|
||||||
if (is_negative)
|
|
||||||
{
|
|
||||||
total_minutes = -total_minutes;
|
|
||||||
sign = '-';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sign = '+';
|
|
||||||
}
|
|
||||||
|
|
||||||
int h = total_minutes / 60;
|
|
||||||
int m = total_minutes % 60;
|
|
||||||
msg.formatted << sign;
|
|
||||||
pad_n_join(msg.formatted, h, m, ':');
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
log_clock::time_point _last_update;
|
|
||||||
int _offset_minutes;
|
|
||||||
std::mutex _mutex;
|
|
||||||
|
|
||||||
int get_cached_offset(const log_msg& msg, const std::tm& tm_time)
|
|
||||||
{
|
|
||||||
using namespace std::chrono;
|
|
||||||
std::lock_guard<std::mutex> l(_mutex);
|
|
||||||
if (msg.time - _last_update >= cache_refresh)
|
|
||||||
{
|
|
||||||
_offset_minutes = os::utc_minutes_offset(tm_time);
|
|
||||||
_last_update = msg.time;
|
|
||||||
}
|
|
||||||
return _offset_minutes;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Thread id
|
|
||||||
class t_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
msg.formatted << msg.thread_id;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Current pid
|
|
||||||
class pid_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
msg.formatted << details::os::pid();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// message counter formatter
|
|
||||||
class i_formatter SPDLOG_FINAL :public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
msg.formatted << fmt::pad(msg.msg_id, 6, '0');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class v_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
msg.formatted << fmt::StringRef(msg.raw.data(), msg.raw.size());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class ch_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ch_formatter(char ch): _ch(ch)
|
|
||||||
{}
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
msg.formatted << _ch;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
char _ch;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//aggregate user chars to display as is
|
|
||||||
class aggregate_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
aggregate_formatter()
|
|
||||||
{}
|
|
||||||
void add_ch(char ch)
|
|
||||||
{
|
|
||||||
_str += ch;
|
|
||||||
}
|
|
||||||
void format(details::log_msg& msg, const std::tm&) override
|
|
||||||
{
|
|
||||||
msg.formatted << _str;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
std::string _str;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Full info formatter
|
|
||||||
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] %v
|
|
||||||
class full_formatter SPDLOG_FINAL:public flag_formatter
|
|
||||||
{
|
|
||||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
||||||
{
|
|
||||||
#ifndef SPDLOG_NO_DATETIME
|
|
||||||
auto duration = msg.time.time_since_epoch();
|
|
||||||
auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count() % 1000;
|
|
||||||
|
|
||||||
/* Slower version(while still very fast - about 3.2 million lines/sec under 10 threads),
|
|
||||||
msg.formatted.write("[{:d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.{:03d}] [{}] [{}] {} ",
|
|
||||||
tm_time.tm_year + 1900,
|
|
||||||
tm_time.tm_mon + 1,
|
|
||||||
tm_time.tm_mday,
|
|
||||||
tm_time.tm_hour,
|
|
||||||
tm_time.tm_min,
|
|
||||||
tm_time.tm_sec,
|
|
||||||
static_cast<int>(millis),
|
|
||||||
msg.logger_name,
|
|
||||||
level::to_str(msg.level),
|
|
||||||
msg.raw.str());*/
|
|
||||||
|
|
||||||
|
|
||||||
// Faster (albeit uglier) way to format the line (5.6 million lines/sec under 10 threads)
|
|
||||||
msg.formatted << '[' << static_cast<unsigned int>(tm_time.tm_year + 1900) << '-'
|
|
||||||
<< fmt::pad(static_cast<unsigned int>(tm_time.tm_mon + 1), 2, '0') << '-'
|
|
||||||
<< fmt::pad(static_cast<unsigned int>(tm_time.tm_mday), 2, '0') << ' '
|
|
||||||
<< fmt::pad(static_cast<unsigned int>(tm_time.tm_hour), 2, '0') << ':'
|
|
||||||
<< fmt::pad(static_cast<unsigned int>(tm_time.tm_min), 2, '0') << ':'
|
|
||||||
<< fmt::pad(static_cast<unsigned int>(tm_time.tm_sec), 2, '0') << '.'
|
|
||||||
<< fmt::pad(static_cast<unsigned int>(millis), 3, '0') << "] ";
|
|
||||||
|
|
||||||
//no datetime needed
|
|
||||||
#else
|
|
||||||
(void)tm_time;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SPDLOG_NO_NAME
|
|
||||||
msg.formatted << '[' << *msg.logger_name << "] ";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
msg.formatted << '[' << level::to_str(msg.level) << "] ";
|
|
||||||
msg.formatted << fmt::StringRef(msg.raw.data(), msg.raw.size());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// pattern_formatter inline impl
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
inline spdlog::pattern_formatter::pattern_formatter(const std::string& pattern, pattern_time_type pattern_time)
|
|
||||||
: _pattern_time(pattern_time)
|
|
||||||
{
|
|
||||||
compile_pattern(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::pattern_formatter::compile_pattern(const std::string& pattern)
|
|
||||||
{
|
|
||||||
auto end = pattern.end();
|
|
||||||
std::unique_ptr<details::aggregate_formatter> user_chars;
|
|
||||||
for (auto it = pattern.begin(); it != end; ++it)
|
|
||||||
{
|
|
||||||
if (*it == '%')
|
|
||||||
{
|
|
||||||
if (user_chars) //append user chars found so far
|
|
||||||
_formatters.push_back(std::move(user_chars));
|
|
||||||
|
|
||||||
if (++it != end)
|
|
||||||
handle_flag(*it);
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else // chars not following the % sign should be displayed as is
|
|
||||||
{
|
|
||||||
if (!user_chars)
|
|
||||||
user_chars = std::unique_ptr<details::aggregate_formatter>(new details::aggregate_formatter());
|
|
||||||
user_chars->add_ch(*it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (user_chars) //append raw chars found so far
|
|
||||||
{
|
|
||||||
_formatters.push_back(std::move(user_chars));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
inline void spdlog::pattern_formatter::handle_flag(char flag)
|
|
||||||
{
|
|
||||||
switch (flag)
|
|
||||||
{
|
|
||||||
// logger name
|
|
||||||
case 'n':
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::name_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'l':
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::level_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'L':
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::short_level_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('t'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::t_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('v'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::v_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('a'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::a_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('A'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::A_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('b'):
|
|
||||||
case('h'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::b_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('B'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::B_formatter()));
|
|
||||||
break;
|
|
||||||
case('c'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::c_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('C'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::C_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('Y'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::Y_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('D'):
|
|
||||||
case('x'):
|
|
||||||
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::D_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('m'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::m_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('d'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::d_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('H'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::H_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('I'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::I_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('M'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::M_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('S'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::S_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('e'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::e_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('f'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::f_formatter()));
|
|
||||||
break;
|
|
||||||
case('F'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::F_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('E'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::E_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('p'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::p_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('r'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::r_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('R'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::R_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('T'):
|
|
||||||
case('X'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::T_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case('z'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::z_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ('+'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::full_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ('P'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::pid_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case ('i'):
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::i_formatter()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: //Unknown flag appears as is
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::ch_formatter('%')));
|
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::ch_formatter(flag)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::tm spdlog::pattern_formatter::get_time(details::log_msg& msg)
|
|
||||||
{
|
|
||||||
if (_pattern_time == pattern_time_type::local)
|
|
||||||
return details::os::localtime(log_clock::to_time_t(msg.time));
|
|
||||||
else
|
|
||||||
return details::os::gmtime(log_clock::to_time_t(msg.time));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::pattern_formatter::format(details::log_msg& msg)
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifndef SPDLOG_NO_DATETIME
|
|
||||||
auto tm_time = get_time(msg);
|
|
||||||
#else
|
|
||||||
std::tm tm_time;
|
|
||||||
#endif
|
|
||||||
for (auto &f : _formatters)
|
|
||||||
{
|
|
||||||
f->format(msg, tm_time);
|
|
||||||
}
|
|
||||||
//write eol
|
|
||||||
msg.formatted.write(details::os::eol, details::os::eol_size);
|
|
||||||
}
|
|
26
include/spdlog/details/periodic_worker-inl.h
Normal file
26
include/spdlog/details/periodic_worker-inl.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef SPDLOG_HEADER_ONLY
|
||||||
|
#include <spdlog/details/periodic_worker.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
// stop the worker thread and join it
|
||||||
|
SPDLOG_INLINE periodic_worker::~periodic_worker() {
|
||||||
|
if (worker_thread_.joinable()) {
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
|
active_ = false;
|
||||||
|
}
|
||||||
|
cv_.notify_one();
|
||||||
|
worker_thread_.join();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
58
include/spdlog/details/periodic_worker.h
Normal file
58
include/spdlog/details/periodic_worker.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// periodic worker thread - periodically executes the given callback function.
|
||||||
|
//
|
||||||
|
// RAII over the owned thread:
|
||||||
|
// creates the thread on construction.
|
||||||
|
// stops and joins the thread on destruction (if the thread is executing a callback, wait for it
|
||||||
|
// to finish first).
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <functional>
|
||||||
|
#include <mutex>
|
||||||
|
#include <thread>
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
class SPDLOG_API periodic_worker {
|
||||||
|
public:
|
||||||
|
template <typename Rep, typename Period>
|
||||||
|
periodic_worker(const std::function<void()> &callback_fun,
|
||||||
|
std::chrono::duration<Rep, Period> interval) {
|
||||||
|
active_ = (interval > std::chrono::duration<Rep, Period>::zero());
|
||||||
|
if (!active_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
worker_thread_ = std::thread([this, callback_fun, interval]() {
|
||||||
|
for (;;) {
|
||||||
|
std::unique_lock<std::mutex> lock(this->mutex_);
|
||||||
|
if (this->cv_.wait_for(lock, interval, [this] { return !this->active_; })) {
|
||||||
|
return; // active_ == false, so exit this thread
|
||||||
|
}
|
||||||
|
callback_fun();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
std::thread &get_thread() { return worker_thread_; }
|
||||||
|
periodic_worker(const periodic_worker &) = delete;
|
||||||
|
periodic_worker &operator=(const periodic_worker &) = delete;
|
||||||
|
// stop the worker thread and join it
|
||||||
|
~periodic_worker();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool active_;
|
||||||
|
std::thread worker_thread_;
|
||||||
|
std::mutex mutex_;
|
||||||
|
std::condition_variable cv_;
|
||||||
|
};
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
||||||
|
|
||||||
|
#ifdef SPDLOG_HEADER_ONLY
|
||||||
|
#include "periodic_worker-inl.h"
|
||||||
|
#endif
|
261
include/spdlog/details/registry-inl.h
Normal file
261
include/spdlog/details/registry-inl.h
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef SPDLOG_HEADER_ONLY
|
||||||
|
#include <spdlog/details/registry.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <spdlog/common.h>
|
||||||
|
#include <spdlog/details/periodic_worker.h>
|
||||||
|
#include <spdlog/logger.h>
|
||||||
|
#include <spdlog/pattern_formatter.h>
|
||||||
|
|
||||||
|
#ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
|
||||||
|
// support for the default stdout color logger
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <spdlog/sinks/wincolor_sink.h>
|
||||||
|
#else
|
||||||
|
#include <spdlog/sinks/ansicolor_sink.h>
|
||||||
|
#endif
|
||||||
|
#endif // SPDLOG_DISABLE_DEFAULT_LOGGER
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
SPDLOG_INLINE registry::registry()
|
||||||
|
: formatter_(new pattern_formatter()) {
|
||||||
|
#ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
|
||||||
|
// create default logger (ansicolor_stdout_sink_mt or wincolor_stdout_sink_mt in windows).
|
||||||
|
#ifdef _WIN32
|
||||||
|
auto color_sink = std::make_shared<sinks::wincolor_stdout_sink_mt>();
|
||||||
|
#else
|
||||||
|
auto color_sink = std::make_shared<sinks::ansicolor_stdout_sink_mt>();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *default_logger_name = "";
|
||||||
|
default_logger_ = std::make_shared<spdlog::logger>(default_logger_name, std::move(color_sink));
|
||||||
|
loggers_[default_logger_name] = default_logger_;
|
||||||
|
|
||||||
|
#endif // SPDLOG_DISABLE_DEFAULT_LOGGER
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE registry::~registry() = default;
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::register_logger(std::shared_ptr<logger> new_logger) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
register_logger_(std::move(new_logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::initialize_logger(std::shared_ptr<logger> new_logger) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
new_logger->set_formatter(formatter_->clone());
|
||||||
|
|
||||||
|
if (err_handler_) {
|
||||||
|
new_logger->set_error_handler(err_handler_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set new level according to previously configured level or default level
|
||||||
|
auto it = log_levels_.find(new_logger->name());
|
||||||
|
auto new_level = it != log_levels_.end() ? it->second : global_log_level_;
|
||||||
|
new_logger->set_level(new_level);
|
||||||
|
|
||||||
|
new_logger->flush_on(flush_level_);
|
||||||
|
|
||||||
|
if (backtrace_n_messages_ > 0) {
|
||||||
|
new_logger->enable_backtrace(backtrace_n_messages_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (automatic_registration_) {
|
||||||
|
register_logger_(std::move(new_logger));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE std::shared_ptr<logger> registry::get(const std::string &logger_name) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
auto found = loggers_.find(logger_name);
|
||||||
|
return found == loggers_.end() ? nullptr : found->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE std::shared_ptr<logger> registry::default_logger() {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
return default_logger_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return raw ptr to the default logger.
|
||||||
|
// To be used directly by the spdlog default api (e.g. spdlog::info)
|
||||||
|
// This make the default API faster, but cannot be used concurrently with set_default_logger().
|
||||||
|
// e.g do not call set_default_logger() from one thread while calling spdlog::info() from another.
|
||||||
|
SPDLOG_INLINE logger *registry::get_default_raw() { return default_logger_.get(); }
|
||||||
|
|
||||||
|
// set default logger.
|
||||||
|
// default logger is stored in default_logger_ (for faster retrieval) and in the loggers_ map.
|
||||||
|
SPDLOG_INLINE void registry::set_default_logger(std::shared_ptr<logger> new_default_logger) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
if (new_default_logger != nullptr) {
|
||||||
|
loggers_[new_default_logger->name()] = new_default_logger;
|
||||||
|
}
|
||||||
|
default_logger_ = std::move(new_default_logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::set_tp(std::shared_ptr<thread_pool> tp) {
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(tp_mutex_);
|
||||||
|
tp_ = std::move(tp);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE std::shared_ptr<thread_pool> registry::get_tp() {
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(tp_mutex_);
|
||||||
|
return tp_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set global formatter. Each sink in each logger will get a clone of this object
|
||||||
|
SPDLOG_INLINE void registry::set_formatter(std::unique_ptr<formatter> formatter) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
formatter_ = std::move(formatter);
|
||||||
|
for (auto &l : loggers_) {
|
||||||
|
l.second->set_formatter(formatter_->clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::enable_backtrace(size_t n_messages) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
backtrace_n_messages_ = n_messages;
|
||||||
|
|
||||||
|
for (auto &l : loggers_) {
|
||||||
|
l.second->enable_backtrace(n_messages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::disable_backtrace() {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
backtrace_n_messages_ = 0;
|
||||||
|
for (auto &l : loggers_) {
|
||||||
|
l.second->disable_backtrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::set_level(level::level_enum log_level) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
for (auto &l : loggers_) {
|
||||||
|
l.second->set_level(log_level);
|
||||||
|
}
|
||||||
|
global_log_level_ = log_level;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::flush_on(level::level_enum log_level) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
for (auto &l : loggers_) {
|
||||||
|
l.second->flush_on(log_level);
|
||||||
|
}
|
||||||
|
flush_level_ = log_level;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::set_error_handler(err_handler handler) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
for (auto &l : loggers_) {
|
||||||
|
l.second->set_error_handler(handler);
|
||||||
|
}
|
||||||
|
err_handler_ = std::move(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::apply_all(
|
||||||
|
const std::function<void(const std::shared_ptr<logger>)> &fun) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
for (auto &l : loggers_) {
|
||||||
|
fun(l.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::flush_all() {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
for (auto &l : loggers_) {
|
||||||
|
l.second->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::drop(const std::string &logger_name) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
auto is_default_logger = default_logger_ && default_logger_->name() == logger_name;
|
||||||
|
loggers_.erase(logger_name);
|
||||||
|
if (is_default_logger) {
|
||||||
|
default_logger_.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::drop_all() {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
loggers_.clear();
|
||||||
|
default_logger_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// clean all resources and threads started by the registry
|
||||||
|
SPDLOG_INLINE void registry::shutdown() {
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(flusher_mutex_);
|
||||||
|
periodic_flusher_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
drop_all();
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(tp_mutex_);
|
||||||
|
tp_.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE std::recursive_mutex ®istry::tp_mutex() { return tp_mutex_; }
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::set_automatic_registration(bool automatic_registration) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
automatic_registration_ = automatic_registration;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::set_levels(log_levels levels, level::level_enum *global_level) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
log_levels_ = std::move(levels);
|
||||||
|
auto global_level_requested = global_level != nullptr;
|
||||||
|
global_log_level_ = global_level_requested ? *global_level : global_log_level_;
|
||||||
|
|
||||||
|
for (auto &logger : loggers_) {
|
||||||
|
auto logger_entry = log_levels_.find(logger.first);
|
||||||
|
if (logger_entry != log_levels_.end()) {
|
||||||
|
logger.second->set_level(logger_entry->second);
|
||||||
|
} else if (global_level_requested) {
|
||||||
|
logger.second->set_level(*global_level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE registry ®istry::instance() {
|
||||||
|
static registry s_instance;
|
||||||
|
return s_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::apply_logger_env_levels(std::shared_ptr<logger> new_logger) {
|
||||||
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
|
auto it = log_levels_.find(new_logger->name());
|
||||||
|
auto new_level = it != log_levels_.end() ? it->second : global_log_level_;
|
||||||
|
new_logger->set_level(new_level);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::throw_if_exists_(const std::string &logger_name) {
|
||||||
|
if (loggers_.find(logger_name) != loggers_.end()) {
|
||||||
|
throw_spdlog_ex("logger with name '" + logger_name + "' already exists");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE void registry::register_logger_(std::shared_ptr<logger> new_logger) {
|
||||||
|
auto logger_name = new_logger->name();
|
||||||
|
throw_if_exists_(logger_name);
|
||||||
|
loggers_[logger_name] = std::move(new_logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
@ -1,19 +1,15 @@
|
|||||||
//
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Loggers registy of unique name->logger pointer
|
// Loggers registry of unique name->logger pointer
|
||||||
// An attempt to create a logger with an already existing name will be ignored
|
// An attempt to create a logger with an already existing name will result with spdlog_ex exception.
|
||||||
// If user requests a non existing logger, nullptr will be returned
|
// If user requests a non existing logger, nullptr will be returned
|
||||||
// This class is thread safe
|
// This class is thread safe
|
||||||
|
|
||||||
#include "../details/null_mutex.h"
|
#include <spdlog/common.h>
|
||||||
#include "../logger.h"
|
#include <spdlog/details/periodic_worker.h>
|
||||||
#include "../async_logger.h"
|
|
||||||
#include "../common.h"
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@ -22,193 +18,112 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace spdlog
|
namespace spdlog {
|
||||||
{
|
class logger;
|
||||||
namespace details
|
|
||||||
{
|
namespace details {
|
||||||
template <class Mutex> class registry_t
|
class thread_pool;
|
||||||
{
|
|
||||||
|
class SPDLOG_API registry {
|
||||||
public:
|
public:
|
||||||
|
using log_levels = std::unordered_map<std::string, level::level_enum>;
|
||||||
|
registry(const registry &) = delete;
|
||||||
|
registry &operator=(const registry &) = delete;
|
||||||
|
|
||||||
void register_logger(std::shared_ptr<logger> logger)
|
void register_logger(std::shared_ptr<logger> new_logger);
|
||||||
{
|
void initialize_logger(std::shared_ptr<logger> new_logger);
|
||||||
std::lock_guard<Mutex> lock(_mutex);
|
std::shared_ptr<logger> get(const std::string &logger_name);
|
||||||
auto logger_name = logger->name();
|
std::shared_ptr<logger> default_logger();
|
||||||
throw_if_exists(logger_name);
|
|
||||||
_loggers[logger_name] = logger;
|
// Return raw ptr to the default logger.
|
||||||
|
// To be used directly by the spdlog default api (e.g. spdlog::info)
|
||||||
|
// This make the default API faster, but cannot be used concurrently with set_default_logger().
|
||||||
|
// e.g do not call set_default_logger() from one thread while calling spdlog::info() from
|
||||||
|
// another.
|
||||||
|
logger *get_default_raw();
|
||||||
|
|
||||||
|
// set default logger and add it to the registry if not registered already.
|
||||||
|
// default logger is stored in default_logger_ (for faster retrieval) and in the loggers_ map.
|
||||||
|
// Note: Make sure to unregister it when no longer needed or before calling again with a new
|
||||||
|
// logger.
|
||||||
|
void set_default_logger(std::shared_ptr<logger> new_default_logger);
|
||||||
|
|
||||||
|
void set_tp(std::shared_ptr<thread_pool> tp);
|
||||||
|
|
||||||
|
std::shared_ptr<thread_pool> get_tp();
|
||||||
|
|
||||||
|
// Set global formatter. Each sink in each logger will get a clone of this object
|
||||||
|
void set_formatter(std::unique_ptr<formatter> formatter);
|
||||||
|
|
||||||
|
void enable_backtrace(size_t n_messages);
|
||||||
|
|
||||||
|
void disable_backtrace();
|
||||||
|
|
||||||
|
void set_level(level::level_enum log_level);
|
||||||
|
|
||||||
|
void flush_on(level::level_enum log_level);
|
||||||
|
|
||||||
|
template <typename Rep, typename Period>
|
||||||
|
void flush_every(std::chrono::duration<Rep, Period> interval) {
|
||||||
|
std::lock_guard<std::mutex> lock(flusher_mutex_);
|
||||||
|
auto clbk = [this]() { this->flush_all(); };
|
||||||
|
periodic_flusher_ = details::make_unique<periodic_worker>(clbk, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<periodic_worker> &get_flusher() {
|
||||||
std::shared_ptr<logger> get(const std::string& logger_name)
|
std::lock_guard<std::mutex> lock(flusher_mutex_);
|
||||||
{
|
return periodic_flusher_;
|
||||||
std::lock_guard<Mutex> lock(_mutex);
|
|
||||||
auto found = _loggers.find(logger_name);
|
|
||||||
return found == _loggers.end() ? nullptr : found->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class It>
|
void set_error_handler(err_handler handler);
|
||||||
std::shared_ptr<logger> create(const std::string& logger_name, const It& sinks_begin, const It& sinks_end)
|
|
||||||
{
|
|
||||||
std::lock_guard<Mutex> lock(_mutex);
|
|
||||||
throw_if_exists(logger_name);
|
|
||||||
std::shared_ptr<logger> new_logger;
|
|
||||||
if (_async_mode)
|
|
||||||
new_logger = std::make_shared<async_logger>(logger_name, sinks_begin, sinks_end, _async_q_size, _overflow_policy, _worker_warmup_cb, _flush_interval_ms, _worker_teardown_cb);
|
|
||||||
else
|
|
||||||
new_logger = std::make_shared<logger>(logger_name, sinks_begin, sinks_end);
|
|
||||||
|
|
||||||
if (_formatter)
|
void apply_all(const std::function<void(const std::shared_ptr<logger>)> &fun);
|
||||||
new_logger->set_formatter(_formatter);
|
|
||||||
|
|
||||||
if (_err_handler)
|
void flush_all();
|
||||||
new_logger->set_error_handler(_err_handler);
|
|
||||||
|
|
||||||
new_logger->set_level(_level);
|
void drop(const std::string &logger_name);
|
||||||
|
|
||||||
|
void drop_all();
|
||||||
|
|
||||||
//Add to registry
|
// clean all resources and threads started by the registry
|
||||||
_loggers[logger_name] = new_logger;
|
void shutdown();
|
||||||
return new_logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class It>
|
std::recursive_mutex &tp_mutex();
|
||||||
std::shared_ptr<async_logger> create_async(const std::string& logger_name, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb, const It& sinks_begin, const It& sinks_end)
|
|
||||||
{
|
|
||||||
std::lock_guard<Mutex> lock(_mutex);
|
|
||||||
throw_if_exists(logger_name);
|
|
||||||
auto new_logger = std::make_shared<async_logger>(logger_name, sinks_begin, sinks_end, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb);
|
|
||||||
|
|
||||||
if (_formatter)
|
void set_automatic_registration(bool automatic_registration);
|
||||||
new_logger->set_formatter(_formatter);
|
|
||||||
|
|
||||||
if (_err_handler)
|
// set levels for all existing/future loggers. global_level can be null if should not set.
|
||||||
new_logger->set_error_handler(_err_handler);
|
void set_levels(log_levels levels, level::level_enum *global_level);
|
||||||
|
|
||||||
new_logger->set_level(_level);
|
static registry &instance();
|
||||||
|
|
||||||
//Add to registry
|
void apply_logger_env_levels(std::shared_ptr<logger> new_logger);
|
||||||
_loggers[logger_name] = new_logger;
|
|
||||||
return new_logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
void apply_all(std::function<void(std::shared_ptr<logger>)> fun)
|
|
||||||
{
|
|
||||||
std::lock_guard<Mutex> lock(_mutex);
|
|
||||||
for (auto &l : _loggers)
|
|
||||||
fun(l.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
void drop(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
std::lock_guard<Mutex> lock(_mutex);
|
|
||||||
_loggers.erase(logger_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void drop_all()
|
|
||||||
{
|
|
||||||
std::lock_guard<Mutex> lock(_mutex);
|
|
||||||
_loggers.clear();
|
|
||||||
}
|
|
||||||
std::shared_ptr<logger> create(const std::string& logger_name, sinks_init_list sinks)
|
|
||||||
{
|
|
||||||
return create(logger_name, sinks.begin(), sinks.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<logger> create(const std::string& logger_name, sink_ptr sink)
|
|
||||||
{
|
|
||||||
return create(logger_name, { sink });
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<async_logger> create_async(const std::string& logger_name, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb, sinks_init_list sinks)
|
|
||||||
{
|
|
||||||
return create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, sinks.begin(), sinks.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<async_logger> create_async(const std::string& logger_name, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb, sink_ptr sink)
|
|
||||||
{
|
|
||||||
return create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, { sink });
|
|
||||||
}
|
|
||||||
|
|
||||||
void formatter(formatter_ptr f)
|
|
||||||
{
|
|
||||||
std::lock_guard<Mutex> lock(_mutex);
|
|
||||||
_formatter = f;
|
|
||||||
for (auto& l : _loggers)
|
|
||||||
l.second->set_formatter(_formatter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_pattern(const std::string& pattern)
|
|
||||||
{
|
|
||||||
std::lock_guard<Mutex> lock(_mutex);
|
|
||||||
_formatter = std::make_shared<pattern_formatter>(pattern);
|
|
||||||
for (auto& l : _loggers)
|
|
||||||
l.second->set_formatter(_formatter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_level(level::level_enum log_level)
|
|
||||||
{
|
|
||||||
std::lock_guard<Mutex> lock(_mutex);
|
|
||||||
for (auto& l : _loggers)
|
|
||||||
l.second->set_level(log_level);
|
|
||||||
_level = log_level;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_error_handler(log_err_handler handler)
|
|
||||||
{
|
|
||||||
for (auto& l : _loggers)
|
|
||||||
l.second->set_error_handler(handler);
|
|
||||||
_err_handler = handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_async_mode(size_t q_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb)
|
|
||||||
{
|
|
||||||
std::lock_guard<Mutex> lock(_mutex);
|
|
||||||
_async_mode = true;
|
|
||||||
_async_q_size = q_size;
|
|
||||||
_overflow_policy = overflow_policy;
|
|
||||||
_worker_warmup_cb = worker_warmup_cb;
|
|
||||||
_flush_interval_ms = flush_interval_ms;
|
|
||||||
_worker_teardown_cb = worker_teardown_cb;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_sync_mode()
|
|
||||||
{
|
|
||||||
std::lock_guard<Mutex> lock(_mutex);
|
|
||||||
_async_mode = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static registry_t<Mutex>& instance()
|
|
||||||
{
|
|
||||||
static registry_t<Mutex> s_instance;
|
|
||||||
return s_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
registry_t<Mutex>() {}
|
registry();
|
||||||
registry_t<Mutex>(const registry_t<Mutex>&) = delete;
|
~registry();
|
||||||
registry_t<Mutex>& operator=(const registry_t<Mutex>&) = delete;
|
|
||||||
|
|
||||||
void throw_if_exists(const std::string &logger_name)
|
void throw_if_exists_(const std::string &logger_name);
|
||||||
{
|
void register_logger_(std::shared_ptr<logger> new_logger);
|
||||||
if (_loggers.find(logger_name) != _loggers.end())
|
bool set_level_from_cfg_(logger *logger);
|
||||||
throw spdlog_ex("logger with name '" + logger_name + "' already exists");
|
std::mutex logger_map_mutex_, flusher_mutex_;
|
||||||
}
|
std::recursive_mutex tp_mutex_;
|
||||||
Mutex _mutex;
|
std::unordered_map<std::string, std::shared_ptr<logger>> loggers_;
|
||||||
std::unordered_map <std::string, std::shared_ptr<logger>> _loggers;
|
log_levels log_levels_;
|
||||||
formatter_ptr _formatter;
|
std::unique_ptr<formatter> formatter_;
|
||||||
level::level_enum _level = level::info;
|
spdlog::level::level_enum global_log_level_ = level::info;
|
||||||
log_err_handler _err_handler;
|
level::level_enum flush_level_ = level::off;
|
||||||
bool _async_mode = false;
|
err_handler err_handler_;
|
||||||
size_t _async_q_size = 0;
|
std::shared_ptr<thread_pool> tp_;
|
||||||
async_overflow_policy _overflow_policy = async_overflow_policy::block_retry;
|
std::unique_ptr<periodic_worker> periodic_flusher_;
|
||||||
std::function<void()> _worker_warmup_cb = nullptr;
|
std::shared_ptr<logger> default_logger_;
|
||||||
std::chrono::milliseconds _flush_interval_ms;
|
bool automatic_registration_ = true;
|
||||||
std::function<void()> _worker_teardown_cb = nullptr;
|
size_t backtrace_n_messages_ = 0;
|
||||||
};
|
};
|
||||||
#ifdef SPDLOG_NO_REGISTRY_MUTEX
|
|
||||||
typedef registry_t<spdlog::details::null_mutex> registry;
|
} // namespace details
|
||||||
#else
|
} // namespace spdlog
|
||||||
typedef registry_t<std::mutex> registry;
|
|
||||||
|
#ifdef SPDLOG_HEADER_ONLY
|
||||||
|
#include "registry-inl.h"
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,263 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(c) 2015 Gabi Melman.
|
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
//
|
|
||||||
// Global registry functions
|
|
||||||
//
|
|
||||||
#include "../spdlog.h"
|
|
||||||
#include "../details/registry.h"
|
|
||||||
#include "../sinks/file_sinks.h"
|
|
||||||
#include "../sinks/stdout_sinks.h"
|
|
||||||
#ifdef SPDLOG_ENABLE_SYSLOG
|
|
||||||
#include "../sinks/syslog_sink.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include "../sinks/wincolor_sink.h"
|
|
||||||
#else
|
|
||||||
#include "../sinks/ansicolor_sink.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
#include "../sinks/android_sink.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
inline void spdlog::register_logger(std::shared_ptr<logger> logger)
|
|
||||||
{
|
|
||||||
return details::registry::instance().register_logger(logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::get(const std::string& name)
|
|
||||||
{
|
|
||||||
return details::registry::instance().get(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::drop(const std::string &name)
|
|
||||||
{
|
|
||||||
details::registry::instance().drop(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create multi/single threaded simple file logger
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::basic_logger_mt(const std::string& logger_name, const filename_t& filename, bool truncate)
|
|
||||||
{
|
|
||||||
return create<spdlog::sinks::simple_file_sink_mt>(logger_name, filename, truncate);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::basic_logger_st(const std::string& logger_name, const filename_t& filename, bool truncate)
|
|
||||||
{
|
|
||||||
return create<spdlog::sinks::simple_file_sink_st>(logger_name, filename, truncate);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create multi/single threaded rotating file logger
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_mt(const std::string& logger_name, const filename_t& filename, size_t max_file_size, size_t max_files)
|
|
||||||
{
|
|
||||||
return create<spdlog::sinks::rotating_file_sink_mt>(logger_name, filename, max_file_size, max_files);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_st(const std::string& logger_name, const filename_t& filename, size_t max_file_size, size_t max_files)
|
|
||||||
{
|
|
||||||
return create<spdlog::sinks::rotating_file_sink_st>(logger_name, filename, max_file_size, max_files);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create file logger which creates new file at midnight):
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_mt(const std::string& logger_name, const filename_t& filename, int hour, int minute)
|
|
||||||
{
|
|
||||||
return create<spdlog::sinks::daily_file_sink_mt>(logger_name, filename, hour, minute);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_st(const std::string& logger_name, const filename_t& filename, int hour, int minute)
|
|
||||||
{
|
|
||||||
return create<spdlog::sinks::daily_file_sink_st>(logger_name, filename, hour, minute);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// stdout/stderr loggers
|
|
||||||
//
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::stdout_logger_mt(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
return spdlog::details::registry::instance().create(logger_name, spdlog::sinks::stdout_sink_mt::instance());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::stdout_logger_st(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
return spdlog::details::registry::instance().create(logger_name, spdlog::sinks::stdout_sink_st::instance());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_mt(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
return spdlog::details::registry::instance().create(logger_name, spdlog::sinks::stderr_sink_mt::instance());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
return spdlog::details::registry::instance().create(logger_name, spdlog::sinks::stderr_sink_st::instance());
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// stdout/stderr color loggers
|
|
||||||
//
|
|
||||||
#ifdef _WIN32
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_mt(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
auto sink = std::make_shared<spdlog::sinks::wincolor_stdout_sink_mt>();
|
|
||||||
return spdlog::details::registry::instance().create(logger_name, sink);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_st(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
auto sink = std::make_shared<spdlog::sinks::wincolor_stdout_sink_st>();
|
|
||||||
return spdlog::details::registry::instance().create(logger_name, sink);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_mt(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
auto sink = std::make_shared<spdlog::sinks::wincolor_stderr_sink_mt>();
|
|
||||||
return spdlog::details::registry::instance().create(logger_name, sink);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_st(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
auto sink = std::make_shared<spdlog::sinks::wincolor_stderr_sink_st>();
|
|
||||||
return spdlog::details::registry::instance().create(logger_name, sink);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else //ansi terminal colors
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_mt(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
auto sink = std::make_shared<spdlog::sinks::ansicolor_stdout_sink_mt>();
|
|
||||||
return spdlog::details::registry::instance().create(logger_name, sink);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_st(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
auto sink = std::make_shared<spdlog::sinks::ansicolor_stdout_sink_st>();
|
|
||||||
return spdlog::details::registry::instance().create(logger_name, sink);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_mt(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
auto sink = std::make_shared<spdlog::sinks::ansicolor_stderr_sink_mt>();
|
|
||||||
return spdlog::details::registry::instance().create(logger_name, sink);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_st(const std::string& logger_name)
|
|
||||||
{
|
|
||||||
auto sink = std::make_shared<spdlog::sinks::ansicolor_stderr_sink_st>();
|
|
||||||
return spdlog::details::registry::instance().create(logger_name, sink);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SPDLOG_ENABLE_SYSLOG
|
|
||||||
// Create syslog logger
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string& logger_name, const std::string& syslog_ident, int syslog_option, int syslog_facility)
|
|
||||||
{
|
|
||||||
return create<spdlog::sinks::syslog_sink>(logger_name, syslog_ident, syslog_option, syslog_facility);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::android_logger(const std::string& logger_name, const std::string& tag)
|
|
||||||
{
|
|
||||||
return create<spdlog::sinks::android_sink>(logger_name, tag);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Create and register a logger a single sink
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, const spdlog::sink_ptr& sink)
|
|
||||||
{
|
|
||||||
return details::registry::instance().create(logger_name, sink);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Create logger with multiple sinks
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, spdlog::sinks_init_list sinks)
|
|
||||||
{
|
|
||||||
return details::registry::instance().create(logger_name, sinks);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <typename Sink, typename... Args>
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, Args... args)
|
|
||||||
{
|
|
||||||
sink_ptr sink = std::make_shared<Sink>(args...);
|
|
||||||
return details::registry::instance().create(logger_name, { sink });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class It>
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, const It& sinks_begin, const It& sinks_end)
|
|
||||||
{
|
|
||||||
return details::registry::instance().create(logger_name, sinks_begin, sinks_end);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and register an async logger with a single sink
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::create_async(const std::string& logger_name, const sink_ptr& sink, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb)
|
|
||||||
{
|
|
||||||
return details::registry::instance().create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, sink);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and register an async logger with multiple sinks
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::create_async(const std::string& logger_name, sinks_init_list sinks, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb )
|
|
||||||
{
|
|
||||||
return details::registry::instance().create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, sinks);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class It>
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::create_async(const std::string& logger_name, const It& sinks_begin, const It& sinks_end, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb)
|
|
||||||
{
|
|
||||||
return details::registry::instance().create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, sinks_begin, sinks_end);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::set_formatter(spdlog::formatter_ptr f)
|
|
||||||
{
|
|
||||||
details::registry::instance().formatter(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::set_pattern(const std::string& format_string)
|
|
||||||
{
|
|
||||||
return details::registry::instance().set_pattern(format_string);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::set_level(level::level_enum log_level)
|
|
||||||
{
|
|
||||||
return details::registry::instance().set_level(log_level);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::set_error_handler(log_err_handler handler)
|
|
||||||
{
|
|
||||||
return details::registry::instance().set_error_handler(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void spdlog::set_async_mode(size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb)
|
|
||||||
{
|
|
||||||
details::registry::instance().set_async_mode(queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::set_sync_mode()
|
|
||||||
{
|
|
||||||
details::registry::instance().set_sync_mode();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::apply_all(std::function<void(std::shared_ptr<logger>)> fun)
|
|
||||||
{
|
|
||||||
details::registry::instance().apply_all(fun);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void spdlog::drop_all()
|
|
||||||
{
|
|
||||||
details::registry::instance().drop_all();
|
|
||||||
}
|
|
22
include/spdlog/details/synchronous_factory.h
Normal file
22
include/spdlog/details/synchronous_factory.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "registry.h"
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
|
||||||
|
// Default logger factory- creates synchronous loggers
|
||||||
|
class logger;
|
||||||
|
|
||||||
|
struct synchronous_factory {
|
||||||
|
template <typename Sink, typename... SinkArgs>
|
||||||
|
static std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs &&...args) {
|
||||||
|
auto sink = std::make_shared<Sink>(std::forward<SinkArgs>(args)...);
|
||||||
|
auto new_logger = std::make_shared<spdlog::logger>(std::move(logger_name), std::move(sink));
|
||||||
|
details::registry::instance().initialize_logger(new_logger);
|
||||||
|
return new_logger;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace spdlog
|
135
include/spdlog/details/tcp_client-windows.h
Normal file
135
include/spdlog/details/tcp_client-windows.h
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
// tcp client helper
|
||||||
|
#include <spdlog/common.h>
|
||||||
|
#include <spdlog/details/os.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
|
||||||
|
#pragma comment(lib, "Ws2_32.lib")
|
||||||
|
#pragma comment(lib, "Mswsock.lib")
|
||||||
|
#pragma comment(lib, "AdvApi32.lib")
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
|
class tcp_client {
|
||||||
|
SOCKET socket_ = INVALID_SOCKET;
|
||||||
|
|
||||||
|
static void init_winsock_() {
|
||||||
|
WSADATA wsaData;
|
||||||
|
auto rv = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||||
|
if (rv != 0) {
|
||||||
|
throw_winsock_error_("WSAStartup failed", ::WSAGetLastError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void throw_winsock_error_(const std::string &msg, int last_error) {
|
||||||
|
char buf[512];
|
||||||
|
::FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
||||||
|
last_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf,
|
||||||
|
(sizeof(buf) / sizeof(char)), NULL);
|
||||||
|
|
||||||
|
throw_spdlog_ex(fmt_lib::format("tcp_sink - {}: {}", msg, buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
tcp_client() { init_winsock_(); }
|
||||||
|
|
||||||
|
~tcp_client() {
|
||||||
|
close();
|
||||||
|
::WSACleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_connected() const { return socket_ != INVALID_SOCKET; }
|
||||||
|
|
||||||
|
void close() {
|
||||||
|
::closesocket(socket_);
|
||||||
|
socket_ = INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
SOCKET fd() const { return socket_; }
|
||||||
|
|
||||||
|
// try to connect or throw on failure
|
||||||
|
void connect(const std::string &host, int port) {
|
||||||
|
if (is_connected()) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
struct addrinfo hints {};
|
||||||
|
ZeroMemory(&hints, sizeof(hints));
|
||||||
|
|
||||||
|
hints.ai_family = AF_UNSPEC; // To work with IPv4, IPv6, and so on
|
||||||
|
hints.ai_socktype = SOCK_STREAM; // TCP
|
||||||
|
hints.ai_flags = AI_NUMERICSERV; // port passed as as numeric value
|
||||||
|
hints.ai_protocol = 0;
|
||||||
|
|
||||||
|
auto port_str = std::to_string(port);
|
||||||
|
struct addrinfo *addrinfo_result;
|
||||||
|
auto rv = ::getaddrinfo(host.c_str(), port_str.c_str(), &hints, &addrinfo_result);
|
||||||
|
int last_error = 0;
|
||||||
|
if (rv != 0) {
|
||||||
|
last_error = ::WSAGetLastError();
|
||||||
|
WSACleanup();
|
||||||
|
throw_winsock_error_("getaddrinfo failed", last_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try each address until we successfully connect(2).
|
||||||
|
|
||||||
|
for (auto *rp = addrinfo_result; rp != nullptr; rp = rp->ai_next) {
|
||||||
|
socket_ = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
|
||||||
|
if (socket_ == INVALID_SOCKET) {
|
||||||
|
last_error = ::WSAGetLastError();
|
||||||
|
WSACleanup();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (::connect(socket_, rp->ai_addr, (int)rp->ai_addrlen) == 0) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
last_error = ::WSAGetLastError();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
::freeaddrinfo(addrinfo_result);
|
||||||
|
if (socket_ == INVALID_SOCKET) {
|
||||||
|
WSACleanup();
|
||||||
|
throw_winsock_error_("connect failed", last_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set TCP_NODELAY
|
||||||
|
int enable_flag = 1;
|
||||||
|
::setsockopt(socket_, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char *>(&enable_flag),
|
||||||
|
sizeof(enable_flag));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send exactly n_bytes of the given data.
|
||||||
|
// On error close the connection and throw.
|
||||||
|
void send(const char *data, size_t n_bytes) {
|
||||||
|
size_t bytes_sent = 0;
|
||||||
|
while (bytes_sent < n_bytes) {
|
||||||
|
const int send_flags = 0;
|
||||||
|
auto write_result =
|
||||||
|
::send(socket_, data + bytes_sent, (int)(n_bytes - bytes_sent), send_flags);
|
||||||
|
if (write_result == SOCKET_ERROR) {
|
||||||
|
int last_error = ::WSAGetLastError();
|
||||||
|
close();
|
||||||
|
throw_winsock_error_("send failed", last_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (write_result == 0) // (probably should not happen but in any case..)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bytes_sent += static_cast<size_t>(write_result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace details
|
||||||
|
} // namespace spdlog
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user