aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYigit Sever2021-04-15 23:03:58 +0300
committerYigit Sever2021-04-15 23:03:58 +0300
commit8c2b7ebe1e98b88ddbb07a68dc8e54b7c5047379 (patch)
treee0bb5359ee7f1905f9829e5b95a64d1fb9553c7c
parent7ee9ebea367895b1b028c7a842a635f271d6f8c4 (diff)
downloadgradecoin-8c2b7ebe1e98b88ddbb07a68dc8e54b7c5047379.tar.gz
gradecoin-8c2b7ebe1e98b88ddbb07a68dc8e54b7c5047379.tar.bz2
gradecoin-8c2b7ebe1e98b88ddbb07a68dc8e54b7c5047379.zip
Switch over to big boy logging
-rw-r--r--.gitignore3
-rw-r--r--Cargo.lock258
-rw-r--r--Cargo.toml2
-rw-r--r--log.conf.yml41
-rw-r--r--src/bin/main.rs3
5 files changed, 232 insertions, 75 deletions
diff --git a/.gitignore b/.gitignore
index 7b71fac..71a094e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
1/target 1log/
2target/
2blocks/ 3blocks/
3users/ 4users/
4tags.lock 5tags.lock
diff --git a/Cargo.lock b/Cargo.lock
index 649c923..5538eee 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -41,6 +41,18 @@ dependencies = [
41] 41]
42 42
43[[package]] 43[[package]]
44name = "anyhow"
45version = "1.0.40"
46source = "registry+https://github.com/rust-lang/crates.io-index"
47checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b"
48
49[[package]]
50name = "arc-swap"
51version = "0.4.8"
52source = "registry+https://github.com/rust-lang/crates.io-index"
53checksum = "dabe5a181f83789739c194cbe5a897dde195078fac08568d09221fd6137a7ba8"
54
55[[package]]
44name = "arrayvec" 56name = "arrayvec"
45version = "0.5.2" 57version = "0.5.2"
46source = "registry+https://github.com/rust-lang/crates.io-index" 58source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -93,17 +105,6 @@ dependencies = [
93] 105]
94 106
95[[package]] 107[[package]]
96name = "atty"
97version = "0.2.14"
98source = "registry+https://github.com/rust-lang/crates.io-index"
99checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
100dependencies = [
101 "hermit-abi",
102 "libc",
103 "winapi 0.3.9",
104]
105
106[[package]]
107name = "autocfg" 108name = "autocfg"
108version = "0.1.7" 109version = "0.1.7"
109source = "registry+https://github.com/rust-lang/crates.io-index" 110source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -282,6 +283,17 @@ dependencies = [
282] 283]
283 284
284[[package]] 285[[package]]
286name = "derivative"
287version = "2.2.0"
288source = "registry+https://github.com/rust-lang/crates.io-index"
289checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
290dependencies = [
291 "proc-macro2",
292 "quote",
293 "syn",
294]
295
296[[package]]
285name = "digest" 297name = "digest"
286version = "0.9.0" 298version = "0.9.0"
287source = "registry+https://github.com/rust-lang/crates.io-index" 299source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -297,19 +309,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
297checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" 309checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0"
298 310
299[[package]] 311[[package]]
300name = "env_logger"
301version = "0.6.2"
302source = "registry+https://github.com/rust-lang/crates.io-index"
303checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
304dependencies = [
305 "atty",
306 "humantime",
307 "log",
308 "regex",
309 "termcolor",
310]
311
312[[package]]
313name = "fnv" 312name = "fnv"
314version = "1.0.7" 313version = "1.0.7"
315source = "registry+https://github.com/rust-lang/crates.io-index" 314source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -455,9 +454,9 @@ dependencies = [
455 "jsonwebtoken", 454 "jsonwebtoken",
456 "lazy_static", 455 "lazy_static",
457 "log", 456 "log",
457 "log4rs",
458 "md-5", 458 "md-5",
459 "parking_lot", 459 "parking_lot 0.10.2",
460 "pretty_env_logger",
461 "rsa", 460 "rsa",
462 "serde", 461 "serde",
463 "serde_json", 462 "serde_json",
@@ -519,15 +518,6 @@ dependencies = [
519] 518]
520 519
521[[package]] 520[[package]]
522name = "hermit-abi"
523version = "0.1.18"
524source = "registry+https://github.com/rust-lang/crates.io-index"
525checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
526dependencies = [
527 "libc",
528]
529
530[[package]]
531name = "hex-literal" 521name = "hex-literal"
532version = "0.3.1" 522version = "0.3.1"
533source = "registry+https://github.com/rust-lang/crates.io-index" 523source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -574,12 +564,9 @@ checksum = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e"
574 564
575[[package]] 565[[package]]
576name = "humantime" 566name = "humantime"
577version = "1.3.0" 567version = "2.1.0"
578source = "registry+https://github.com/rust-lang/crates.io-index" 568source = "registry+https://github.com/rust-lang/crates.io-index"
579checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" 569checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
580dependencies = [
581 "quick-error",
582]
583 570
584[[package]] 571[[package]]
585name = "hyper" 572name = "hyper"
@@ -636,6 +623,15 @@ dependencies = [
636] 623]
637 624
638[[package]] 625[[package]]
626name = "instant"
627version = "0.1.9"
628source = "registry+https://github.com/rust-lang/crates.io-index"
629checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
630dependencies = [
631 "cfg-if 1.0.0",
632]
633
634[[package]]
639name = "iovec" 635name = "iovec"
640version = "0.1.4" 636version = "0.1.4"
641source = "registry+https://github.com/rust-lang/crates.io-index" 637source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -718,6 +714,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
718checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" 714checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
719 715
720[[package]] 716[[package]]
717name = "linked-hash-map"
718version = "0.5.4"
719source = "registry+https://github.com/rust-lang/crates.io-index"
720checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
721
722[[package]]
721name = "lock_api" 723name = "lock_api"
722version = "0.3.4" 724version = "0.3.4"
723source = "registry+https://github.com/rust-lang/crates.io-index" 725source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -727,12 +729,55 @@ dependencies = [
727] 729]
728 730
729[[package]] 731[[package]]
732name = "lock_api"
733version = "0.4.3"
734source = "registry+https://github.com/rust-lang/crates.io-index"
735checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176"
736dependencies = [
737 "scopeguard",
738]
739
740[[package]]
730name = "log" 741name = "log"
731version = "0.4.14" 742version = "0.4.14"
732source = "registry+https://github.com/rust-lang/crates.io-index" 743source = "registry+https://github.com/rust-lang/crates.io-index"
733checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" 744checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
734dependencies = [ 745dependencies = [
735 "cfg-if 1.0.0", 746 "cfg-if 1.0.0",
747 "serde",
748]
749
750[[package]]
751name = "log-mdc"
752version = "0.1.0"
753source = "registry+https://github.com/rust-lang/crates.io-index"
754checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7"
755
756[[package]]
757name = "log4rs"
758version = "1.0.0"
759source = "registry+https://github.com/rust-lang/crates.io-index"
760checksum = "d1572a880d1115ff867396eee7ae2bc924554225e67a0d3c85c745b3e60ca211"
761dependencies = [
762 "anyhow",
763 "arc-swap",
764 "chrono",
765 "derivative",
766 "fnv",
767 "humantime",
768 "libc",
769 "log",
770 "log-mdc",
771 "parking_lot 0.11.1",
772 "regex",
773 "serde",
774 "serde-value",
775 "serde_json",
776 "serde_yaml",
777 "thiserror",
778 "thread-id",
779 "typemap",
780 "winapi 0.3.9",
736] 781]
737 782
738[[package]] 783[[package]]
@@ -931,13 +976,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
931checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" 976checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
932 977
933[[package]] 978[[package]]
979name = "ordered-float"
980version = "2.1.1"
981source = "registry+https://github.com/rust-lang/crates.io-index"
982checksum = "766f840da25490628d8e63e529cd21c014f6600c6b8517add12a6fa6167a6218"
983dependencies = [
984 "num-traits",
985]
986
987[[package]]
934name = "parking_lot" 988name = "parking_lot"
935version = "0.10.2" 989version = "0.10.2"
936source = "registry+https://github.com/rust-lang/crates.io-index" 990source = "registry+https://github.com/rust-lang/crates.io-index"
937checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" 991checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e"
938dependencies = [ 992dependencies = [
939 "lock_api", 993 "lock_api 0.3.4",
940 "parking_lot_core", 994 "parking_lot_core 0.7.2",
995]
996
997[[package]]
998name = "parking_lot"
999version = "0.11.1"
1000source = "registry+https://github.com/rust-lang/crates.io-index"
1001checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
1002dependencies = [
1003 "instant",
1004 "lock_api 0.4.3",
1005 "parking_lot_core 0.8.3",
941] 1006]
942 1007
943[[package]] 1008[[package]]
@@ -955,6 +1020,20 @@ dependencies = [
955] 1020]
956 1021
957[[package]] 1022[[package]]
1023name = "parking_lot_core"
1024version = "0.8.3"
1025source = "registry+https://github.com/rust-lang/crates.io-index"
1026checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
1027dependencies = [
1028 "cfg-if 1.0.0",
1029 "instant",
1030 "libc",
1031 "redox_syscall 0.2.6",
1032 "smallvec",
1033 "winapi 0.3.9",
1034]
1035
1036[[package]]
958name = "pem" 1037name = "pem"
959version = "0.8.3" 1038version = "0.8.3"
960source = "registry+https://github.com/rust-lang/crates.io-index" 1039source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1036,17 +1115,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1036checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" 1115checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
1037 1116
1038[[package]] 1117[[package]]
1039name = "pretty_env_logger"
1040version = "0.3.1"
1041source = "registry+https://github.com/rust-lang/crates.io-index"
1042checksum = "717ee476b1690853d222af4634056d830b5197ffd747726a9a1eee6da9f49074"
1043dependencies = [
1044 "chrono",
1045 "env_logger",
1046 "log",
1047]
1048
1049[[package]]
1050name = "proc-macro2" 1118name = "proc-macro2"
1051version = "1.0.26" 1119version = "1.0.26"
1052source = "registry+https://github.com/rust-lang/crates.io-index" 1120source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1267,6 +1335,16 @@ dependencies = [
1267] 1335]
1268 1336
1269[[package]] 1337[[package]]
1338name = "serde-value"
1339version = "0.7.0"
1340source = "registry+https://github.com/rust-lang/crates.io-index"
1341checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c"
1342dependencies = [
1343 "ordered-float",
1344 "serde",
1345]
1346
1347[[package]]
1270name = "serde_derive" 1348name = "serde_derive"
1271version = "1.0.125" 1349version = "1.0.125"
1272source = "registry+https://github.com/rust-lang/crates.io-index" 1350source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1310,6 +1388,18 @@ dependencies = [
1310] 1388]
1311 1389
1312[[package]] 1390[[package]]
1391name = "serde_yaml"
1392version = "0.8.17"
1393source = "registry+https://github.com/rust-lang/crates.io-index"
1394checksum = "15654ed4ab61726bf918a39cb8d98a2e2995b002387807fa6ba58fdf7f59bb23"
1395dependencies = [
1396 "dtoa",
1397 "linked-hash-map",
1398 "serde",
1399 "yaml-rust",
1400]
1401
1402[[package]]
1313name = "sha-1" 1403name = "sha-1"
1314version = "0.9.4" 1404version = "0.9.4"
1315source = "registry+https://github.com/rust-lang/crates.io-index" 1405source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1443,15 +1533,6 @@ dependencies = [
1443] 1533]
1444 1534
1445[[package]] 1535[[package]]
1446name = "termcolor"
1447version = "1.1.2"
1448source = "registry+https://github.com/rust-lang/crates.io-index"
1449checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
1450dependencies = [
1451 "winapi-util",
1452]
1453
1454[[package]]
1455name = "thiserror" 1536name = "thiserror"
1456version = "1.0.24" 1537version = "1.0.24"
1457source = "registry+https://github.com/rust-lang/crates.io-index" 1538source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1472,6 +1553,17 @@ dependencies = [
1472] 1553]
1473 1554
1474[[package]] 1555[[package]]
1556name = "thread-id"
1557version = "3.3.0"
1558source = "registry+https://github.com/rust-lang/crates.io-index"
1559checksum = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1"
1560dependencies = [
1561 "libc",
1562 "redox_syscall 0.1.57",
1563 "winapi 0.3.9",
1564]
1565
1566[[package]]
1475name = "time" 1567name = "time"
1476version = "0.1.43" 1568version = "0.1.43"
1477source = "registry+https://github.com/rust-lang/crates.io-index" 1569source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1599,6 +1691,12 @@ dependencies = [
1599] 1691]
1600 1692
1601[[package]] 1693[[package]]
1694name = "traitobject"
1695version = "0.1.0"
1696source = "registry+https://github.com/rust-lang/crates.io-index"
1697checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
1698
1699[[package]]
1602name = "try-lock" 1700name = "try-lock"
1603version = "0.2.3" 1701version = "0.2.3"
1604source = "registry+https://github.com/rust-lang/crates.io-index" 1702source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1633,6 +1731,15 @@ dependencies = [
1633] 1731]
1634 1732
1635[[package]] 1733[[package]]
1734name = "typemap"
1735version = "0.3.3"
1736source = "registry+https://github.com/rust-lang/crates.io-index"
1737checksum = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6"
1738dependencies = [
1739 "unsafe-any",
1740]
1741
1742[[package]]
1636name = "typenum" 1743name = "typenum"
1637version = "1.13.0" 1744version = "1.13.0"
1638source = "registry+https://github.com/rust-lang/crates.io-index" 1745source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1672,6 +1779,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1672checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" 1779checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
1673 1780
1674[[package]] 1781[[package]]
1782name = "unsafe-any"
1783version = "0.4.2"
1784source = "registry+https://github.com/rust-lang/crates.io-index"
1785checksum = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f"
1786dependencies = [
1787 "traitobject",
1788]
1789
1790[[package]]
1675name = "untrusted" 1791name = "untrusted"
1676version = "0.7.1" 1792version = "0.7.1"
1677source = "registry+https://github.com/rust-lang/crates.io-index" 1793source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1850,15 +1966,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1850checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1966checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
1851 1967
1852[[package]] 1968[[package]]
1853name = "winapi-util"
1854version = "0.1.5"
1855source = "registry+https://github.com/rust-lang/crates.io-index"
1856checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
1857dependencies = [
1858 "winapi 0.3.9",
1859]
1860
1861[[package]]
1862name = "winapi-x86_64-pc-windows-gnu" 1969name = "winapi-x86_64-pc-windows-gnu"
1863version = "0.4.0" 1970version = "0.4.0"
1864source = "registry+https://github.com/rust-lang/crates.io-index" 1971source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1881,6 +1988,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1881checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" 1988checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"
1882 1989
1883[[package]] 1990[[package]]
1991name = "yaml-rust"
1992version = "0.4.5"
1993source = "registry+https://github.com/rust-lang/crates.io-index"
1994checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
1995dependencies = [
1996 "linked-hash-map",
1997]
1998
1999[[package]]
1884name = "zeroize" 2000name = "zeroize"
1885version = "1.2.0" 2001version = "1.2.0"
1886source = "registry+https://github.com/rust-lang/crates.io-index" 2002source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index b505ba4..9c1d5f1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@ tokio = { version = "0.2.9", features = ["macros"] }
12serde = { version = "1.0.104", features = ["derive"] } 12serde = { version = "1.0.104", features = ["derive"] }
13chrono = { version = "0.4.10", features = ["serde"] } 13chrono = { version = "0.4.10", features = ["serde"] }
14log = "0.4.8" 14log = "0.4.8"
15pretty_env_logger = "0.3.1" 15log4rs = "1.0.0"
16parking_lot = "0.10.0" 16parking_lot = "0.10.0"
17serde_json = "1.0.59" 17serde_json = "1.0.59"
18lazy_static = "1.4.0" 18lazy_static = "1.4.0"
diff --git a/log.conf.yml b/log.conf.yml
new file mode 100644
index 0000000..1940669
--- /dev/null
+++ b/log.conf.yml
@@ -0,0 +1,41 @@
1# Scan this file for changes every 2 minutes
2refresh_rate: 2 minutes
3
4appenders:
5 # An appender named "stdout" that writes to stdout with pretty colours
6 stdout:
7 kind: console
8 encoder:
9 pattern: "[{d(%Y-%m-%d %H:%M:%S)} {h({l})}] - {m}\n"
10
11 # And this guy writes to file, also rolls the files (when they get too large)
12 gradecoin:
13 kind: rolling_file
14 path: "log/gradecoin.log"
15 append: true
16 encoder:
17 kind: pattern
18 pattern: "[{d(%Y-%m-%d %H:%M:%S)} {l}] - {m}\n"
19
20 policy:
21 kind: compound
22
23 trigger:
24 kind: size
25 limit: 4 mb
26
27 roller:
28 kind: fixed_window
29 pattern: "log/gradecoin.{}.old.log"
30 count: 5
31 base: 1
32
33loggers:
34 gradecoin:
35 level: info
36 appenders:
37 - stdout
38 - gradecoin
39 additive: false
40
41
diff --git a/src/bin/main.rs b/src/bin/main.rs
index 8b61e5c..882fdc6 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -10,11 +10,10 @@ use gradecoin::schema::create_database;
10#[tokio::main] 10#[tokio::main]
11async fn main() { 11async fn main() {
12 // Show debug logs by default by setting `RUST_LOG=gradecoin=debug` 12 // Show debug logs by default by setting `RUST_LOG=gradecoin=debug`
13 // TODO: write logs to file? <13-04-21, yigit> //
14 if env::var_os("RUST_LOG").is_none() { 13 if env::var_os("RUST_LOG").is_none() {
15 env::set_var("RUST_LOG", "gradecoin=debug"); 14 env::set_var("RUST_LOG", "gradecoin=debug");
16 } 15 }
17 pretty_env_logger::init(); 16 log4rs::init_file("log.conf.yml", Default::default()).unwrap();
18 17
19 let db = create_database(); 18 let db = create_database();
20 19