xmr-rs / xmr

Monero node.
Apache License 2.0
30 stars 9 forks source link

Running xmr gives blank output. #11

Open shopglobal opened 6 years ago

shopglobal commented 6 years ago

So I tested the cargo run for this crate, and am presented with a blank output. Is this the intended function? Or should we be booting up the daemon with./dxmr? Is it headless? Api? Do we just need to add logging? Could you catch me up to speed? Looking forward to collaborating.

user@userd:~/xmr$ cargo build
   Compiling slab v0.3.0
   Compiling scoped-tls v0.1.0
   Compiling lazy_static v1.0.0
   Compiling xdg v2.1.0
   Compiling strsim v0.6.0
   Compiling cfg-if v0.1.2
   Compiling byteorder v1.2.1
   Compiling unicode-width v0.1.4
   Compiling quote v0.3.15
   Compiling termcolor v0.3.3
   Compiling rustc-serialize v0.3.24
   Compiling regex-syntax v0.4.2
   Compiling xmr-rct v0.1.0 (file:///home/user/xmr/rct)
   Compiling smallvec v0.6.0
   Compiling serde v1.0.27
   Compiling unicode-xid v0.0.4
   Compiling utf8-ranges v1.0.0
   Compiling uuid v0.5.1
   Compiling bitflags v1.0.1
   Compiling rustc-demangle v0.1.5
   Compiling cc v1.0.4
   Compiling libc v0.2.36
   Compiling void v1.0.2
   Compiling futures v0.1.18
   Compiling stable_deref_trait v1.0.0
   Compiling crossbeam v0.3.2
   Compiling slab v0.4.0
   Compiling linked-hash-map v0.5.0
   Compiling vec_map v0.8.0
   Compiling num-traits v0.1.41
   Compiling lazycell v0.6.0
   Compiling ansi_term v0.10.2
   Compiling log v0.4.1
   Compiling textwrap v0.9.0
   Compiling app_dirs v1.1.1
   Compiling synom v0.11.3
   Compiling unreachable v1.0.0
   Compiling time v0.1.39
   Compiling memmap v0.6.2
   Compiling num_cpus v1.8.0
   Compiling atty v0.2.6
   Compiling memchr v2.0.1
   Compiling iovec v0.1.1
   Compiling fs2 v0.4.3
   Compiling rand v0.4.2
   Compiling net2 v0.2.31
   Compiling rand v0.3.20
   Compiling owning_ref v0.3.3
   Compiling backtrace-sys v0.1.16
   Compiling xmr-crypto v0.1.0 (file:///home/user/xmr/crypto)
   Compiling log v0.3.9
   Compiling num-complex v0.1.41
   Compiling num-integer v0.1.35
   Compiling thread_local v0.3.5
   Compiling clap v2.29.2
   Compiling syn v0.11.11
   Compiling futures-cpupool v0.1.8
   Compiling bytes v0.4.6
   Compiling aho-corasick v0.6.4
   Compiling sanakirja v0.8.16
   Compiling num-iter v0.1.34
   Compiling mio v0.6.13
   Compiling num-bigint v0.1.41
   Compiling parking_lot_core v0.2.10
   Compiling regex v0.2.5
   Compiling tokio-io v0.1.5
   Compiling synstructure v0.6.1
   Compiling serde_derive_internals v0.19.0
   Compiling parking_lot v0.4.8
   Compiling tokio-core v0.1.12
   Compiling num-rational v0.1.41
   Compiling backtrace v0.3.5
   Compiling num v0.1.41
   Compiling serde_derive v1.0.27
   Compiling chrono v0.4.0
   Compiling xmr-varint v0.1.0 (file:///home/user/xmr/varint)
   Compiling failure_derive v0.1.1
   Compiling failure v0.1.1
   Compiling env_logger v0.5.0
   Compiling xmr-format v0.1.0 (file:///home/user/xmr/format)
   Compiling xmr-portable-storage v0.1.0 (file:///home/user/xmr/portable-storage)
   Compiling xmr-keys v0.1.0 (file:///home/user/xmr/keys)
   Compiling xmr-primitives v0.1.0 (file:///home/user/xmr/primitives)
   Compiling xmr-levin v0.1.0 (file:///home/user/xmr/levin)
   Compiling xmr-portable-storage-utils v0.1.0 (file:///home/user/xmr/portable-storage-utils)
   Compiling xmr-verification v0.1.0 (file:///home/user/xmr/verification)
   Compiling xmr-chain v0.1.0 (file:///home/user/xmr/chain)
   Compiling xmr-storage v0.1.0 (file:///home/user/xmr/storage)
   Compiling xmr-network v0.1.0 (file:///home/user/xmr/network)
   Compiling xmr-db v0.1.0 (file:///home/user/xmr/db)
   Compiling xmr-p2p v0.1.0 (file:///home/user/xmr/p2p)
   Compiling xmr-sync v0.1.0 (file:///home/user/xmr/sync)
warning: field is never used: `peers`
  --> sync/src/inbound_connection.rs:12:5
   |
12 |     peers: PeersRef,
   |     ^^^^^^^^^^^^^^^
   |
   = note: #[warn(dead_code)] on by default

warning: field is never used: `executor`
  --> sync/src/local_node.rs:16:5
   |
16 |     executor: ExecutorRef,
   |     ^^^^^^^^^^^^^^^^^^^^^

   Compiling xmr v0.1.0 (file:///home/user/xmr)
    Finished dev [unoptimized + debuginfo] target(s) in 79.68 secs
jeandudey commented 6 years ago

I think $ export RUST_BACKTRACE=trace might help.

The executable currently doesn't display anything interesting (yet) however I think it should output info! and warn! log messages, anyway using trace!-level log can be used to develop and debug the program.

Thanks for pointing this out, possibly a custom log could be made to show the log on stdout. If I get something working within the following minutes I'm going to open a PR so you can see if it fits your needs (or you can try to do it too).

shopglobal commented 6 years ago

https://stackoverflow.com/questions/49062707/capture-both-stdout-stderr-via-pipe Does this method look like it can help?

use std::io::{BufRead, BufReader};
use std::process::{Command, Stdio};

fn main() {
    let child = Command::new("./dxrm")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .spawn()
        .unwrap();

    let output = child.wait_with_output().unwrap();

    let out = BufReader::new(&*output.stdout);
    let err = BufReader::new(&*output.stderr);

    out.lines().for_each(|line|
        println!("out: {}", line.unwrap());
    );
    err.lines().for_each(|line|
        println!("err: {}", line.unwrap());
    );

    println!("{}", output.status);
}
jeandudey commented 6 years ago

@shopglobal It won't work the way you think, to show log on stdout you need to create a logger interface inside the dxmr code, the interface needs to implement Log. Currently dxmr uses env_logger (implements Log) that needs the RUST_LOG environment variable to be set (to a valid log level) and then prints the log to stdout.