Move to tracing, test create order with payments

This commit is contained in:
Adrian Woźniak 2022-06-07 11:36:01 +02:00
parent e0975cc94b
commit c4939f7581
No known key found for this signature in database
GPG Key ID: 0012845A89C7352B
52 changed files with 592 additions and 308 deletions

435
Cargo.lock generated
View File

@ -11,11 +11,12 @@ dependencies = [
"bus", "bus",
"config", "config",
"database_manager", "database_manager",
"log", "fibers_rpc",
"model", "model",
"pretty_env_logger", "pretty_env_logger",
"serde", "serde",
"thiserror", "thiserror",
"tracing",
] ]
[[package]] [[package]]
@ -268,7 +269,7 @@ dependencies = [
"actix-utils", "actix-utils",
"futures-core", "futures-core",
"futures-util", "futures-util",
"mio", "mio 0.8.3",
"num_cpus", "num_cpus",
"socket2", "socket2",
"tokio", "tokio",
@ -352,7 +353,7 @@ dependencies = [
"ahash 0.7.6", "ahash 0.7.6",
"bytes", "bytes",
"bytestring", "bytestring",
"cfg-if", "cfg-if 1.0.0",
"cookie", "cookie",
"derive_more", "derive_more",
"encoding_rs", "encoding_rs",
@ -456,7 +457,7 @@ version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"cipher", "cipher",
"cpufeatures", "cpufeatures",
"opaque-debug 0.3.0", "opaque-debug 0.3.0",
@ -517,6 +518,15 @@ dependencies = [
"alloc-no-stdlib", "alloc-no-stdlib",
] ]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi 0.3.9",
]
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.57" version = "1.0.57"
@ -576,6 +586,12 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "atomic_immut"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b9fcea66a65a49890058406499cca8906e4e9cd1173bfeb272dcd2ac603e4fa"
[[package]] [[package]]
name = "atty" name = "atty"
version = "0.2.14" version = "0.2.14"
@ -584,7 +600,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi",
"libc", "libc",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -612,7 +628,7 @@ checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61"
dependencies = [ dependencies = [
"addr2line", "addr2line",
"cc", "cc",
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"miniz_oxide", "miniz_oxide",
"object", "object",
@ -664,13 +680,12 @@ dependencies = [
"dotenv", "dotenv",
"email_manager", "email_manager",
"fs_manager", "fs_manager",
"futures", "futures 0.3.21",
"futures-util", "futures-util",
"gumdrop", "gumdrop",
"human-panic", "human-panic",
"include_dir", "include_dir",
"jemallocator", "jemallocator",
"log",
"messagebus", "messagebus",
"model", "model",
"oauth2", "oauth2",
@ -689,6 +704,7 @@ dependencies = [
"tokio", "tokio",
"toml", "toml",
"tracing", "tracing",
"tracing-subscriber",
"uuid 0.8.2", "uuid 0.8.2",
"validator 0.14.0", "validator 0.14.0",
] ]
@ -805,6 +821,16 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
[[package]]
name = "bytecodec"
version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adf4c9d0bbf32eea58d7c0f812058138ee8edaf0f2802b6d03561b504729a325"
dependencies = [
"byteorder",
"trackable 0.2.24",
]
[[package]] [[package]]
name = "byteorder" name = "byteorder"
version = "1.4.3" version = "1.4.3"
@ -836,11 +862,11 @@ dependencies = [
"chrono", "chrono",
"config", "config",
"database_manager", "database_manager",
"log",
"model", "model",
"pretty_env_logger", "pretty_env_logger",
"serde", "serde",
"thiserror", "thiserror",
"tracing",
"uuid 0.8.2", "uuid 0.8.2",
] ]
@ -853,6 +879,12 @@ dependencies = [
"jobserver", "jobserver",
] ]
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.0"
@ -872,7 +904,7 @@ dependencies = [
"serde", "serde",
"time 0.1.43", "time 0.1.43",
"wasm-bindgen", "wasm-bindgen",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -911,7 +943,6 @@ name = "config"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"log",
"parking_lot 0.12.0", "parking_lot 0.12.0",
"password-hash", "password-hash",
"pay_u", "pay_u",
@ -919,6 +950,7 @@ dependencies = [
"serde_json", "serde_json",
"thiserror", "thiserror",
"toml", "toml",
"tracing",
] ]
[[package]] [[package]]
@ -927,7 +959,7 @@ version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"wasm-bindgen", "wasm-bindgen",
] ]
@ -1007,7 +1039,7 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
] ]
[[package]] [[package]]
@ -1016,7 +1048,7 @@ version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"crossbeam-utils", "crossbeam-utils",
] ]
@ -1026,7 +1058,7 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"crossbeam-epoch", "crossbeam-epoch",
"crossbeam-utils", "crossbeam-utils",
] ]
@ -1038,7 +1070,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if", "cfg-if 1.0.0",
"crossbeam-utils", "crossbeam-utils",
"lazy_static", "lazy_static",
"memoffset", "memoffset",
@ -1051,7 +1083,7 @@ version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2" checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"crossbeam-utils", "crossbeam-utils",
] ]
@ -1061,7 +1093,7 @@ version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"lazy_static", "lazy_static",
] ]
@ -1135,7 +1167,7 @@ version = "4.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"num_cpus", "num_cpus",
] ]
@ -1155,7 +1187,6 @@ dependencies = [
"config", "config",
"fake", "fake",
"itertools", "itertools",
"log",
"model", "model",
"pretty_env_logger", "pretty_env_logger",
"rand", "rand",
@ -1164,6 +1195,7 @@ dependencies = [
"sqlx-core", "sqlx-core",
"testx", "testx",
"thiserror", "thiserror",
"tracing",
"uuid 0.8.2", "uuid 0.8.2",
] ]
@ -1181,13 +1213,13 @@ dependencies = [
"fake", "fake",
"fs_manager", "fs_manager",
"human-panic", "human-panic",
"log",
"model", "model",
"password-hash", "password-hash",
"pretty_env_logger",
"rand", "rand",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing",
"tracing-subscriber",
] ]
[[package]] [[package]]
@ -1255,7 +1287,7 @@ checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
dependencies = [ dependencies = [
"libc", "libc",
"redox_users", "redox_users",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -1295,7 +1327,6 @@ dependencies = [
"actix-rt", "actix-rt",
"chrono", "chrono",
"config", "config",
"log",
"model", "model",
"pretty_env_logger", "pretty_env_logger",
"sendgrid", "sendgrid",
@ -1303,6 +1334,7 @@ dependencies = [
"serde_json", "serde_json",
"thiserror", "thiserror",
"tinytemplate", "tinytemplate",
"tracing",
"uuid 0.8.2", "uuid 0.8.2",
] ]
@ -1318,7 +1350,7 @@ version = "0.8.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
] ]
[[package]] [[package]]
@ -1349,6 +1381,12 @@ version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71"
[[package]]
name = "factory"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73a3579e5ac964dd11bed8ba3932ee51b48ce652ee12e49c61a78a268bbc9b2c"
[[package]] [[package]]
name = "fake" name = "fake"
version = "2.4.3" version = "2.4.3"
@ -1377,6 +1415,49 @@ dependencies = [
"instant", "instant",
] ]
[[package]]
name = "fibers"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cce97d737d7eda3d2e8a907892b4c4fdd3857cb6f18b58047645011c5a0b46e7"
dependencies = [
"futures 0.1.31",
"mio 0.6.23",
"nbchan",
"num_cpus",
"splay_tree",
]
[[package]]
name = "fibers_rpc"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56413f3c95f2a93aaf579d1f549ac4043b8a2ed5f37e7fd5d3d32be58ef88691"
dependencies = [
"atomic_immut",
"bytecodec",
"byteorder",
"factory",
"fibers",
"fibers_tasque",
"futures 0.1.31",
"prometrics",
"slog",
"trackable 0.2.24",
]
[[package]]
name = "fibers_tasque"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "504278fcd15ae0c70acf6dcf85c8b4e16cb0c8e71f7d8a0ef8d560b116f21cac"
dependencies = [
"fibers",
"futures 0.1.31",
"lazy_static",
"tasque",
]
[[package]] [[package]]
name = "firestorm" name = "firestorm"
version = "0.5.0" version = "0.5.0"
@ -1389,7 +1470,7 @@ version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b39522e96686d38f4bc984b9198e3a0613264abaebaff2c5c918bfa6b6da09af" checksum = "b39522e96686d38f4bc984b9198e3a0613264abaebaff2c5c918bfa6b6da09af"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"crc32fast", "crc32fast",
"libc", "libc",
"miniz_oxide", "miniz_oxide",
@ -1486,15 +1567,38 @@ dependencies = [
"bytes", "bytes",
"chrono", "chrono",
"config", "config",
"log", "fibers_rpc",
"model", "model",
"pretty_env_logger", "pretty_env_logger",
"serde", "serde",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing",
"uuid 0.8.2", "uuid 0.8.2",
] ]
[[package]]
name = "fuchsia-zircon"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
dependencies = [
"bitflags",
"fuchsia-zircon-sys",
]
[[package]]
name = "fuchsia-zircon-sys"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "futures"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678"
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.21" version = "0.3.21"
@ -1620,7 +1724,7 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"js-sys", "js-sys",
"libc", "libc",
"wasi 0.10.2+wasi-snapshot-preview1", "wasi 0.10.2+wasi-snapshot-preview1",
@ -2026,7 +2130,7 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
] ]
[[package]] [[package]]
@ -2049,6 +2153,15 @@ dependencies = [
"unic-langid", "unic-langid",
] ]
[[package]]
name = "iovec"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "ipnet" name = "ipnet"
version = "2.5.0" version = "2.5.0"
@ -2130,6 +2243,16 @@ dependencies = [
"sha2", "sha2",
] ]
[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
dependencies = [
"winapi 0.2.8",
"winapi-build",
]
[[package]] [[package]]
name = "lang_provider" name = "lang_provider"
version = "0.1.0" version = "0.1.0"
@ -2138,10 +2261,10 @@ dependencies = [
"actix-rt", "actix-rt",
"config", "config",
"fluent", "fluent",
"log",
"model", "model",
"pretty_env_logger", "pretty_env_logger",
"thiserror", "thiserror",
"tracing",
"unic-langid", "unic-langid",
] ]
@ -2238,7 +2361,7 @@ version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
] ]
[[package]] [[package]]
@ -2248,7 +2371,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df1d1bc1084549d60725ccc53a2bfa07f67fe4689fda07b05a36531f2988104a" checksum = "df1d1bc1084549d60725ccc53a2bfa07f67fe4689fda07b05a36531f2988104a"
dependencies = [ dependencies = [
"nix", "nix",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -2303,7 +2426,7 @@ dependencies = [
"ctor", "ctor",
"dashmap", "dashmap",
"erased-serde", "erased-serde",
"futures", "futures 0.3.21",
"log", "log",
"messagebus_derive", "messagebus_derive",
"parking_lot 0.11.2", "parking_lot 0.11.2",
@ -2357,6 +2480,25 @@ dependencies = [
"adler", "adler",
] ]
[[package]]
name = "mio"
version = "0.6.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4"
dependencies = [
"cfg-if 0.1.10",
"fuchsia-zircon",
"fuchsia-zircon-sys",
"iovec",
"kernel32-sys",
"libc",
"log",
"miow",
"net2",
"slab",
"winapi 0.2.8",
]
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.8.3" version = "0.8.3"
@ -2369,6 +2511,18 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "miow"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d"
dependencies = [
"kernel32-sys",
"net2",
"winapi 0.2.8",
"ws2_32-sys",
]
[[package]] [[package]]
name = "model" name = "model"
version = "0.1.0" version = "0.1.0"
@ -2377,7 +2531,6 @@ dependencies = [
"chrono", "chrono",
"derive_more", "derive_more",
"fake", "fake",
"log",
"password-hash", "password-hash",
"rand", "rand",
"rand_core", "rand_core",
@ -2385,6 +2538,7 @@ dependencies = [
"sqlx", "sqlx",
"sqlx-core", "sqlx-core",
"thiserror", "thiserror",
"tracing",
"uuid 0.8.2", "uuid 0.8.2",
"validator 0.15.0", "validator 0.15.0",
] ]
@ -2407,6 +2561,23 @@ dependencies = [
"tempfile", "tempfile",
] ]
[[package]]
name = "nbchan"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b1d61edb4e941c69f2a74782b3dc4a388adeab2d8cc1fe29e8ef8d2a7f9760"
[[package]]
name = "net2"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
dependencies = [
"cfg-if 0.1.10",
"libc",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.23.1" version = "0.23.1"
@ -2415,11 +2586,17 @@ checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cc", "cc",
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"memoffset", "memoffset",
] ]
[[package]]
name = "nom"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf51a729ecf40266a2368ad335a5fdde43471f545a967109cd62146ecf8b66ff"
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.1" version = "7.1.1"
@ -2533,7 +2710,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if", "cfg-if 1.0.0",
"foreign-types", "foreign-types",
"libc", "libc",
"once_cell", "once_cell",
@ -2610,11 +2787,11 @@ dependencies = [
"chrono", "chrono",
"config", "config",
"database_manager", "database_manager",
"log",
"model", "model",
"pretty_env_logger", "pretty_env_logger",
"serde", "serde",
"thiserror", "thiserror",
"tracing",
"uuid 0.8.2", "uuid 0.8.2",
] ]
@ -2654,12 +2831,12 @@ version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"instant", "instant",
"libc", "libc",
"redox_syscall", "redox_syscall",
"smallvec", "smallvec",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -2668,7 +2845,7 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"redox_syscall", "redox_syscall",
"smallvec", "smallvec",
@ -2726,13 +2903,13 @@ dependencies = [
"config", "config",
"database_manager", "database_manager",
"derive_more", "derive_more",
"log",
"model", "model",
"parking_lot 0.12.0", "parking_lot 0.12.0",
"pay_u", "pay_u",
"pretty_env_logger", "pretty_env_logger",
"serde", "serde",
"thiserror", "thiserror",
"tracing",
"uuid 0.8.2", "uuid 0.8.2",
] ]
@ -2894,7 +3071,7 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"cpufeatures", "cpufeatures",
"opaque-debug 0.3.0", "opaque-debug 0.3.0",
"universal-hash", "universal-hash",
@ -2946,6 +3123,31 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "procinfo"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ab1427f3d2635891f842892dda177883dca0639e05fe66796a62c9d2f23b49c"
dependencies = [
"byteorder",
"libc",
"nom 2.2.1",
"rustc_version 0.2.3",
]
[[package]]
name = "prometrics"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8794f06bb51baa428e62af268ccdda6f40254f742234cdfb80cf4ad84890b38f"
dependencies = [
"atomic_immut",
"lazy_static",
"libc",
"procinfo",
"trackable 0.2.24",
]
[[package]] [[package]]
name = "quick-error" name = "quick-error"
version = "1.2.3" version = "1.2.3"
@ -3073,7 +3275,7 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [ dependencies = [
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -3129,7 +3331,7 @@ dependencies = [
"spin", "spin",
"untrusted", "untrusted",
"web-sys", "web-sys",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -3249,7 +3451,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -3287,13 +3489,13 @@ dependencies = [
"chrono", "chrono",
"config", "config",
"derive_more", "derive_more",
"log",
"model", "model",
"parking_lot 0.12.0", "parking_lot 0.12.0",
"pretty_env_logger", "pretty_env_logger",
"serde", "serde",
"sonic-channel", "sonic-channel",
"thiserror", "thiserror",
"tracing",
"uuid 0.8.2", "uuid 0.8.2",
] ]
@ -3330,7 +3532,7 @@ dependencies = [
"cookie", "cookie",
"dbg", "dbg",
"enclose", "enclose",
"futures", "futures 0.3.21",
"getrandom", "getrandom",
"gloo-file", "gloo-file",
"gloo-timers", "gloo-timers",
@ -3470,7 +3672,7 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"cpufeatures", "cpufeatures",
"digest 0.10.3", "digest 0.10.3",
] ]
@ -3496,7 +3698,7 @@ version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"cpufeatures", "cpufeatures",
"digest 0.10.3", "digest 0.10.3",
] ]
@ -3531,6 +3733,12 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32"
[[package]]
name = "slog"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06"
[[package]] [[package]]
name = "slug" name = "slug"
version = "0.1.4" version = "0.1.4"
@ -3573,6 +3781,12 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "splay_tree"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "309dee0d93c0a8f7a852cbd9a86e01e1a94781b64d98d86a191f4af7f095ecc1"
[[package]] [[package]]
name = "sqlformat" name = "sqlformat"
version = "0.1.8" version = "0.1.8"
@ -3580,7 +3794,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4b7922be017ee70900be125523f38bdd644f4f06a1b16e8fa5a8ee8c34bffd4" checksum = "b4b7922be017ee70900be125523f38bdd644f4f06a1b16e8fa5a8ee8c34bffd4"
dependencies = [ dependencies = [
"itertools", "itertools",
"nom", "nom 7.1.1",
"unicode_categories", "unicode_categories",
] ]
@ -3786,18 +4000,28 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "tasque"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38095001d1ebb11e772cf2b61b09c3aa657722088ac31474695298d227755753"
dependencies = [
"num_cpus",
"prometrics",
]
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.3.0" version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"fastrand", "fastrand",
"libc", "libc",
"redox_syscall", "redox_syscall",
"remove_dir_all", "remove_dir_all",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -3871,7 +4095,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
dependencies = [ dependencies = [
"libc", "libc",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -3886,7 +4110,7 @@ dependencies = [
"stdweb", "stdweb",
"time-macros 0.1.1", "time-macros 0.1.1",
"version_check 0.9.4", "version_check 0.9.4",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -3972,11 +4196,10 @@ dependencies = [
"config", "config",
"database_manager", "database_manager",
"derive_more", "derive_more",
"futures", "futures 0.3.21",
"futures-util", "futures-util",
"hmac", "hmac",
"jwt", "jwt",
"log",
"model", "model",
"parking_lot 0.12.0", "parking_lot 0.12.0",
"password-hash", "password-hash",
@ -3986,6 +4209,7 @@ dependencies = [
"sha2", "sha2",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing",
"uuid 0.8.2", "uuid 0.8.2",
] ]
@ -3998,7 +4222,7 @@ dependencies = [
"bytes", "bytes",
"libc", "libc",
"memchr", "memchr",
"mio", "mio 0.8.3",
"num_cpus", "num_cpus",
"once_cell", "once_cell",
"parking_lot 0.12.0", "parking_lot 0.12.0",
@ -4006,7 +4230,7 @@ dependencies = [
"signal-hook-registry", "signal-hook-registry",
"socket2", "socket2",
"tokio-macros", "tokio-macros",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -4112,7 +4336,7 @@ version = "0.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"log", "log",
"pin-project-lite", "pin-project-lite",
"tracing-attributes", "tracing-attributes",
@ -4137,6 +4361,61 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"valuable",
]
[[package]]
name = "tracing-log"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596"
dependencies = [
"ansi_term",
"sharded-slab",
"smallvec",
"thread_local",
"tracing-core",
"tracing-log",
]
[[package]]
name = "trackable"
version = "0.2.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b98abb9e7300b9ac902cc04920945a874c1973e08c310627cc4458c04b70dd32"
dependencies = [
"trackable 1.2.0",
"trackable_derive",
]
[[package]]
name = "trackable"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "017e2a1a93718e4e8386d037cfb8add78f1d690467f4350fb582f55af1203167"
dependencies = [
"trackable_derive",
]
[[package]]
name = "trackable_derive"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebeb235c5847e2f82cfe0f07eb971d1e5f6804b18dac2ae16349cc604380f82f"
dependencies = [
"quote",
"syn",
] ]
[[package]] [[package]]
@ -4392,6 +4671,12 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]] [[package]]
name = "vcpkg" name = "vcpkg"
version = "0.2.15" version = "0.2.15"
@ -4417,7 +4702,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
dependencies = [ dependencies = [
"same-file", "same-file",
"winapi", "winapi 0.3.9",
"winapi-util", "winapi-util",
] ]
@ -4449,7 +4734,7 @@ version = "0.2.80"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"serde", "serde",
"serde_json", "serde_json",
"wasm-bindgen-macro", "wasm-bindgen-macro",
@ -4476,7 +4761,7 @@ version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2" checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
@ -4598,6 +4883,12 @@ dependencies = [
"web-sys", "web-sys",
] ]
[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"
@ -4608,6 +4899,12 @@ dependencies = [
"winapi-x86_64-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu",
] ]
[[package]]
name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
[[package]] [[package]]
name = "winapi-i686-pc-windows-gnu" name = "winapi-i686-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
@ -4620,7 +4917,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [ dependencies = [
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@ -4678,7 +4975,17 @@ version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
dependencies = [ dependencies = [
"winapi", "winapi 0.3.9",
]
[[package]]
name = "ws2_32-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
dependencies = [
"winapi 0.2.8",
"winapi-build",
] ]
[[package]] [[package]]

View File

@ -7,7 +7,6 @@ edition = "2021"
model = { path = "../../shared/model" } model = { path = "../../shared/model" }
config = { path = "../../shared/config" } config = { path = "../../shared/config" }
database_manager = { path = "../database_manager" } database_manager = { path = "../database_manager" }
#token_manager = { path = "../token_manager" }
bus = { path = "../../shared/bus" } bus = { path = "../../shared/bus" }
actix = { version = "0.13", features = [] } actix = { version = "0.13", features = [] }
@ -17,5 +16,7 @@ thiserror = { version = "1.0.31" }
serde = { version = "1.0.137", features = ["derive"] } serde = { version = "1.0.137", features = ["derive"] }
log = { version = "0.4", features = [] } tracing = { version = "0.1.6" }
pretty_env_logger = { version = "0.4", features = [] } pretty_env_logger = { version = "0.4", features = [] }
fibers_rpc = { version = "0.3.4", features = [] }

View File

@ -44,11 +44,11 @@ macro_rules! query_account {
match $cart.send($msg).await { match $cart.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
$fail $fail
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
$fail $fail
} }
} }
@ -62,11 +62,11 @@ macro_rules! query_account {
match $cart.send($msg).await { match $cart.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
return Err($db_fail); return Err($db_fail);
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err($act_fail); return Err($act_fail);
} }
} }
@ -143,7 +143,7 @@ pub(crate) async fn create_account(
match msg.password.encrypt(&config.lock().web().pass_salt()) { match msg.password.encrypt(&config.lock().web().pass_salt()) {
Ok(hash) => hash, Ok(hash) => hash,
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err(Error::Hashing); return Err(Error::Hashing);
} }
} }

View File

@ -19,5 +19,5 @@ serde = { version = "1.0.137", features = ["derive"] }
uuid = { version = "0.8", features = ["serde"] } uuid = { version = "0.8", features = ["serde"] }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
log = { version = "0.4", features = [] } tracing = { version = "0.1.34" }
pretty_env_logger = { version = "0.4", features = [] } pretty_env_logger = { version = "0.4", features = [] }

View File

@ -26,11 +26,11 @@ macro_rules! query_cart {
match $cart.send($msg).await { match $cart.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
$fail $fail
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
$fail $fail
} }
} }
@ -44,11 +44,11 @@ macro_rules! query_cart {
match $cart.send($msg).await { match $cart.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
return Err($db_fail); return Err($db_fail);
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err($act_fail); return Err($act_fail);
} }
} }
@ -213,7 +213,7 @@ pub struct ModifyCart {
cart_async_handler!(ModifyCart, modify_cart, ModifyCartResult); cart_async_handler!(ModifyCart, modify_cart, ModifyCartResult);
async fn modify_cart(msg: ModifyCart, db: actix::Addr<Database>) -> Result<ModifyCartResult> { async fn modify_cart(msg: ModifyCart, db: actix::Addr<Database>) -> Result<ModifyCartResult> {
log::debug!("{:?}", msg); tracing::debug!("{:?}", msg);
let cart: model::ShoppingCart = query_db!( let cart: model::ShoppingCart = query_db!(
db, db,
database_manager::EnsureActiveShoppingCart { database_manager::EnsureActiveShoppingCart {

View File

@ -21,7 +21,7 @@ thiserror = { version = "1.0.31" }
uuid = { version = "0.8", features = ["serde"] } uuid = { version = "0.8", features = ["serde"] }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
log = { version = "0.4", features = [] } tracing = { version = "0.1.34" }
pretty_env_logger = { version = "0.4", features = [] } pretty_env_logger = { version = "0.4", features = [] }
fake = { version = "2.4.3", features = ["derive", "chrono", "http", "uuid"], optional = true } fake = { version = "2.4.3", features = ["derive", "chrono", "http", "uuid"], optional = true }

View File

@ -137,7 +137,7 @@ WHERE account_id = $1
.fetch_all(&mut *pool) .fetch_all(&mut *pool)
.await .await
{ {
log::error!("{e}"); tracing::error!("{e}");
dbg!(e); dbg!(e);
} }
} }
@ -161,7 +161,7 @@ RETURNING id, name, email, phone, street, city, country, zip, account_id, is_def
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e}"); tracing::error!("{e}");
dbg!(e); dbg!(e);
Error::CreateAccountAddress.into() Error::CreateAccountAddress.into()
}) })

View File

@ -43,7 +43,7 @@ FROM accounts
.fetch_all(pool) .fetch_all(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::Account(Error::All) super::Error::Account(Error::All)
}) })
} }
@ -83,7 +83,7 @@ RETURNING id, email, login, pass_hash, role, customer_id, state
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::Account(Error::CantCreate) super::Error::Account(Error::CantCreate)
}) })
} }
@ -143,7 +143,7 @@ RETURNING id, email, login, pass_hash, role, customer_id, state
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::Account(Error::CantUpdate) super::Error::Account(Error::CantUpdate)
}) })
} }
@ -171,7 +171,7 @@ WHERE id = $1
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::Account(Error::NotExists) super::Error::Account(Error::NotExists)
}) })
} }
@ -225,7 +225,7 @@ WHERE login = $1 AND email = $2
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::Account(Error::CantCreate) super::Error::Account(Error::CantCreate)
}) })
} }

View File

@ -45,13 +45,13 @@ macro_rules! db_async_handler {
($msg: ty, $async: ident, $res: ty, $inner_async: ident) => { ($msg: ty, $async: ident, $res: ty, $inner_async: ident) => {
async fn $inner_async(msg: $msg, pool: sqlx::PgPool) -> Result<$res> { async fn $inner_async(msg: $msg, pool: sqlx::PgPool) -> Result<$res> {
let mut t = pool.begin().await.map_err(|e| { let mut t = pool.begin().await.map_err(|e| {
log::error!("{:?}", e); tracing::error!("{:?}", e);
$crate::Error::TransactionFailed $crate::Error::TransactionFailed
})?; })?;
match $async(msg, &mut t).await { match $async(msg, &mut t).await {
Ok(res) => { Ok(res) => {
t.commit().await.map_err(|e| { t.commit().await.map_err(|e| {
log::error!("{:?}", e); tracing::error!("{:?}", e);
$crate::Error::TransactionFailed $crate::Error::TransactionFailed
})?; })?;
Ok(res) Ok(res)
@ -81,11 +81,11 @@ macro_rules! query_db {
match $db.send($msg).await { match $db.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
$fail $fail
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
$fail $fail
} }
} }
@ -99,11 +99,11 @@ macro_rules! query_db {
match $db.send($msg).await { match $db.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
return Err($db_fail); return Err($db_fail);
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err($act_fail); return Err($act_fail);
} }
} }
@ -113,11 +113,11 @@ macro_rules! query_db {
match $db.send($msg).await { match $db.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
return Err($db_fail(e.into())); return Err($db_fail(e.into()));
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err($act_fail); return Err($act_fail);
} }
} }
@ -175,7 +175,7 @@ impl Database {
pub async fn build(config: SharedAppConfig) -> Self { pub async fn build(config: SharedAppConfig) -> Self {
let url = config.lock().database().url(); let url = config.lock().database().url();
let pool = PgPool::connect(&url).await.unwrap_or_else(|e| { let pool = PgPool::connect(&url).await.unwrap_or_else(|e| {
log::error!("Failed to connect to database. {e:?}"); tracing::error!("Failed to connect to database. {e:?}");
std::process::exit(1); std::process::exit(1);
}); });
Database { pool } Database { pool }

View File

@ -37,7 +37,7 @@ ORDER BY id DESC
.fetch_all(&pool) .fetch_all(&pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
Error::All.into() Error::All.into()
}) })
} }
@ -76,7 +76,7 @@ RETURNING id, product_id, order_id, quantity, quantity_unit
.fetch_one(db) .fetch_one(db)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::OrderItem(Error::CantCreate) super::Error::OrderItem(Error::CantCreate)
}) })
} }
@ -101,7 +101,7 @@ WHERE id = $1
.fetch_one(&db) .fetch_one(&db)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
Error::NotExists.into() Error::NotExists.into()
}) })
} }
@ -127,7 +127,7 @@ ORDER BY id DESC
.fetch_all(&pool) .fetch_all(&pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
Error::OrderItems.into() Error::OrderItems.into()
}) })
} }

View File

@ -39,7 +39,7 @@ ORDER BY id DESC
.fetch_all(t) .fetch_all(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::AccountOrder(Error::All) super::Error::AccountOrder(Error::All)
}) })
} }
@ -86,7 +86,7 @@ RETURNING id, buyer_id, status, order_ext_id, service_order_id, checkout_notes,
{ {
Ok(order) => order, Ok(order) => order,
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
dbg!(e); dbg!(e);
return Err(super::Error::AccountOrder(Error::CantCreate)); return Err(super::Error::AccountOrder(Error::CantCreate));
} }
@ -104,7 +104,7 @@ RETURNING id, buyer_id, status, order_ext_id, service_order_id, checkout_notes,
.await .await
{ {
dbg!(e); dbg!(e);
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err(super::Error::AccountOrder(Error::CantCreate)); return Err(super::Error::AccountOrder(Error::CantCreate));
} }
@ -122,7 +122,7 @@ RETURNING id, buyer_id, status, order_ext_id, service_order_id, checkout_notes,
.await .await
{ {
dbg!(e); dbg!(e);
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err(super::Error::AccountOrder(Error::CantCreate)); return Err(super::Error::AccountOrder(Error::CantCreate));
}; };
@ -161,7 +161,7 @@ RETURNING id, buyer_id, status, order_ext_id, service_order_id, checkout_notes,
.fetch_one(t) .fetch_one(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::AccountOrder(Error::CantCreate) super::Error::AccountOrder(Error::CantCreate)
}) })
} }
@ -197,7 +197,7 @@ RETURNING id, buyer_id, status, order_ext_id, service_order_id, checkout_notes,
.fetch_one(t) .fetch_one(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::AccountOrder(Error::CantCreate) super::Error::AccountOrder(Error::CantCreate)
}) })
} }
@ -230,7 +230,7 @@ WHERE id = $1
.fetch_one(t) .fetch_one(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::AccountOrder(Error::NotExists) super::Error::AccountOrder(Error::NotExists)
}) })
} }
@ -266,7 +266,7 @@ RETURNING id, buyer_id, status, order_ext_id, service_order_id, checkout_notes,
.fetch_one(t) .fetch_one(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::AccountOrder(Error::NotExists) super::Error::AccountOrder(Error::NotExists)
}) })
} }

View File

@ -30,7 +30,7 @@ ORDER BY id ASC
.fetch_all(pool) .fetch_all(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Photo(Error::All) crate::Error::Photo(Error::All)
}) })
} }
@ -64,7 +64,7 @@ RETURNING id, local_path, file_name, unique_name
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Photo(Error::Create) crate::Error::Photo(Error::Create)
}) })
} }
@ -90,7 +90,7 @@ pub(crate) async fn photos_for_products(
msg: PhotosForProducts, msg: PhotosForProducts,
pool: &mut sqlx::Transaction<'_, sqlx::Postgres>, pool: &mut sqlx::Transaction<'_, sqlx::Postgres>,
) -> Result<Vec<model::ProductLinkedPhoto>> { ) -> Result<Vec<model::ProductLinkedPhoto>> {
log::debug!("all product ids {:?}", msg.product_ids); tracing::debug!("all product ids {:?}", msg.product_ids);
let res: Vec<model::ProductLinkedPhoto> = MultiLoad::new( let res: Vec<model::ProductLinkedPhoto> = MultiLoad::new(
pool, pool,
r#" r#"
@ -111,13 +111,13 @@ WHERE
msg.product_ids.len(), msg.product_ids.len(),
msg.product_ids.into_iter().map(|id| *id), msg.product_ids.into_iter().map(|id| *id),
|e| { |e| {
log::error!("{}", e); tracing::error!("{}", e);
dbg!(e); dbg!(e);
crate::Error::Photo(Error::PhotosForProducts) crate::Error::Photo(Error::PhotosForProducts)
}, },
) )
.await?; .await?;
log::debug!("product linked photos {:?}", res); tracing::debug!("product linked photos {:?}", res);
Ok(res) Ok(res)
} }

View File

@ -35,7 +35,7 @@ ORDER BY id ASC
.fetch_all(pool) .fetch_all(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
Error::All.into() Error::All.into()
}) })
} }
@ -70,7 +70,7 @@ RETURNING id, product_id, photo_id
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{:?}", e); tracing::error!("{:?}", e);
Error::Create.into() Error::Create.into()
}) })
} }
@ -103,7 +103,7 @@ RETURNING id, product_id, photo_id
.fetch_optional(pool) .fetch_optional(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{:?}", e); tracing::error!("{:?}", e);
Error::Delete.into() Error::Delete.into()
}) })
} }

View File

@ -53,7 +53,7 @@ ORDER BY id
.fetch_all(pool) .fetch_all(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Product(Error::All) crate::Error::Product(Error::All)
}) })
} }
@ -87,7 +87,7 @@ WHERE id = $1
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Product(Error::Single(msg.product_id)) crate::Error::Product(Error::Single(msg.product_id))
}) })
} }
@ -132,7 +132,7 @@ RETURNING id,
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
dbg!(e); dbg!(e);
crate::Error::Product(Error::Create) crate::Error::Product(Error::Create)
}) })
@ -185,7 +185,7 @@ RETURNING id,
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Product(Error::Update) crate::Error::Product(Error::Update)
}) })
} }
@ -224,7 +224,7 @@ RETURNING id,
.fetch_optional(pool) .fetch_optional(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Product(Error::Delete) crate::Error::Product(Error::Delete)
}) })
} }
@ -268,7 +268,7 @@ ORDER BY products.id
.fetch_all(pool) .fetch_all(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Product(Error::ShoppingCartProducts) crate::Error::Product(Error::ShoppingCartProducts)
}) })
} }
@ -309,7 +309,7 @@ WHERE
msg.product_ids.len(), msg.product_ids.len(),
msg.product_ids.into_iter().map(|id| *id), msg.product_ids.into_iter().map(|id| *id),
|e| { |e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Product(Error::FindProducts) crate::Error::Product(Error::FindProducts)
}, },
) )

View File

@ -57,7 +57,7 @@ ORDER BY shopping_cart_items.id ASC
.fetch_all(t) .fetch_all(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
dbg!(e); dbg!(e);
super::Error::ShoppingCartItem(Error::All) super::Error::ShoppingCartItem(Error::All)
}) })
@ -115,7 +115,7 @@ WHERE shopping_carts.buyer_id = $1
.fetch_all(t) .fetch_all(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::ShoppingCartItem(Error::AccountCarts) super::Error::ShoppingCartItem(Error::AccountCarts)
}) })
} }
@ -154,7 +154,7 @@ RETURNING id, product_id, shopping_cart_id, quantity, quantity_unit
.fetch_one(t) .fetch_one(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
dbg!(&e); dbg!(&e);
super::Error::ShoppingCartItem(Error::CantCreate) super::Error::ShoppingCartItem(Error::CantCreate)
}) })
@ -197,7 +197,7 @@ RETURNING id, product_id, shopping_cart_id, quantity, quantity_unit
.fetch_one(t) .fetch_one(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::ShoppingCartItem(Error::CantUpdate(msg.id)) super::Error::ShoppingCartItem(Error::CantUpdate(msg.id))
}) })
} }
@ -230,7 +230,7 @@ RETURNING id, product_id, shopping_cart_id, quantity, quantity_unit
.fetch_optional(t) .fetch_optional(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::ShoppingCartItem(Error::CantUpdate(msg.id)) super::Error::ShoppingCartItem(Error::CantUpdate(msg.id))
}) })
} }
@ -263,7 +263,7 @@ WHERE id = $1
.fetch_one(t) .fetch_one(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::ShoppingCartItem(Error::NotExists) super::Error::ShoppingCartItem(Error::NotExists)
}) })
} }
@ -305,7 +305,7 @@ ORDER BY shopping_cart_items.id ASC
.fetch_optional(t) .fetch_optional(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::ShoppingCartItem(Error::NotExists) super::Error::ShoppingCartItem(Error::NotExists)
}) })
} }
@ -344,7 +344,7 @@ ORDER BY shopping_cart_items.id ASC
.fetch_all(t) .fetch_all(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::ShoppingCartItem(Error::CartItems(shopping_cart_id)) crate::Error::ShoppingCartItem(Error::CartItems(shopping_cart_id))
}) })
} }
@ -402,7 +402,7 @@ RETURNING id, product_id, shopping_cart_id, quantity, quantity_unit
.fetch_optional(t) .fetch_optional(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::ShoppingCartItem(Error::Update { crate::Error::ShoppingCartItem(Error::Update {
shopping_cart_item_id: msg.shopping_cart_item_id, shopping_cart_item_id: msg.shopping_cart_item_id,
product_id: msg.product_id, product_id: msg.product_id,

View File

@ -37,7 +37,7 @@ FROM shopping_carts
.fetch_all(&pool) .fetch_all(&pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::ShoppingCart(Error::All) super::Error::ShoppingCart(Error::All)
}) })
} }
@ -82,7 +82,7 @@ WHERE buyer_id = $1
.fetch_all(&pool) .fetch_all(&pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::ShoppingCart(Error::AccountCarts) super::Error::ShoppingCart(Error::AccountCarts)
}) })
} }
@ -117,7 +117,7 @@ RETURNING id, buyer_id, payment_method, state, checkout_notes
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
dbg!(e); dbg!(e);
super::Error::ShoppingCart(Error::CantCreate) super::Error::ShoppingCart(Error::CantCreate)
}) })
@ -160,7 +160,7 @@ RETURNING id, buyer_id, payment_method, state, checkout_notes
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::ShoppingCart(Error::CantUpdate(msg.id)) super::Error::ShoppingCart(Error::CantUpdate(msg.id))
}) })
} }
@ -198,7 +198,7 @@ RETURNING id, buyer_id, payment_method, state, checkout_notes
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::ShoppingCart(Error::CantUpdate(msg.id)) super::Error::ShoppingCart(Error::CantUpdate(msg.id))
}) })
} }
@ -231,7 +231,7 @@ WHERE id = $1
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::ShoppingCart(Error::NotExists) super::Error::ShoppingCart(Error::NotExists)
}) })
} }
@ -266,7 +266,7 @@ RETURNING id, buyer_id, payment_method, state, checkout_notes
.fetch_optional(&mut *pool) .fetch_optional(&mut *pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::ShoppingCart(Error::NotExists) super::Error::ShoppingCart(Error::NotExists)
}) { }) {
return Ok(cart); return Ok(cart);
@ -282,7 +282,7 @@ WHERE buyer_id = $1 AND state = 'active'
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
super::Error::ShoppingCart(Error::NotExists) super::Error::ShoppingCart(Error::NotExists)
}) })
} }

View File

@ -39,7 +39,7 @@ ORDER BY id ASC
.fetch_all(pool) .fetch_all(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Stock(Error::All) crate::Error::Stock(Error::All)
}) })
} }
@ -67,7 +67,7 @@ WHERE id = $1
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
dbg!(e); dbg!(e);
crate::Error::Stock(Error::NotFound) crate::Error::Stock(Error::NotFound)
}) })
@ -100,7 +100,7 @@ RETURNING id, product_id, quantity, quantity_unit
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
dbg!(e); dbg!(e);
crate::Error::Stock(Error::Create) crate::Error::Stock(Error::Create)
}) })
@ -138,7 +138,7 @@ RETURNING id, product_id, quantity, quantity_unit
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Stock(Error::Update) crate::Error::Stock(Error::Update)
}) })
} }
@ -171,7 +171,7 @@ RETURNING id, product_id, quantity, quantity_unit
.fetch_optional(pool) .fetch_optional(pool)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Stock(Error::Delete) crate::Error::Stock(Error::Delete)
}) })
} }

View File

@ -50,7 +50,7 @@ WHERE jwt_id = $1 AND expiration_time > now()
.fetch_one(t) .fetch_one(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Token(Error::Jti) crate::Error::Token(Error::Jti)
}) })
} }
@ -88,7 +88,7 @@ RETURNING id, customer_id, role, issuer, subject, audience, expiration_time, not
.fetch_one(t) .fetch_one(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Token(Error::Create) crate::Error::Token(Error::Create)
}) })
} }
@ -134,7 +134,7 @@ RETURNING id, customer_id, role, issuer, subject, audience, expiration_time, not
.fetch_one(t) .fetch_one(t)
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
crate::Error::Token(Error::Create) crate::Error::Token(Error::Create)
}) })
} }

View File

@ -17,7 +17,7 @@ thiserror = { version = "1.0.31" }
uuid = { version = "0.8", features = ["serde"] } uuid = { version = "0.8", features = ["serde"] }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
log = { version = "0.4", features = [] } tracing = { version = "0.1.34" }
pretty_env_logger = { version = "0.4", features = [] } pretty_env_logger = { version = "0.4", features = [] }
tinytemplate = { version = "1.2.1" } tinytemplate = { version = "1.2.1" }

View File

@ -116,7 +116,7 @@ pub(crate) async fn reset_password(msg: ResetPassword, inner: Arc<Inner>) -> Res
.template .template
.render("reset-password", &context) .render("reset-password", &context)
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
Error::ResetPassTemplate Error::ResetPassTemplate
})?; })?;
@ -132,7 +132,7 @@ pub(crate) async fn reset_password(msg: ResetPassword, inner: Arc<Inner>) -> Res
) )
.await; .await;
log::debug!("{:?}", status); tracing::debug!("{:?}", status);
Ok(()) Ok(())
} }
@ -167,7 +167,7 @@ pub(crate) async fn welcome(msg: Welcome, inner: Arc<Inner>) -> Result<()> {
style: STYLE, style: STYLE,
}; };
let html = inner.template.render("welcome", &context).map_err(|e| { let html = inner.template.render("welcome", &context).map_err(|e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
Error::ResetPassTemplate Error::ResetPassTemplate
})?; })?;
@ -183,7 +183,7 @@ pub(crate) async fn welcome(msg: Welcome, inner: Arc<Inner>) -> Result<()> {
) )
.await; .await;
log::debug!("{:?}", status); tracing::debug!("{:?}", status);
Ok(()) Ok(())
} }

View File

@ -20,7 +20,9 @@ serde = { version = "1.0", features = ["derive"] }
uuid = { version = "0.8", features = ["serde"] } uuid = { version = "0.8", features = ["serde"] }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
log = { version = "0.4", features = [] } tracing = { version = "0.1.34" }
pretty_env_logger = { version = "0.4", features = [] } pretty_env_logger = { version = "0.4", features = [] }
tokio = { version = "1.18.1", features = ["full"] } tokio = { version = "1.18.1", features = ["full"] }
fibers_rpc = { version = "0.3.4", features = [] }

View File

@ -27,11 +27,11 @@ macro_rules! query_fs {
match $fs.send($msg).await { match $fs.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
$fail $fail
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
$fail $fail
} }
} }
@ -40,11 +40,11 @@ macro_rules! query_fs {
match $fs.send($msg).await { match $fs.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
panic!("{:?}", e); panic!("{:?}", e);
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
panic!("{:?}", e); panic!("{:?}", e);
} }
} }
@ -58,11 +58,11 @@ macro_rules! query_fs {
match $fs.send($msg).await { match $fs.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
return Err($db_fail); return Err($db_fail);
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err($act_fail); return Err($act_fail);
} }
} }
@ -143,7 +143,7 @@ pub(crate) async fn remove_file(msg: RemoveFile, config: SharedAppConfig) -> Res
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(()), Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(()),
Err(e) => { Err(e) => {
log::error!("{:?}", e); tracing::error!("{:?}", e);
Err(Error::CantRemove) Err(Error::CantRemove)
} }
} }
@ -172,7 +172,7 @@ pub(crate) async fn write_file(msg: WriteFile, config: SharedAppConfig) -> Resul
mut stream, mut stream,
} = msg; } = msg;
log::debug!("Writing file {:?}", file_name); tracing::debug!("Writing file {:?}", file_name);
let p = std::path::Path::new(&file_name); let p = std::path::Path::new(&file_name);
let ext = p let ext = p
@ -197,7 +197,7 @@ pub(crate) async fn write_file(msg: WriteFile, config: SharedAppConfig) -> Resul
let path = std::path::PathBuf::new() let path = std::path::PathBuf::new()
.join(&output_path) .join(&output_path)
.join(&unique_name); .join(&unique_name);
log::debug!( tracing::debug!(
"File {:?} will be written as {:?} at {:?}", "File {:?} will be written as {:?} at {:?}",
file_name, file_name,
unique_name, unique_name,
@ -206,7 +206,7 @@ pub(crate) async fn write_file(msg: WriteFile, config: SharedAppConfig) -> Resul
let mut file = match std::fs::File::create(&path) { let mut file = match std::fs::File::create(&path) {
Ok(f) => f, Ok(f) => f,
Err(e) => { Err(e) => {
log::error!("{:?}", e); tracing::error!("{:?}", e);
return Err(Error::CantWrite); return Err(Error::CantWrite);
} }
}; };
@ -215,18 +215,18 @@ pub(crate) async fn write_file(msg: WriteFile, config: SharedAppConfig) -> Resul
while let Some(b) = stream.recv().await { while let Some(b) = stream.recv().await {
counter += 1; counter += 1;
if counter % 100_000 == 0 { if counter % 100_000 == 0 {
log::debug!("Wrote {} for {:?}", counter, file_name); tracing::debug!("Wrote {} for {:?}", counter, file_name);
} }
match file.write(&b) { match file.write(&b) {
Ok(_) => {} Ok(_) => {}
Err(e) if e.kind() == std::io::ErrorKind::StorageFull => return Err(Error::NoSpace), Err(e) if e.kind() == std::io::ErrorKind::StorageFull => return Err(Error::NoSpace),
Err(e) => { Err(e) => {
log::error!("{:?}", e); tracing::error!("{:?}", e);
return Err(Error::CantWrite); return Err(Error::CantWrite);
} }
} }
} }
log::debug!("File {:?} successfully written", unique_name); tracing::debug!("File {:?} successfully written", unique_name);
Ok(WriteResult { Ok(WriteResult {
file_name: FileName::new(file_name), file_name: FileName::new(file_name),

View File

@ -12,7 +12,7 @@ actix-rt = { version = "2.7", features = [] }
thiserror = { version = "1.0.31" } thiserror = { version = "1.0.31" }
log = { version = "0.4", features = [] } tracing = { version = "0.1.34" }
pretty_env_logger = { version = "0.4", features = [] } pretty_env_logger = { version = "0.4", features = [] }
fluent = { version = "0.16.0" } fluent = { version = "0.16.0" }

View File

@ -18,5 +18,5 @@ serde = { version = "1.0.137", features = ["derive"] }
uuid = { version = "0.8", features = ["serde"] } uuid = { version = "0.8", features = ["serde"] }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
log = { version = "0.4", features = [] } tracing = { version = "0.1.34" }
pretty_env_logger = { version = "0.4", features = [] } pretty_env_logger = { version = "0.4", features = [] }

View File

@ -29,11 +29,11 @@ macro_rules! query_order {
match $order_manager.send($msg).await { match $order_manager.send($msg).await {
Ok(Ok(r)) => Ok(r), Ok(Ok(r)) => Ok(r),
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
Err($db_fail) Err($db_fail)
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
Err($act_fail) Err($act_fail)
} }
} }

View File

@ -16,7 +16,7 @@ thiserror = { version = "1.0.31" }
uuid = { version = "0.8", features = ["serde"] } uuid = { version = "0.8", features = ["serde"] }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
log = { version = "0.4", features = [] } tracing = { version = "0.1.34" }
pretty_env_logger = { version = "0.4", features = [] } pretty_env_logger = { version = "0.4", features = [] }
derive_more = { version = "0.99", features = [] } derive_more = { version = "0.99", features = [] }

View File

@ -4,7 +4,9 @@ use std::sync::Arc;
use actix::Addr; use actix::Addr;
use config::SharedAppConfig; use config::SharedAppConfig;
use database_manager::{query_db, Database}; use database_manager::{query_db, Database};
use model::{AccountId, OrderStatus, Price, ProductId, Quantity, QuantityUnit}; use model::{
AccountId, OrderId, OrderStatus, PaymentMethod, Price, ProductId, Quantity, QuantityUnit,
};
use parking_lot::Mutex; use parking_lot::Mutex;
#[macro_export] #[macro_export]
@ -30,11 +32,11 @@ macro_rules! query_pay {
match $manager.send($msg).await { match $manager.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("Payment {e}"); tracing::error!("Payment {e}");
$fail $fail
} }
Err(e) => { Err(e) => {
log::error!("Payment {e:?}"); tracing::error!("Payment {e:?}");
$fail $fail
} }
} }
@ -48,11 +50,11 @@ macro_rules! query_pay {
match $manager.send($msg).await { match $manager.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("Payment {e}"); tracing::error!("Payment {e}");
return Err($db_fail); return Err($db_fail);
} }
Err(e) => { Err(e) => {
log::error!("Payment {e:?}"); tracing::error!("Payment {e:?}");
return Err($act_fail); return Err($act_fail);
} }
} }
@ -95,7 +97,7 @@ impl PaymentManager {
) )
}; };
client.authorize().await.unwrap_or_else(|e| { client.authorize().await.unwrap_or_else(|e| {
log::error!("{}", e); tracing::error!("{}", e);
std::process::exit(1); std::process::exit(1);
}); });
Self { Self {
@ -163,9 +165,8 @@ pub struct RequestPayment {
pub buyer: Buyer, pub buyer: Buyer,
pub customer_ip: String, pub customer_ip: String,
pub buyer_id: AccountId, pub buyer_id: AccountId,
/// False if customer is allowed to be charged on site. pub payment_method: PaymentMethod,
/// Otherwise it should be true to use payment service for charging pub db_order_id: OrderId,
pub charge_client: bool,
} }
pay_async_handler!(RequestPayment, request_payment, CreatePaymentResult); pay_async_handler!(RequestPayment, request_payment, CreatePaymentResult);
@ -176,6 +177,20 @@ pub(crate) async fn request_payment(
db: Addr<Database>, db: Addr<Database>,
config: SharedAppConfig, config: SharedAppConfig,
) -> Result<CreatePaymentResult> { ) -> Result<CreatePaymentResult> {
let db_order: model::Order = query_db!(
db,
database_manager::FindOrder {
id: msg.db_order_id
},
Error::InvalidOrder
);
if msg.payment_method == PaymentMethod::PaymentOnTheSpot {
return Ok(CreatePaymentResult {
order: db_order,
items: vec![],
redirect_uri: "/pay-on-site".to_string(),
});
}
let (notify_uri, continue_uri) = { let (notify_uri, continue_uri) = {
let l = config.lock(); let l = config.lock();
let w = l.web(); let w = l.web();
@ -215,51 +230,11 @@ pub(crate) async fn request_payment(
Error::UnavailableShoppingCart Error::UnavailableShoppingCart
); );
let address: model::OrderAddress = query_db!( // let payment_required = {
db, // let l = config.lock();
database_manager::CreateOrderAddress { // l.payment().optional_payment() != false
name: address.name, // };
email: address.email, let redirect_uri = {
street: address.street,
city: address.city,
country: address.country,
zip: address.zip,
},
Error::InvalidOrderAddress
);
let db_order: model::Order = query_db!(
db,
database_manager::CreateOrder {
buyer_id: msg.buyer_id,
items: cart_products
.iter()
.map(|product| {
let (quantity, quantity_unit) =
items.get(&product.id).cloned().unwrap_or_else(|| {
(
model::Quantity::try_from(0).unwrap(),
model::QuantityUnit::Gram,
)
});
database_manager::create_order::OrderItem {
product_id: product.id,
quantity,
quantity_unit,
}
})
.collect(),
shopping_cart_id: Some(cart.id),
checkout_notes: cart.checkout_notes,
},
Error::CreateOrder
);
let payment_required = {
let l = config.lock();
l.payment().optional_payment() != false
};
let redirect_uri = if msg.charge_client || payment_required {
let pay_u::res::CreateOrder { let pay_u::res::CreateOrder {
status: _, status: _,
redirect_uri, redirect_uri,
@ -276,7 +251,7 @@ pub(crate) async fn request_payment(
format!("Order #{}", db_order.id), format!("Order #{}", db_order.id),
) )
.map_err(|e| { .map_err(|e| {
log::error!("{}", e); tracing::error!("{}", e);
Error::InvalidOrder Error::InvalidOrder
})? })?
.with_products(cart_products.into_iter().map(|p| { .with_products(cart_products.into_iter().map(|p| {
@ -295,7 +270,7 @@ pub(crate) async fn request_payment(
) )
.await .await
.map_err(|e| { .map_err(|e| {
log::error!("{}", e); tracing::error!("{}", e);
Error::PaymentFailed Error::PaymentFailed
})? })?
}; };
@ -309,8 +284,6 @@ pub(crate) async fn request_payment(
Error::CreateOrder Error::CreateOrder
); );
redirect_uri redirect_uri
} else {
String::from("/pay-on-site")
}; };
let order_items = query_db!( let order_items = query_db!(

View File

@ -15,7 +15,7 @@ thiserror = { version = "1.0.31" }
uuid = { version = "0.8", features = ["serde"] } uuid = { version = "0.8", features = ["serde"] }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
log = { version = "0.4", features = [] } tracing = { version = "0.1.34" }
pretty_env_logger = { version = "0.4", features = [] } pretty_env_logger = { version = "0.4", features = [] }
derive_more = { version = "0.99", features = [] } derive_more = { version = "0.99", features = [] }

View File

@ -102,7 +102,7 @@ pub(crate) async fn search(
match l.query(&msg.collection, &msg.lang, &msg.query) { match l.query(&msg.collection, &msg.lang, &msg.query) {
Ok(res) => Ok(Some(res)), Ok(res) => Ok(Some(res)),
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
Err(Error::QueryFailed) Err(Error::QueryFailed)
} }
} }
@ -131,7 +131,7 @@ pub(crate) async fn create_index(
match l.push(&msg.collection, &msg.lang, &msg.key, &msg.value) { match l.push(&msg.collection, &msg.lang, &msg.key, &msg.value) {
Ok(_) => Ok(Some(())), Ok(_) => Ok(Some(())),
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
Err(Error::CantCreate) Err(Error::CantCreate)
} }
} }

View File

@ -16,7 +16,7 @@ thiserror = { version = "1.0.31" }
uuid = { version = "0.8", features = ["serde"] } uuid = { version = "0.8", features = ["serde"] }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
log = { version = "0.4", features = [] } tracing = { version = "0.1.34" }
pretty_env_logger = { version = "0.4", features = [] } pretty_env_logger = { version = "0.4", features = [] }
derive_more = { version = "0.99", features = [] } derive_more = { version = "0.99", features = [] }

View File

@ -32,11 +32,11 @@ macro_rules! query_tm {
match $tm.send($msg).await { match $tm.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
$fail $fail
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
$fail $fail
} }
} }
@ -48,13 +48,13 @@ macro_rules! query_tm {
$( $(
$tm.send($msg).map_ok_or_else( $tm.send($msg).map_ok_or_else(
|e| { |e| {
log::error!("{e:?}"); tracing::error!("{e:?}");
Err($fail) Err($fail)
}, },
|res| match res { |res| match res {
Ok(rec) => Ok(rec), Ok(rec) => Ok(rec),
Err(e) => { Err(e) => {
log::error!("{e}"); tracing::error!("{e}");
Err($fail) Err($fail)
} }
}, },
@ -71,11 +71,11 @@ macro_rules! query_tm {
match $tm.send($msg).await { match $tm.send($msg).await {
Ok(Ok(r)) => r, Ok(Ok(r)) => r,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
return Err($db_fail); return Err($db_fail);
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err($act_fail); return Err($act_fail);
} }
} }
@ -240,7 +240,7 @@ pub(crate) async fn create_token(
let s = match claims.sign_with_key(&key) { let s = match claims.sign_with_key(&key) {
Ok(s) => s, Ok(s) => s,
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err(Error::SaveInternal); return Err(Error::SaveInternal);
} }
}; };
@ -320,7 +320,7 @@ pub(crate) async fn validate(
) -> Result<Token> { ) -> Result<Token> {
use jwt::VerifyWithKey; use jwt::VerifyWithKey;
log::info!("Validating token {:?}", msg.token); tracing::info!("Validating token {:?}", msg.token);
let secret = config.lock().web().jwt_secret(); let secret = config.lock().web().jwt_secret();
let key: Hmac<Sha256> = build_key(secret)?; let key: Hmac<Sha256> = build_key(secret)?;
@ -374,7 +374,7 @@ pub(crate) async fn validate(
return Err(Error::Invalid); return Err(Error::Invalid);
} }
log::info!("JWT token valid"); tracing::info!("JWT token valid");
Ok(token) Ok(token)
} }
@ -382,7 +382,7 @@ fn build_key(secret: String) -> Result<Hmac<Sha256>> {
match Hmac::new_from_slice(secret.as_bytes()) { match Hmac::new_from_slice(secret.as_bytes()) {
Ok(key) => Ok(key), Ok(key) => Ok(key),
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
Err(Error::ValidateInternal) Err(Error::ValidateInternal)
} }
} }

View File

@ -37,8 +37,6 @@ gumdrop = { version = "0.8", features = [] }
tera = { version = "1.15", features = [] } tera = { version = "1.15", features = [] }
tracing = { version = "0.1", features = [] }
uuid = { version = "0.8", features = ["serde"] } uuid = { version = "0.8", features = ["serde"] }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
@ -53,7 +51,8 @@ thiserror = { version = "1.0", features = [] }
validator = { version = "0.14", features = [] } validator = { version = "0.14", features = [] }
log = { version = "0.4", features = [] } tracing = { version = "0.1.34" }
tracing-subscriber = { version = "0.3.11" }
pretty_env_logger = { version = "0.4", features = [] } pretty_env_logger = { version = "0.4", features = [] }
dotenv = { version = "0.15", features = [] } dotenv = { version = "0.15", features = [] }

View File

@ -238,7 +238,7 @@ async fn main() -> Result<()> {
human_panic::setup_panic!(); human_panic::setup_panic!();
dotenv::dotenv().ok(); dotenv::dotenv().ok();
pretty_env_logger::init(); tracing_subscriber::fmt::init();
let opts: Opts = gumdrop::Options::parse_args_default_or_exit(); let opts: Opts = gumdrop::Options::parse_args_default_or_exit();
match opts.cmd.unwrap_or_default() { match opts.cmd.unwrap_or_default() {

View File

@ -55,7 +55,7 @@ pub async fn update_account(
let hash = match p1.encrypt(&config.lock().web().pass_salt()) { let hash = match p1.encrypt(&config.lock().web().pass_salt()) {
Ok(hash) => hash, Ok(hash) => hash,
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err(routes::Error::Admin(routes::admin::Error::HashPass)); return Err(routes::Error::Admin(routes::admin::Error::HashPass));
} }
}; };
@ -98,7 +98,7 @@ pub async fn create_account(
let hash = match payload.password.encrypt(&config.lock().web().pass_salt()) { let hash = match payload.password.encrypt(&config.lock().web().pass_salt()) {
Ok(hash) => hash, Ok(hash) => hash,
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err(routes::Error::Admin(Error::HashPass)); return Err(routes::Error::Admin(Error::HashPass));
} }
}; };

View File

@ -62,7 +62,7 @@ async fn upload_product_image(
let read = async { let read = async {
while let Some(Ok(data)) = field.next().await { while let Some(Ok(data)) = field.next().await {
if let Err(e) = tx.send(data) { if let Err(e) = tx.send(data) {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err(UploadError::InvalidName); return Err(UploadError::InvalidName);
} }
} }
@ -77,11 +77,11 @@ async fn upload_product_image(
} = match fs.send(msg).await { } = match fs.send(msg).await {
Ok(Ok(res)) => res, Ok(Ok(res)) => res,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
return Err(UploadError::FileStreamBroken); return Err(UploadError::FileStreamBroken);
} }
Err(e) => { Err(e) => {
log::error!("{e}"); tracing::error!("{e}");
return Err(UploadError::FileStreamBroken); return Err(UploadError::FileStreamBroken);
} }
}; };
@ -99,16 +99,16 @@ async fn upload_product_image(
match tokio::join!(read, write) { match tokio::join!(read, write) {
(Ok(_), Ok(_)) => {} (Ok(_), Ok(_)) => {}
(Ok(_), Err(e)) => { (Ok(_), Err(e)) => {
log::error!("Write error. {e}"); tracing::error!("Write error. {e}");
return HttpResponse::BadRequest().finish(); return HttpResponse::BadRequest().finish();
} }
(Err(e), Ok(_)) => { (Err(e), Ok(_)) => {
log::error!("Read error. {e:?}"); tracing::error!("Read error. {e:?}");
return HttpResponse::BadRequest().finish(); return HttpResponse::BadRequest().finish();
} }
(Err(read), Err(write)) => { (Err(read), Err(write)) => {
log::error!("Read error. {read:?}"); tracing::error!("Read error. {read:?}");
log::error!("Write error. {write:?}"); tracing::error!("Write error. {write:?}");
return HttpResponse::BadRequest().finish(); return HttpResponse::BadRequest().finish();
} }
} }

View File

@ -8,11 +8,11 @@ macro_rules! admin_send_db {
match $db.send($msg).await { match $db.send($msg).await {
Ok(Ok(res)) => res, Ok(Ok(res)) => res,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{}", e); tracing::error!("{}", e);
return Err(crate::routes::Error::from(e)); return Err(crate::routes::Error::from(e));
} }
Err(e) => { Err(e) => {
log::error!("{}", e); tracing::error!("{}", e);
return Err(crate::routes::Error::CriticalFailure); return Err(crate::routes::Error::CriticalFailure);
} }
} }

View File

@ -25,7 +25,7 @@ impl RequireLogin for Session {
match self.get("admin_id") { match self.get("admin_id") {
Ok(Some(id)) => Ok(id), Ok(Some(id)) => Ok(id),
_ => { _ => {
log::debug!("User is not logged as an admin"); tracing::debug!("User is not logged as an admin");
Err(Error::Unauthorized) Err(Error::Unauthorized)
} }
} }

View File

@ -198,11 +198,11 @@ async fn delete_cart_item(
{ {
Ok(Ok(_)) => Ok(HttpResponse::Ok().json(api::DeleteItemOutput { success: true })), Ok(Ok(_)) => Ok(HttpResponse::Ok().json(api::DeleteItemOutput { success: true })),
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
Ok(HttpResponse::BadRequest().json(api::DeleteItemOutput { success: false })) Ok(HttpResponse::BadRequest().json(api::DeleteItemOutput { success: false }))
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
Err(routes::Error::Public(PublicError::DatabaseConnection)) Err(routes::Error::Public(PublicError::DatabaseConnection))
} }
} }
@ -248,33 +248,15 @@ pub(crate) async fn create_order(
first_name, first_name,
last_name, last_name,
language, language,
charge_client,
currency, currency,
address, address,
payment_method,
} = payload; } = payload;
let ip = match req.peer_addr() { let ip = match req.peer_addr() {
Some(ip) => ip, Some(ip) => ip,
_ => return Err(super::Error::NoIp.into()), _ => return Err(super::Error::NoIp.into()),
}; };
let payment_manager::CreatePaymentResult { redirect_uri, .. } = query_pay!(
payment,
payment_manager::RequestPayment {
currency,
buyer: payment_manager::Buyer {
email,
phone,
first_name,
last_name,
language,
},
customer_ip: ip.to_string(),
buyer_id: account_id,
charge_client
},
routes::Error::Public(PublicError::DatabaseConnection)
);
let order_address = match address { let order_address = match address {
api::OrderAddressInput::DefaultAccountAddress => { api::OrderAddressInput::DefaultAccountAddress => {
order_manager::OrderAddressInput::DefaultAccountAddress order_manager::OrderAddressInput::DefaultAccountAddress
@ -310,6 +292,25 @@ pub(crate) async fn create_order(
PublicError::DatabaseConnection PublicError::DatabaseConnection
)?; )?;
let payment_manager::CreatePaymentResult { redirect_uri, .. } = query_pay!(
payment,
payment_manager::RequestPayment {
currency,
buyer: payment_manager::Buyer {
email,
phone,
first_name,
last_name,
language,
},
customer_ip: ip.to_string(),
buyer_id: account_id,
payment_method,
db_order_id: order.id
},
routes::Error::Public(PublicError::DatabaseConnection)
);
Ok(Json(api::PlaceOrderResult { Ok(Json(api::PlaceOrderResult {
redirect_uri, redirect_uri,
order_id: order.id, order_id: order.id,

View File

@ -38,11 +38,11 @@ async fn search(
.collect(), .collect(),
Ok(Ok(None)) => return Ok(Json(vec![])), Ok(Ok(None)) => return Ok(Json(vec![])),
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}"); tracing::error!("{e}");
return Ok(Json(vec![])); return Ok(Json(vec![]));
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Ok(Json(vec![])); return Ok(Json(vec![]));
} }
}; };
@ -138,7 +138,7 @@ pub async fn create_account(
match payload.password.encrypt(&config.lock().web().pass_salt()) { match payload.password.encrypt(&config.lock().web().pass_salt()) {
Ok(hash) => hash, Ok(hash) => hash,
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
return Err(routes::Error::Admin(routes::admin::Error::HashPass)); return Err(routes::Error::Admin(routes::admin::Error::HashPass));
} }
} }

View File

@ -14,11 +14,11 @@ macro_rules! public_send_db {
return match $db.send($msg).await { return match $db.send($msg).await {
Ok(Ok(res)) => Ok(HttpResponse::Ok().json(res)), Ok(Ok(res)) => Ok(HttpResponse::Ok().json(res)),
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{}", e); tracing::error!("{}", e);
Err(crate::routes::Error::Public(PublicError::Database(e))) Err(crate::routes::Error::Public(PublicError::Database(e)))
} }
Err(e) => { Err(e) => {
log::error!("{}", e); tracing::error!("{}", e);
Err(crate::routes::Error::Public( Err(crate::routes::Error::Public(
PublicError::DatabaseConnection, PublicError::DatabaseConnection,
)) ))
@ -31,11 +31,11 @@ macro_rules! public_send_db {
match $db.send($msg).await { match $db.send($msg).await {
Ok(Ok(res)) => res, Ok(Ok(res)) => res,
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{}", e); tracing::error!("{}", e);
return Err(crate::routes::Error::Public(PublicError::Database(e))); return Err(crate::routes::Error::Public(PublicError::Database(e)));
} }
Err(e) => { Err(e) => {
log::error!("{}", e); tracing::error!("{}", e);
return Err(crate::routes::Error::Public( return Err(crate::routes::Error::Public(
PublicError::DatabaseConnection, PublicError::DatabaseConnection,
)); ));

View File

@ -22,8 +22,8 @@ rand = { version = "0.8.5" }
dotenv = { version = "0.15", features = [] } dotenv = { version = "0.15", features = [] }
log = { version = "0.4", features = [] } tracing = { version = "0.1.34" }
pretty_env_logger = { version = "0.4", features = [] } tracing-subscriber = { version = "0.3.11" }
password-hash = { version = "0.4", features = ["alloc"] } password-hash = { version = "0.4", features = ["alloc"] }

View File

@ -24,10 +24,10 @@ pub(crate) async fn create_accounts(
match db.send(msg).await { match db.send(msg).await {
Ok(Ok(account)) => accounts.push(account), Ok(Ok(account)) => accounts.push(account),
Ok(Err(e)) => { Ok(Err(e)) => {
log::error!("{e}") tracing::error!("{e}")
} }
Err(e) => { Err(e) => {
log::error!("{e}") tracing::error!("{e}")
} }
} }
} }

View File

@ -44,7 +44,7 @@ async fn main() {
dotenv::dotenv().ok(); dotenv::dotenv().ok();
std::env::set_var("RUST_LOG", "DEBUG"); std::env::set_var("RUST_LOG", "DEBUG");
pretty_env_logger::init(); tracing_subscriber::fmt::init();
let db_seed = Arc::new(Mutex::new(DbSeed::default())); let db_seed = Arc::new(Mutex::new(DbSeed::default()));
let config = config::default_load(&Opts); let config = config::default_load(&Opts);

View File

@ -56,7 +56,7 @@ async fn create_photo(
}; };
let (_, res) = tokio::join!(read, write); let (_, res) = tokio::join!(read, write);
log::debug!("Photo {:?} done", file); tracing::debug!("Photo {:?} done", file);
res res
} }
@ -65,7 +65,7 @@ pub(crate) async fn create_photos(
seed: SharedState, seed: SharedState,
config: SharedAppConfig, config: SharedAppConfig,
) -> Result<()> { ) -> Result<()> {
log::debug!("Creating photos"); tracing::debug!("Creating photos");
let photos: Vec<model::Photo> = query_db!(db, database_manager::AllPhotos, default vec![]); let photos: Vec<model::Photo> = query_db!(db, database_manager::AllPhotos, default vec![]);
if photos.len() >= 10 { if photos.len() >= 10 {
seed.lock().unwrap().photos = photos; seed.lock().unwrap().photos = photos;

View File

@ -54,7 +54,7 @@ pub(crate) async fn create_products(
seed.lock().unwrap().products = products; seed.lock().unwrap().products = products;
} }
if let Err(e) = create_product_photos(db.clone(), seed.clone(), config.clone()).await { if let Err(e) = create_product_photos(db.clone(), seed.clone(), config.clone()).await {
log::error!("{e:?}"); tracing::error!("{e:?}");
} }
return Ok(()); return Ok(());
} }

View File

@ -16,6 +16,6 @@ pay_u = { version = '0.1', features = ["single-client"] }
actix-web = { version = "4.0", features = [] } actix-web = { version = "4.0", features = [] }
log = { version = "0.4" } tracing = { version = "0.1.34" }
thiserror = { version = "1.0" } thiserror = { version = "1.0" }

View File

@ -530,7 +530,7 @@ fn load(config_path: &str, opts: &impl UpdateConfig) -> SharedAppConfig {
std::process::exit(1); std::process::exit(1);
} }
Err(e) => { Err(e) => {
log::error!("{e:?}"); tracing::error!("{e:?}");
panic!("Config file was not found at path {config_path:?}") panic!("Config file was not found at path {config_path:?}")
} }
} }

View File

@ -29,4 +29,4 @@ password-hash = { version = "0.4", features = ["alloc"] }
argon2 = { version = "0.4", features = ["parallel", "password-hash"] } argon2 = { version = "0.4", features = ["parallel", "password-hash"] }
rand_core = { version = "0.6", features = ["std"] } rand_core = { version = "0.6", features = ["std"] }
log = { version = "0.4.17" } tracing = { version = "0.1.34" }

View File

@ -444,12 +444,10 @@ pub struct CreateOrderInput {
pub last_name: String, pub last_name: String,
/// Required customer language /// Required customer language
pub language: String, pub language: String,
/// False if customer is allowed to be charged on site.
/// Otherwise it should be true to use payment service for charging
pub charge_client: bool,
/// User currency /// User currency
pub currency: String, pub currency: String,
pub address: OrderAddressInput, pub address: OrderAddressInput,
pub payment_method: PaymentMethod,
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]

View File

@ -9,7 +9,7 @@ pub trait Encrypt {
impl Encrypt for crate::Password { impl Encrypt for crate::Password {
fn encrypt(&self, salt: &SaltString) -> password_hash::Result<String> { fn encrypt(&self, salt: &SaltString) -> password_hash::Result<String> {
log::debug!("Hashing password {:?}", self); tracing::debug!("Hashing password {:?}", self);
Ok( Ok(
Argon2::new(Algorithm::Argon2id, Version::V0x13, Params::default()) Argon2::new(Algorithm::Argon2id, Version::V0x13, Params::default())
.hash_password(self.as_bytes(), &salt)? .hash_password(self.as_bytes(), &salt)?
@ -18,7 +18,7 @@ impl Encrypt for crate::Password {
} }
fn validate(&self, pass_hash: &crate::PassHash) -> password_hash::Result<()> { fn validate(&self, pass_hash: &crate::PassHash) -> password_hash::Result<()> {
log::debug!("Validating password {:?} {:?}", self, pass_hash); tracing::debug!("Validating password {:?} {:?}", self, pass_hash);
Argon2::default().verify_password( Argon2::default().verify_password(
self.as_bytes(), self.as_bytes(),

View File

@ -1,5 +1,5 @@
use model::api::OrderAddressInput; use model::api::OrderAddressInput;
use model::{AccessTokenString, AddressId, RefreshTokenString}; use model::{AccessTokenString, AddressId, PaymentMethod, RefreshTokenString};
use seed::fetch::{Header, Method, Request}; use seed::fetch::{Header, Method, Request};
use crate::api::perform; use crate::api::perform;
@ -126,7 +126,7 @@ pub async fn place_account_order(
first_name: String, first_name: String,
last_name: String, last_name: String,
language: String, language: String,
charge_client: bool, payment_method: PaymentMethod,
currency: String, currency: String,
address_id: Option<AddressId>, address_id: Option<AddressId>,
) -> NetRes<model::api::PlaceOrderResult> { ) -> NetRes<model::api::PlaceOrderResult> {
@ -136,7 +136,7 @@ pub async fn place_account_order(
first_name, first_name,
last_name, last_name,
language, language,
charge_client, payment_method,
currency, currency,
address: address_id address: address_id
.map(OrderAddressInput::AccountAddress) .map(OrderAddressInput::AccountAddress)

View File

@ -1,6 +1,6 @@
use std::str::FromStr; use std::str::FromStr;
use model::AccessTokenString; use model::{AccessTokenString, PaymentMethod};
use seed::prelude::*; use seed::prelude::*;
use seed::*; use seed::*;
@ -109,7 +109,10 @@ pub fn update(msg: CheckoutMsg, model: &mut crate::Model, orders: &mut impl Orde
let first_name: String = String::from(page.address.first_name.as_str()); let first_name: String = String::from(page.address.first_name.as_str());
let last_name: String = String::from(page.address.last_name.as_str()); let last_name: String = String::from(page.address.last_name.as_str());
let language: String = model.i18n.current_language().to_string(); let language: String = model.i18n.current_language().to_string();
let charge_client = false; let payment_method = model
.cart
.payment_method
.unwrap_or(PaymentMethod::PaymentOnTheSpot);
let currency = model.config.currency.name.to_string(); let currency = model.config.currency.name.to_string();
let address_id = None; let address_id = None;
@ -121,7 +124,7 @@ pub fn update(msg: CheckoutMsg, model: &mut crate::Model, orders: &mut impl Orde
first_name, first_name,
last_name, last_name,
language, language,
charge_client, payment_method,
currency, currency,
address_id, address_id,
) )