use tracing in compiler

This commit is contained in:
collin 2020-08-21 16:36:50 -07:00
parent c22ddffe74
commit 912a192b5c
8 changed files with 18 additions and 20 deletions

1
Cargo.lock generated
View File

@ -1240,7 +1240,6 @@ dependencies = [
"leo-package",
"leo-state",
"leo-typed",
"log",
"num-bigint",
"pest",
"rand",

View File

@ -29,7 +29,6 @@ snarkos-utilities = { version = "1.0.0" }
bincode = { version = "1.0" }
hex = { version = "0.4.2" }
log = { version = "0.4" }
pest = { version = "2.0" }
rand = { version = "0.7" }
rand_xorshift = { version = "0.2", default-features = false }

View File

@ -133,7 +133,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
self.program = typed_tree.into_repr();
self.imported_programs = ImportParser::parse(&self.program)?;
log::debug!("Program parsing complete\n{:#?}", self.program);
tracing::debug!("Program parsing complete\n{:#?}", self.program);
Ok(())
}
@ -230,16 +230,16 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstraintSynthesizer<F> for Compil
let output_directory = self.output_directory.clone();
let package_name = self.package_name.clone();
let result = self.generate_constraints_helper(cs).map_err(|e| {
log::error!("{}", e);
tracing::error!("{}", e);
SynthesisError::Unsatisfiable
})?;
log::info!("Program circuit successfully synthesized!");
tracing::info!("Program circuit successfully synthesized!");
// Write results to file
let output_file = OutputFile::new(&package_name);
log::info!("Writing to output registers...");
tracing::info!("Writing to output registers...");
output_file.write(&output_directory, result.bytes()).unwrap();

View File

@ -25,21 +25,21 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
let string = self.format(cs, file_scope, function_scope, string)?;
if unwrap_indicator_value(indicator) {
log::debug!("{}", string);
tracing::debug!("{}", string);
}
}
ConsoleFunction::Error(string) => {
let string = self.format(cs, file_scope, function_scope, string)?;
if unwrap_indicator_value(indicator) {
log::error!("{}", string);
tracing::error!("{}", string);
}
}
ConsoleFunction::Log(string) => {
let string = self.format(cs, file_scope, function_scope, string)?;
if unwrap_indicator_value(indicator) {
log::info!("{}", string);
tracing::info!("{}", string);
}
}
}

View File

@ -78,7 +78,7 @@ pub fn generate_test_constraints<F: Field + PrimeField, G: GroupType<F>>(
// Get default input
let default = input.pairs.get(&program_name);
log::info!("Running {} tests", tests.len());
tracing::info!("Running {} tests", tests.len());
for (test_name, test) in tests.into_iter() {
let cs = &mut TestConstraintSystem::<F>::new();
@ -121,7 +121,7 @@ pub fn generate_test_constraints<F: Field + PrimeField, G: GroupType<F>>(
);
if result.is_ok() {
log::info!(
tracing::info!(
"test {} compiled successfully. Constraint system satisfied: {}",
full_test_name,
cs.is_satisfied()
@ -131,11 +131,11 @@ pub fn generate_test_constraints<F: Field + PrimeField, G: GroupType<F>>(
let output = result?;
let output_file = OutputFile::new(&output_file_name);
log::info!("\tWriting output to registers in `{}.out` ...", output_file_name);
tracing::info!("\tWriting output to registers in `{}.out` ...", output_file_name);
output_file.write(output_directory, output.bytes()).unwrap();
} else {
log::error!("test {} errored: {}", full_test_name, result.unwrap_err());
// tracing::error!("test {} errored: {}", full_test_name, result.unwrap_err());
}
}

View File

@ -112,7 +112,7 @@ impl CLI for BuildCommand {
// Load the state file at `package_name.in`
let state_string = StateFile::new(&package_name).read_from(&path)?;
// Log compilation of main file to console
// Log compilation of files to console
tracing::info!("program file ({:?})", main_file_path);
// Load the program at `main_file_path`

View File

@ -56,7 +56,7 @@ impl CLI for DeployCommand {
// Get the package name
let _package_name = Manifest::try_from(&path)?.get_package_name();
tracing::info!("Unimplemented - `leo deploy`");
tracing::error!("Unimplemented - `leo deploy`");
Ok(())
}

View File

@ -107,8 +107,8 @@ pub enum CLIError {
VerificationKeyFileError(VerificationKeyFileError),
}
macro_rules! impl_T {
(for $($t:tt), +) => {
macro_rules! impl_cli_error {
($($t:tt), +) => {
$(impl From<$t> for CLIError {
fn from(error: $t) -> Self {
tracing::error!("{}\n", error);
@ -119,7 +119,7 @@ macro_rules! impl_T {
}
}
impl_T!(for
impl_cli_error!(
AddError,
BuildError,
CircuitFileError,
@ -143,8 +143,8 @@ impl_T!(for
SourceDirectoryError,
StateFileError,
TestError,
VerificationKeyFileError
ZipFileError,
VerificationKeyFileError,
ZipFileError
);
impl From<leo_compiler::errors::CompilerError> for CLIError {