mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-24 18:06:42 +02:00
use log and env_logger, and add some logging around sync
This commit is contained in:
parent
c117494ce6
commit
0a1ee470f7
13 changed files with 109 additions and 14 deletions
|
@ -27,6 +27,7 @@ pub(crate) fn app_scope(server_state: ServerState) -> Scope {
|
|||
|
||||
#[actix_web::main]
|
||||
async fn main() -> Fallible<()> {
|
||||
env_logger::init();
|
||||
let matches = clap::App::new("taskchampion-sync-server")
|
||||
.version("0.1.0")
|
||||
.about("Server for TaskChampion")
|
||||
|
@ -58,7 +59,7 @@ async fn main() -> Fallible<()> {
|
|||
let server_box: Box<dyn Storage> = Box::new(KVStorage::new(data_dir)?);
|
||||
let server_state = ServerState::new(server_box);
|
||||
|
||||
println!("Serving on port {}", port);
|
||||
log::warn!("Serving on port {}", port);
|
||||
HttpServer::new(move || App::new().service(app_scope(server_state.clone())))
|
||||
.bind(format!("0.0.0.0:{}", port))?
|
||||
.run()
|
||||
|
|
|
@ -49,8 +49,15 @@ pub(crate) fn add_version<'a>(
|
|||
parent_version_id: VersionId,
|
||||
history_segment: HistorySegment,
|
||||
) -> Fallible<AddVersionResult> {
|
||||
log::debug!(
|
||||
"add_version(client_id: {}, parent_version_id: {})",
|
||||
client_id,
|
||||
parent_version_id,
|
||||
);
|
||||
|
||||
// check if this version is acceptable, under the protection of the transaction
|
||||
if client.latest_version_id != NO_VERSION_ID && parent_version_id != client.latest_version_id {
|
||||
log::debug!("add_version request rejected: mismatched latest_version_id");
|
||||
return Ok(AddVersionResult::ExpectedParentVersion(
|
||||
client.latest_version_id,
|
||||
));
|
||||
|
@ -58,6 +65,10 @@ pub(crate) fn add_version<'a>(
|
|||
|
||||
// invent a version ID
|
||||
let version_id = Uuid::new_v4();
|
||||
log::debug!(
|
||||
"add_version request accepted: new version_id: {}",
|
||||
version_id
|
||||
);
|
||||
|
||||
// update the DB
|
||||
txn.add_version(client_id, version_id, parent_version_id, history_segment)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue