Git Product home page Git Product logo

delog's People

Contributors

conorpp avatar mvanslobbe avatar nickray avatar robin-nitrokey avatar sosthene-nitrokey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

delog's Issues

Type check logs even when disabled

When logs are disabled, delog doesn't type check the arguments, which can lead to unexpected compilation if something was only compiled with logs disabled.

Copyright unclear

Hi,

I'm packaging delog for Debian to be able to package solo2-cli some day. Unfortunately it is not very clear to me who the copyright holder of the code is. LICENSE-MIT states "Copyright (c) 2018 John Scarrott" but the first commit in this repository is from 2020 and it seems John Scarrott didn't commit any code. Cargo.toml lists Nicolas Stalder as author.

Could you please clarify and correct? (and also release a new version once fixed?)

Thanks!

Support inlined arguments

Currently, delog does not support inlined format arguments.

let some_var = "test";
info!("{some_var}");

Should log test but instead logs {some_var} without actually formatting it.

Does not compile for target thumbv6em-none-eabi

Hello,

I am trying to add deluge to my cortex-m0 target using the thumbv6em-none-eabi toolchain.
Whereas I can compile everything easily with the thumbv7em-none-eabihf toolchain, the version 6 toolchain does give me the following error:

$ cargo build --target thumbv6em-none-eabi

   Compiling delog v0.1.6 (/Users/dominiktacke/Projects/rust/embedded/delog)
error[E0599]: no method named `fetch_add` found for reference `&'static AtomicUsize` in the current scope
   --> src/logger.rs:512:29
    |
512 |         delogger.attempts().fetch_add(1, Ordering::SeqCst);
    |                             ^^^^^^^^^ method not found in `&'static AtomicUsize`

error[E0599]: no method named `fetch_add` found for reference `&'static AtomicUsize` in the current scope
   --> src/logger.rs:519:34
    |
519 |             delogger.successes().fetch_add(1, Ordering::SeqCst);
    |                                  ^^^^^^^^^ method not found in `&'static AtomicUsize`

error[E0599]: no method named `compare_exchange` found for reference `&'static AtomicUsize` in the current scope
   --> src/logger.rs:538:47
    |
538 |             let previous = delogger.claimed().compare_exchange(
    |                                               ^^^^^^^^^^^^^^^^ method not found in `&'static AtomicUsize`

error[E0599]: no method named `fetch_add` found for reference `&'static AtomicUsize` in the current scope
   --> src/logger.rs:587:30
    |
587 |         delogger.successes().fetch_add(1, Ordering::SeqCst);
    |                              ^^^^^^^^^ method not found in `&'static AtomicUsize`

error[E0599]: no method named `fetch_add` found for reference `&'static AtomicUsize` in the current scope
   --> src/logger.rs:599:24
    |
599 |     delogger.flushes().fetch_add(1, Ordering::SeqCst);
    |                        ^^^^^^^^^ method not found in `&'static AtomicUsize`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `delog` due to 5 previous errors

Tried this on a Mac M1 as well as in the rust:latest docker with the same result.

Ideas are highly appreciated

Unsound `logger` function

Hello,

having multiple references with at least one of them being &mut to the same memory is considered undefined behavior in Rust.

Code like this:

fn main() {
    let r1 = delog::logger();
    let r2 = delog::logger();

    core::hint::black_box((r1, r2));
}

Is absolutely safe and using public interface, yet triggering UB.

Miri output:

Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu)... done
WARNING: Ignoring `RUSTC_WRAPPER` environment variable, Miri does not support wrapping.
   Compiling delog v0.1.7
   Compiling log v0.4.20
   Compiling delog_ub v0.1.0 (/home/ddystopia/code/delog_ub)
    Finished dev [unoptimized + debuginfo] target(s) in 0.18s
     Running `/home/ddystopia/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner /home/ddystopia/code/delog_ub/target/miri/x86_64-unknown-linux-gnu/debug/delog_ub`
error: Undefined Behavior: trying to retag from <1689> for Unique permission at alloc824[0x0], but that tag does not exist in the borrow stack for this location
 --> src/main.rs:5:28
  |
5 |     core::hint::black_box((r1, r2));
  |                            ^^
  |                            |
  |                            trying to retag from <1689> for Unique permission at alloc824[0x0], but that tag does not exist in the borrow stack for this location
  |                            this error occurs as part of retag at alloc824[0x0..0x10]
  |
  = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
  = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <1689> was created by a Unique retag at offsets [0x0..0x10]
 --> src/main.rs:2:14
  |
2 |     let r1 = delog::logger();
  |              ^^^^^^^^^^^^^^^
help: <1689> was later invalidated at offsets [0x0..0x10] by a Unique retag
 --> src/main.rs:3:14
  |
3 |     let r2 = delog::logger();
  |              ^^^^^^^^^^^^^^^
  = note: BACKTRACE (of the first span):
  = note: inside `main` at src/main.rs:5:28: 5:30

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 1 previous error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.