DEV Community

Cover image for Rust: Actix-web and Daily Logging

Rust: Actix-web and Daily Logging

Be Hai Nguyen on March 13, 2024

Currently, our actix-web learning application simply prints debug information to the console using the println! macro. In this post, we will implem...
Collapse
 
behainguyen profile image
Be Hai Nguyen

Note, the following also raises IndeterminateOffset error:

    let now_local = time::OffsetDateTime::now_local();
    let now_offset = now_local.unwrap();
    let timer = OffsetTime::new(
        now_offset.offset(),
        format_description!("[year]-[month]-[day]-[hour]:[minute]:[second]"),
    );
Enter fullscreen mode Exit fullscreen mode

now_local is in error.

Collapse
 
behainguyen profile image
Be Hai Nguyen

In tests/common.rs, function spawn_app(), time::OffsetDateTime::now_local() also raises IndeterminateOffset error:

    let offset = time::OffsetDateTime::now_local().unwrap().offset()
        .as_hms();
    // let guard = init_app_logger(UtcOffset::from_hms(11, 0, 0).unwrap());
    let guard = init_app_logger(UtcOffset::from_hms(offset.0, offset.1, offset.2).unwrap());
Enter fullscreen mode Exit fullscreen mode