initial port to tracing
This commit is contained in:
parent
ea75e1e3ee
commit
a3b757abad
288
Cargo.lock
generated
288
Cargo.lock
generated
@ -182,7 +182,7 @@ checksum = "c697a62a2f51c5c26af6b1dded0622f15bec690da191615947e0c1b2b7b75198"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"chrono",
|
||||
"futures 0.3.13",
|
||||
"futures 0.3.14",
|
||||
"pin-project 0.4.28",
|
||||
"slog",
|
||||
]
|
||||
@ -307,7 +307,7 @@ dependencies = [
|
||||
"actix-service",
|
||||
"actix-web",
|
||||
"derive_more",
|
||||
"futures 0.3.13",
|
||||
"futures 0.3.14",
|
||||
"mime_guess",
|
||||
"path-slash",
|
||||
]
|
||||
@ -422,6 +422,15 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[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]]
|
||||
name = "anyhow"
|
||||
version = "1.0.40"
|
||||
@ -829,7 +838,7 @@ version = "2.33.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"ansi_term 0.11.0",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"strsim",
|
||||
@ -920,9 +929,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775"
|
||||
checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-utils",
|
||||
@ -1038,27 +1047,6 @@ dependencies = [
|
||||
"generic-array 0.14.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-next"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"dirs-sys-next",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys-next"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "discard"
|
||||
version = "1.0.4"
|
||||
@ -1242,9 +1230,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "flume"
|
||||
version = "0.10.2"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "531a685ab99b8f60a271b44d5dd1a76e55124a8c9fa0407b7a8e9cd172d5b588"
|
||||
checksum = "859e0fa5d4a9b5f73671712ce3e400fa17133c9b9faac607ada8e469f0b6be6c"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
@ -1305,9 +1293,9 @@ checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678"
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.13"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1"
|
||||
checksum = "a9d5813545e459ad3ca1bff9915e9ad7f1a47dc6a91b627ce321d5863b7dd253"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
@ -1320,9 +1308,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.13"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939"
|
||||
checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
@ -1330,9 +1318,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.13"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94"
|
||||
checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815"
|
||||
|
||||
[[package]]
|
||||
name = "futures-cpupool"
|
||||
@ -1346,9 +1334,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.13"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "891a4b7b96d84d5940084b2a37632dd65deeae662c114ceaa2c879629c9c0ad1"
|
||||
checksum = "10f6cb7042eda00f0049b1d2080aa4b93442997ee507eb3828e8bd7577f94c9d"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
@ -1357,15 +1345,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.13"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59"
|
||||
checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.13"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea405816a5139fb39af82c2beb921d52143f556038378d6db21183a5c37fbfb7"
|
||||
checksum = "668c6733a182cd7deb4f1de7ba3bf2120823835b3bcfbeacf7d2c4a773c1bb8b"
|
||||
dependencies = [
|
||||
"proc-macro-hack",
|
||||
"proc-macro2 1.0.26",
|
||||
@ -1375,21 +1363,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.13"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3"
|
||||
checksum = "5c5629433c555de3d82861a7a4e3794a4c40040390907cfbfd7143a92a426c23"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.13"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80"
|
||||
checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.13"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1"
|
||||
checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
@ -1433,6 +1421,16 @@ dependencies = [
|
||||
"version_check 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gethostname"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e692e296bfac1d2533ef168d0b60ff5897b8b70a4009276834014dd8924cc028"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.16"
|
||||
@ -1896,6 +1894,15 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
|
||||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
version = "0.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1"
|
||||
dependencies = [
|
||||
"regex-automata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.8"
|
||||
@ -2397,12 +2404,14 @@ dependencies = [
|
||||
"rand 0.8.3",
|
||||
"rpassword",
|
||||
"serde",
|
||||
"slog",
|
||||
"slog-async",
|
||||
"slog-term",
|
||||
"sqlx",
|
||||
"tera",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
"tracing-actix-web",
|
||||
"tracing-bunyan-formatter",
|
||||
"tracing-log",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2688,16 +2697,6 @@ dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
|
||||
dependencies = [
|
||||
"getrandom 0.2.2",
|
||||
"redox_syscall",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.4.5"
|
||||
@ -2709,6 +2708,16 @@ dependencies = [
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.23"
|
||||
@ -2793,12 +2802,6 @@ dependencies = [
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.5"
|
||||
@ -2834,9 +2837,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "sct"
|
||||
version = "0.6.0"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c"
|
||||
checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
@ -2964,6 +2967,15 @@ dependencies = [
|
||||
"opaque-debug 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.3.0"
|
||||
@ -2985,31 +2997,6 @@ version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06"
|
||||
|
||||
[[package]]
|
||||
name = "slog-async"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c60813879f820c85dbc4eabf3269befe374591289019775898d56a81a804fbdc"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"slog",
|
||||
"take_mut",
|
||||
"thread_local",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slog-term"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95c1e7e5aab61ced6006149ea772770b84a0d16ce0f7885def313e4829946d76"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"chrono",
|
||||
"slog",
|
||||
"term",
|
||||
"thread_local",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slug"
|
||||
version = "0.1.4"
|
||||
@ -3148,7 +3135,7 @@ dependencies = [
|
||||
"cargo_metadata",
|
||||
"dotenv",
|
||||
"either",
|
||||
"futures 0.3.13",
|
||||
"futures 0.3.14",
|
||||
"heck",
|
||||
"hex",
|
||||
"lazy_static",
|
||||
@ -3291,12 +3278,6 @@ dependencies = [
|
||||
"unicode-xid 0.2.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "take_mut"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60"
|
||||
|
||||
[[package]]
|
||||
name = "tap"
|
||||
version = "1.0.1"
|
||||
@ -3335,17 +3316,6 @@ dependencies = [
|
||||
"unic-segment",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "term"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f"
|
||||
dependencies = [
|
||||
"dirs-next",
|
||||
"rustversion",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
@ -3550,9 +3520,51 @@ dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"log",
|
||||
"pin-project-lite 0.2.6",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-actix-web"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc36fc2f840643e49d220d07cd7ca81bc31c7f6df25f164d4257971533dab354"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"futures 0.3.14",
|
||||
"tracing",
|
||||
"tracing-futures",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.26",
|
||||
"quote 1.0.9",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-bunyan-formatter"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05e6b1b6c038da11d8d704f93b3974b0394824cdcc8c818c48255183cf315fd5"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"gethostname",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.17"
|
||||
@ -3572,6 +3584,49 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-serde"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "705096c6f83bf68ea5d357a6aa01829ddbdac531b357b45abeca842938085baa"
|
||||
dependencies = [
|
||||
"ansi_term 0.12.1",
|
||||
"chrono",
|
||||
"lazy_static",
|
||||
"matchers",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
"tracing-serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "trust-dns-proto"
|
||||
version = "0.19.7"
|
||||
@ -3581,7 +3636,7 @@ dependencies = [
|
||||
"async-trait",
|
||||
"cfg-if 1.0.0",
|
||||
"enum-as-inner",
|
||||
"futures 0.3.13",
|
||||
"futures 0.3.14",
|
||||
"idna",
|
||||
"lazy_static",
|
||||
"log",
|
||||
@ -3599,7 +3654,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "710f593b371175db53a26d0b38ed2978fafb9e9e8d3868b1acd753ea18df0ceb"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"futures 0.3.13",
|
||||
"futures 0.3.14",
|
||||
"ipconfig",
|
||||
"lazy_static",
|
||||
"log",
|
||||
@ -3810,6 +3865,15 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
|
||||
dependencies = [
|
||||
"getrandom 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.11"
|
||||
|
@ -25,9 +25,11 @@ dotenv = "0.15.0"
|
||||
actix-identity = "0.3"
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
argonautica = "0.2"
|
||||
slog = { version = "2", features = ["max_level_trace", "release_max_level_info"] }
|
||||
slog-term = "2"
|
||||
slog-async = "2"
|
||||
tracing = { version = "0.1", features = ["log"] }
|
||||
tracing-bunyan-formatter = "0.2.0"
|
||||
tracing-subscriber = { version = "0.2.12", features = ["registry", "env-filter"] }
|
||||
tracing-log = "0.1"
|
||||
tracing-actix-web = "0.2.1"
|
||||
qrcode = "0.12"
|
||||
image = "0.23"
|
||||
rand="0.8"
|
||||
|
@ -12,7 +12,7 @@ use std::{
|
||||
|
||||
use pslink::{models::NewUser, models::User, ServerConfig, ServerError};
|
||||
|
||||
use slog::{Drain, Logger};
|
||||
use tracing::{error, info, trace, warn};
|
||||
|
||||
static MIGRATOR: Migrator = sqlx::migrate!();
|
||||
|
||||
@ -122,7 +122,7 @@ fn generate_cli() -> App<'static, 'static> {
|
||||
)
|
||||
}
|
||||
|
||||
async fn parse_args_to_config(config: ArgMatches<'_>, log: Logger) -> ServerConfig {
|
||||
async fn parse_args_to_config(config: ArgMatches<'_>) -> ServerConfig {
|
||||
let secret = config
|
||||
.value_of("secret")
|
||||
.expect("Failed to read the secret")
|
||||
@ -132,20 +132,11 @@ async fn parse_args_to_config(config: ArgMatches<'_>, log: Logger) -> ServerConf
|
||||
use rand::{thread_rng, Rng};
|
||||
|
||||
if secret.is_empty() {
|
||||
slog_warn!(
|
||||
log,
|
||||
"No secret was found! Use the environment variable PSLINK_SECRET to set one."
|
||||
);
|
||||
slog_warn!(
|
||||
log,
|
||||
"If you change the secret all passwords will be invalid"
|
||||
);
|
||||
slog_warn!(log, "Using an auto generated one for this run.");
|
||||
warn!("No secret was found! Use the environment variable PSLINK_SECRET to set one.");
|
||||
warn!("If you change the secret all passwords will be invalid");
|
||||
warn!("Using an auto generated one for this run.");
|
||||
} else {
|
||||
slog_warn!(
|
||||
log,
|
||||
"The provided secret was too short. Using an autogenerated one."
|
||||
)
|
||||
warn!("The provided secret was too short. Using an autogenerated one.")
|
||||
}
|
||||
|
||||
thread_rng()
|
||||
@ -195,8 +186,6 @@ async fn parse_args_to_config(config: ArgMatches<'_>, log: Logger) -> ServerConf
|
||||
.parse::<pslink::Protocol>()
|
||||
.expect("Failed to parse the protocol");
|
||||
|
||||
let log = log.new(slog_o!("host" => public_url.clone()));
|
||||
|
||||
crate::ServerConfig {
|
||||
secret,
|
||||
db,
|
||||
@ -205,7 +194,6 @@ async fn parse_args_to_config(config: ArgMatches<'_>, log: Logger) -> ServerConf
|
||||
internal_ip,
|
||||
port,
|
||||
protocol,
|
||||
log,
|
||||
empty_forward_url,
|
||||
brand_name,
|
||||
}
|
||||
@ -214,16 +202,9 @@ async fn parse_args_to_config(config: ArgMatches<'_>, log: Logger) -> ServerConf
|
||||
pub(crate) async fn setup() -> Result<Option<crate::ServerConfig>, ServerError> {
|
||||
dotenv().ok();
|
||||
|
||||
// initiallize the logger
|
||||
let decorator = slog_term::TermDecorator::new().build();
|
||||
let drain = slog_term::FullFormat::new(decorator).build().fuse();
|
||||
let drain = slog_async::Async::new(drain).build().fuse();
|
||||
|
||||
let log = slog::Logger::root(drain, slog_o!("name" => "Pslink"));
|
||||
|
||||
// Print launch info
|
||||
slog_info!(log, "Launching Pslink a 'Private short link generator'");
|
||||
slog_trace!(log, "logging initialized");
|
||||
info!("Launching Pslink a 'Private short link generator'");
|
||||
trace!("logging initialized");
|
||||
|
||||
let app = generate_cli();
|
||||
|
||||
@ -239,7 +220,7 @@ pub(crate) async fn setup() -> Result<Option<crate::ServerConfig>, ServerError>
|
||||
.parse::<PathBuf>()
|
||||
.expect("Failed to parse Database path.");
|
||||
if !db.exists() {
|
||||
slog_trace!(log, "No database file found {}", db.display());
|
||||
trace!("No database file found {}", db.display());
|
||||
if config.subcommand_matches("migrate-database").is_none() {
|
||||
let msg = format!(
|
||||
concat!(
|
||||
@ -249,17 +230,17 @@ pub(crate) async fn setup() -> Result<Option<crate::ServerConfig>, ServerError>
|
||||
),
|
||||
db.display()
|
||||
);
|
||||
slog_error!(log, "{}", msg);
|
||||
error!("{}", msg);
|
||||
eprintln!("{}", msg);
|
||||
return Ok(None);
|
||||
}
|
||||
slog_trace!(log, "Creating database: {}", db.display());
|
||||
trace!("Creating database: {}", db.display());
|
||||
|
||||
// create an empty database file. The if above makes sure that this file does not exist.
|
||||
File::create(db)?;
|
||||
};
|
||||
|
||||
let server_config: crate::ServerConfig = parse_args_to_config(config.clone(), log).await;
|
||||
let server_config: crate::ServerConfig = parse_args_to_config(config.clone()).await;
|
||||
|
||||
if let Some(_migrate_config) = config.subcommand_matches("generate-env") {
|
||||
return match generate_env_file(&server_config) {
|
||||
@ -284,21 +265,15 @@ pub(crate) async fn setup() -> Result<Option<crate::ServerConfig>, ServerError>
|
||||
let num_users = User::count_admins(&server_config).await?;
|
||||
|
||||
if num_users.number < 1 {
|
||||
slog_warn!(
|
||||
&server_config.log,
|
||||
concat!(
|
||||
"No admin user created you will not be",
|
||||
" able to do anything as the service is invite only.",
|
||||
" Create a user with `pslink create-admin`"
|
||||
)
|
||||
);
|
||||
warn!(concat!(
|
||||
"No admin user created you will not be",
|
||||
" able to do anything as the service is invite only.",
|
||||
" Create a user with `pslink create-admin`"
|
||||
));
|
||||
} else {
|
||||
slog_trace!(&server_config.log, "At least one admin user is found.");
|
||||
trace!("At least one admin user is found.");
|
||||
}
|
||||
slog_trace!(
|
||||
&server_config.log,
|
||||
"Initialization finished starting the service."
|
||||
);
|
||||
trace!("Initialization finished starting the service.");
|
||||
Ok(Some(server_config))
|
||||
} else {
|
||||
println!("{}", config.usage());
|
||||
@ -308,7 +283,7 @@ pub(crate) async fn setup() -> Result<Option<crate::ServerConfig>, ServerError>
|
||||
|
||||
/// Interactively create a new admin user.
|
||||
async fn create_admin(config: &ServerConfig) -> Result<(), ServerError> {
|
||||
slog_info!(&config.log, "Creating an admin user.");
|
||||
info!("Creating an admin user.");
|
||||
let sin = io::stdin();
|
||||
|
||||
// wait for logging:
|
||||
@ -325,11 +300,9 @@ async fn create_admin(config: &ServerConfig) -> Result<(), ServerError> {
|
||||
print!("Please enter the password for {}: ", new_username);
|
||||
io::stdout().flush().unwrap();
|
||||
let password = rpassword::read_password().unwrap();
|
||||
slog_info!(
|
||||
&config.log,
|
||||
info!(
|
||||
"Creating {} ({}) with given password ",
|
||||
&new_username,
|
||||
&new_email
|
||||
&new_username, &new_email
|
||||
);
|
||||
|
||||
let new_admin = NewUser::new(new_username.clone(), new_email.clone(), &password, config)?;
|
||||
@ -338,14 +311,13 @@ async fn create_admin(config: &ServerConfig) -> Result<(), ServerError> {
|
||||
let created_user = User::get_user_by_name(&new_username, config).await?;
|
||||
created_user.toggle_admin(config).await?;
|
||||
|
||||
slog_info!(&config.log, "Admin user created: {}", new_username);
|
||||
info!("Admin user created: {}", new_username);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn apply_migrations(config: &ServerConfig) -> Result<(), ServerError> {
|
||||
slog_info!(
|
||||
config.log,
|
||||
info!(
|
||||
"Creating a database file and running the migrations in the file {}:",
|
||||
&config.db.display()
|
||||
);
|
||||
@ -355,22 +327,13 @@ async fn apply_migrations(config: &ServerConfig) -> Result<(), ServerError> {
|
||||
|
||||
fn generate_env_file(server_config: &ServerConfig) -> Result<(), ServerError> {
|
||||
if std::path::Path::new(".env").exists() {
|
||||
slog_error!(
|
||||
server_config.log,
|
||||
"ERROR: There already is a .env file - ABORT!"
|
||||
)
|
||||
error!("ERROR: There already is a .env file - ABORT!")
|
||||
} else {
|
||||
slog_info!(
|
||||
server_config.log,
|
||||
"Creating a .env file with default options"
|
||||
);
|
||||
slog_info!(
|
||||
server_config.log,
|
||||
concat!(
|
||||
"The SECRET_KEY variable is used for password encryption.",
|
||||
"If it is changed all existing passwords are invalid."
|
||||
)
|
||||
);
|
||||
info!("Creating a .env file with default options");
|
||||
info!(concat!(
|
||||
"The SECRET_KEY variable is used for password encryption.",
|
||||
"If it is changed all existing passwords are invalid."
|
||||
));
|
||||
let mut file = std::fs::File::create(".env")?;
|
||||
|
||||
let conf_file_content = server_config.to_env_strings();
|
||||
@ -379,7 +342,7 @@ fn generate_env_file(server_config: &ServerConfig) -> Result<(), ServerError> {
|
||||
file.write_all(l.as_bytes())
|
||||
.expect("failed to write .env file")
|
||||
});
|
||||
slog_info!(server_config.log, "Successfully created the env file!")
|
||||
info!("Successfully created the env file!")
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,19 +1,4 @@
|
||||
extern crate sqlx;
|
||||
#[allow(unused_imports)]
|
||||
#[macro_use(
|
||||
slog_o,
|
||||
slog_trace,
|
||||
slog_info,
|
||||
slog_warn,
|
||||
slog_error,
|
||||
slog_log,
|
||||
slog_record,
|
||||
slog_record_static,
|
||||
slog_b,
|
||||
slog_kv
|
||||
)]
|
||||
extern crate slog;
|
||||
extern crate slog_async;
|
||||
|
||||
mod cli;
|
||||
mod views;
|
||||
@ -26,6 +11,33 @@ use tera::Tera;
|
||||
|
||||
use pslink::{ServerConfig, ServerError};
|
||||
|
||||
use tracing::instrument;
|
||||
use tracing::{error, info, trace};
|
||||
use tracing::{subscriber::set_global_default, Subscriber};
|
||||
use tracing_actix_web::TracingLogger;
|
||||
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};
|
||||
use tracing_log::LogTracer;
|
||||
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
|
||||
|
||||
/// Compose multiple layers into a `tracing`'s subscriber.
|
||||
pub fn get_subscriber(name: String, env_filter: String) -> impl Subscriber + Send + Sync {
|
||||
let env_filter =
|
||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(env_filter));
|
||||
let formatting_layer = BunyanFormattingLayer::new(name, std::io::stdout);
|
||||
Registry::default()
|
||||
.with(env_filter)
|
||||
.with(JsonStorageLayer)
|
||||
.with(formatting_layer)
|
||||
}
|
||||
|
||||
/// Register a subscriber as global default to process span data.
|
||||
///
|
||||
/// It should only be called once!
|
||||
pub fn init_subscriber(subscriber: impl Subscriber + Send + Sync) {
|
||||
LogTracer::init().expect("Failed to set logger");
|
||||
set_global_default(subscriber).expect("Failed to set subscriber");
|
||||
}
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/generated.rs"));
|
||||
|
||||
static_loader! {
|
||||
@ -35,8 +47,10 @@ static_loader! {
|
||||
};
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
fn build_tera() -> Result<Tera> {
|
||||
let mut tera = Tera::default();
|
||||
tracing::info!("Tracing activated!");
|
||||
|
||||
// Add translation support
|
||||
tera.register_function("fluent", FluentLoader::new(&*LOCALES));
|
||||
@ -86,29 +100,22 @@ fn build_tera() -> Result<Tera> {
|
||||
#[allow(clippy::future_not_send, clippy::too_many_lines)]
|
||||
async fn webservice(server_config: ServerConfig) -> Result<()> {
|
||||
let host_port = format!("{}:{}", &server_config.internal_ip, &server_config.port);
|
||||
let cfg = server_config.clone();
|
||||
slog_info!(
|
||||
cfg.log,
|
||||
info!(
|
||||
"Running on: {}://{}/admin/login/",
|
||||
&server_config.protocol,
|
||||
host_port
|
||||
&server_config.protocol, host_port
|
||||
);
|
||||
slog_info!(
|
||||
cfg.log,
|
||||
info!(
|
||||
"If the public url is set up correctly it should be accessible via: {}://{}/admin/login/",
|
||||
&server_config.protocol,
|
||||
&server_config.public_url
|
||||
&server_config.protocol, &server_config.public_url
|
||||
);
|
||||
let tera = build_tera()?;
|
||||
slog_trace!(cfg.log, "The tera templates are ready");
|
||||
trace!("The tera templates are ready");
|
||||
|
||||
HttpServer::new(move || {
|
||||
let generated = generate();
|
||||
App::new()
|
||||
.data(server_config.clone())
|
||||
.wrap(actix_slog::StructuredLogger::new(
|
||||
server_config.log.new(slog_o!("log_type" => "access")),
|
||||
))
|
||||
.wrap(TracingLogger)
|
||||
.wrap(IdentityService::new(
|
||||
CookieIdentityPolicy::new(&[0; 32])
|
||||
.name("auth-cookie")
|
||||
@ -191,7 +198,7 @@ async fn webservice(server_config: ServerConfig) -> Result<()> {
|
||||
.bind(host_port)
|
||||
.context("Failed to bind to port")
|
||||
.map_err(|e| {
|
||||
slog_error!(cfg.log, "Failed to bind to port!");
|
||||
error!("Failed to bind to port!");
|
||||
e
|
||||
})?
|
||||
.run()
|
||||
@ -199,8 +206,12 @@ async fn webservice(server_config: ServerConfig) -> Result<()> {
|
||||
.context("Failed to run the webservice")
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::result::Result<(), ServerError> {
|
||||
let subscriber = get_subscriber("app".into(), "info".into());
|
||||
init_subscriber(subscriber);
|
||||
|
||||
match cli::setup().await {
|
||||
Ok(Some(server_config)) => webservice(server_config).await.map_err(|e| {
|
||||
println!("{:?}", e);
|
||||
|
@ -15,6 +15,7 @@ use image::{DynamicImage, ImageOutputFormat, Luma};
|
||||
use qrcode::{render::svg, QrCode};
|
||||
use queries::{authenticate, Role};
|
||||
use tera::{Context, Tera};
|
||||
use tracing::{info, trace, warn};
|
||||
|
||||
use pslink::forms::LinkForm;
|
||||
use pslink::models::{LoginUser, NewUser};
|
||||
@ -150,7 +151,7 @@ pub async fn view_profile(
|
||||
id: Identity,
|
||||
user_id: web::Path<String>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
slog_info!(config.log, "Viewing Profile!");
|
||||
info!("Viewing Profile!");
|
||||
if let Ok(query) = queries::get_user(&id, &user_id.0, &config).await {
|
||||
let mut data = Context::new();
|
||||
data.insert("user", &query.user);
|
||||
@ -177,7 +178,7 @@ pub async fn edit_profile(
|
||||
id: Identity,
|
||||
user_id: web::Path<String>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
slog_info!(config.log, "Editing Profile!");
|
||||
info!("Editing Profile!");
|
||||
if let Ok(query) = queries::get_user(&id, &user_id.0, &config).await {
|
||||
let mut data = Context::new();
|
||||
data.insert("user", &query.user);
|
||||
@ -259,7 +260,7 @@ pub async fn process_signup(
|
||||
config: web::Data<pslink::ServerConfig>,
|
||||
id: Identity,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
slog_info!(config.log, "Creating a User: {:?}", &data);
|
||||
info!("Creating a User: {:?}", &data);
|
||||
match queries::create_user(&id, &data, &config).await {
|
||||
Ok(item) => {
|
||||
Ok(HttpResponse::Ok().body(format!("Successfully saved user: {}", item.item.username)))
|
||||
@ -296,7 +297,7 @@ pub async fn login(
|
||||
req: HttpRequest,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
let language_code = detect_language(&req)?;
|
||||
slog_info!(config.log, "Detected languagecode: {}", &language_code);
|
||||
info!("Detected languagecode: {}", &language_code);
|
||||
let mut data = Context::new();
|
||||
data.insert("title", "Login");
|
||||
data.insert("language", &language_code);
|
||||
@ -305,8 +306,7 @@ pub async fn login(
|
||||
if let Ok(r) = authenticate(&id, &config).await {
|
||||
match r {
|
||||
Role::Admin { user } | Role::Regular { user } => {
|
||||
slog_trace!(
|
||||
config.log,
|
||||
trace!(
|
||||
"This user ({}) is already logged in redirecting to /admin/index/",
|
||||
user.username
|
||||
);
|
||||
@ -315,7 +315,7 @@ pub async fn login(
|
||||
Role::Disabled | Role::NotAuthenticated => (),
|
||||
}
|
||||
}
|
||||
slog_warn!(config.log, "Invalid user session. The user might be deleted or something tampered with the cookies.");
|
||||
warn!("Invalid user session. The user might be deleted or something tampered with the cookies.");
|
||||
id.forget();
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ pub async fn process_login(
|
||||
.verify()?;
|
||||
|
||||
if valid {
|
||||
slog_info!(config.log, "Log-in of user: {}", &u.username);
|
||||
info!("Log-in of user: {}", &u.username);
|
||||
let session_token = u.username;
|
||||
id.remember(session_token);
|
||||
Ok(redirect_builder("/admin/index/"))
|
||||
@ -349,7 +349,7 @@ pub async fn process_login(
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
slog_info!(config.log, "Failed to login: {}", e);
|
||||
info!("Failed to login: {}", e);
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
}
|
||||
@ -366,21 +366,18 @@ pub async fn redirect(
|
||||
data: web::Path<String>,
|
||||
req: HttpRequest,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
slog_info!(config.log, "Redirecting to {:?}", data);
|
||||
info!("Redirecting to {:?}", data);
|
||||
let link = queries::get_link_simple(&data.0, &config).await;
|
||||
slog_info!(config.log, "link: {:?}", link);
|
||||
info!("link: {:?}", link);
|
||||
match link {
|
||||
Ok(link) => {
|
||||
queries::click_link(link.id, &config).await?;
|
||||
Ok(redirect_builder(&link.target))
|
||||
}
|
||||
Err(ServerError::Database(e)) => {
|
||||
slog_info!(
|
||||
config.log,
|
||||
info!(
|
||||
"Link was not found: http://{}/{} \n {}",
|
||||
&config.public_url,
|
||||
&data.0,
|
||||
e
|
||||
&config.public_url, &data.0, e
|
||||
);
|
||||
let mut data = Context::new();
|
||||
data.insert("title", "Wurde gel\u{f6}scht");
|
||||
|
15
src/lib.rs
15
src/lib.rs
@ -1,18 +1,4 @@
|
||||
extern crate sqlx;
|
||||
#[allow(unused_imports)]
|
||||
#[macro_use(
|
||||
slog_o,
|
||||
slog_info,
|
||||
slog_warn,
|
||||
slog_error,
|
||||
slog_log,
|
||||
slog_record,
|
||||
slog_record_static,
|
||||
slog_b,
|
||||
slog_kv
|
||||
)]
|
||||
extern crate slog;
|
||||
extern crate slog_async;
|
||||
|
||||
pub mod forms;
|
||||
pub mod models;
|
||||
@ -171,7 +157,6 @@ pub struct ServerConfig {
|
||||
pub internal_ip: String,
|
||||
pub port: u32,
|
||||
pub protocol: Protocol,
|
||||
pub log: slog::Logger,
|
||||
pub empty_forward_url: String,
|
||||
pub brand_name: String,
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ impl Link {
|
||||
let link = sqlx::query_as!(Self, "Select * from links where code = ? ", code)
|
||||
.fetch_one(&server_config.db_pool)
|
||||
.await;
|
||||
slog_info!(server_config.log, "Found link: {:?}", &link);
|
||||
tracing::info!("Found link: {:?}", &link);
|
||||
link.map_err(ServerError::Database)
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
use actix_identity::Identity;
|
||||
use actix_web::web;
|
||||
use serde::Serialize;
|
||||
use tracing::info;
|
||||
|
||||
use super::models::{Count, Link, NewUser, User};
|
||||
use crate::{
|
||||
@ -170,7 +171,7 @@ pub async fn get_user(
|
||||
server_config: &ServerConfig,
|
||||
) -> Result<Item<User>, ServerError> {
|
||||
if let Ok(uid) = user_id.parse::<i64>() {
|
||||
slog_info!(server_config.log, "Getting user {}", uid);
|
||||
info!("Getting user {}", uid);
|
||||
let auth = authenticate(id, server_config).await?;
|
||||
if auth.admin_or_self(uid) {
|
||||
match auth {
|
||||
@ -214,7 +215,7 @@ pub async fn create_user(
|
||||
data: &web::Form<NewUser>,
|
||||
server_config: &ServerConfig,
|
||||
) -> Result<Item<User>, ServerError> {
|
||||
slog_info!(server_config.log, "Creating a User: {:?}", &data);
|
||||
info!("Creating a User: {:?}", &data);
|
||||
let auth = authenticate(id, server_config).await?;
|
||||
match auth {
|
||||
Role::Admin { user } => {
|
||||
@ -258,7 +259,7 @@ pub async fn update_user(
|
||||
if auth.admin_or_self(uid) {
|
||||
match auth {
|
||||
Role::Admin { .. } | Role::Regular { .. } => {
|
||||
slog_info!(server_config.log, "Updating userinfo: ");
|
||||
info!("Updating userinfo: ");
|
||||
let password = if data.password.len() > 3 {
|
||||
NewUser::hash_password(&data.password, server_config)?
|
||||
} else {
|
||||
@ -303,21 +304,17 @@ pub async fn toggle_admin(
|
||||
let auth = authenticate(id, server_config).await?;
|
||||
match auth {
|
||||
Role::Admin { .. } => {
|
||||
slog_info!(server_config.log, "Changing administrator priviledges: ");
|
||||
info!("Changing administrator priviledges: ");
|
||||
|
||||
let unchanged_user = User::get_user(uid, server_config).await?;
|
||||
|
||||
let old = unchanged_user.role;
|
||||
unchanged_user.toggle_admin(server_config).await?;
|
||||
|
||||
slog_info!(server_config.log, "Toggling role: old was {}", old);
|
||||
info!("Toggling role: old was {}", old);
|
||||
|
||||
let changed_user = User::get_user(uid, server_config).await?;
|
||||
slog_info!(
|
||||
server_config.log,
|
||||
"Toggled role: new is {}",
|
||||
changed_user.role
|
||||
);
|
||||
info!("Toggled role: new is {}", changed_user.role);
|
||||
Ok(Item {
|
||||
user: changed_user.clone(),
|
||||
item: changed_user,
|
||||
@ -382,10 +379,10 @@ pub async fn get_link_simple(
|
||||
link_code: &str,
|
||||
server_config: &ServerConfig,
|
||||
) -> Result<Link, ServerError> {
|
||||
slog_info!(server_config.log, "Getting link for {:?}", link_code);
|
||||
info!("Getting link for {:?}", link_code);
|
||||
|
||||
let link = Link::get_link_by_code(link_code, server_config).await?;
|
||||
slog_info!(server_config.log, "Foun d link for {:?}", link);
|
||||
info!("Foun d link for {:?}", link);
|
||||
Ok(link)
|
||||
}
|
||||
|
||||
@ -394,7 +391,7 @@ pub async fn get_link_simple(
|
||||
/// # Errors
|
||||
/// Fails with [`ServerError`] if access to the database fails.
|
||||
pub async fn click_link(link_id: i64, server_config: &ServerConfig) -> Result<(), ServerError> {
|
||||
slog_info!(server_config.log, "Clicking on {:?}", link_id);
|
||||
info!("Clicking on {:?}", link_id);
|
||||
let new_click = NewClick::new(link_id);
|
||||
new_click.insert_click(server_config).await?;
|
||||
Ok(())
|
||||
@ -429,12 +426,7 @@ pub async fn update_link(
|
||||
data: web::Form<LinkForm>,
|
||||
server_config: &ServerConfig,
|
||||
) -> Result<Item<Link>, ServerError> {
|
||||
slog_info!(
|
||||
server_config.log,
|
||||
"Changing link to: {:?} {:?}",
|
||||
&data,
|
||||
&link_code
|
||||
);
|
||||
info!("Changing link to: {:?} {:?}", &data, &link_code);
|
||||
let auth = authenticate(id, server_config).await?;
|
||||
match auth {
|
||||
Role::Admin { .. } | Role::Regular { .. } => {
|
||||
@ -472,9 +464,9 @@ pub async fn create_link(
|
||||
match auth {
|
||||
Role::Admin { user } | Role::Regular { user } => {
|
||||
let code = data.code.clone();
|
||||
slog_info!(server_config.log, "Creating link for: {}", &code);
|
||||
info!("Creating link for: {}", &code);
|
||||
let new_link = NewLink::from_link_form(data.into_inner(), user.id);
|
||||
slog_info!(server_config.log, "Creating link for: {:?}", &new_link);
|
||||
info!("Creating link for: {:?}", &new_link);
|
||||
|
||||
new_link.insert(server_config).await?;
|
||||
let new_link = get_link_simple(&code, server_config).await?;
|
||||
|
Loading…
Reference in New Issue
Block a user