diff --git a/cli/auth_tokens.rs b/cli/auth_tokens.rs index 64f42fc5c0..83c97e641e 100644 --- a/cli/auth_tokens.rs +++ b/cli/auth_tokens.rs @@ -1,6 +1,8 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. use deno_core::ModuleSpecifier; +use log::debug; +use log::error; use std::fmt; #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/cli/colors.rs b/cli/colors.rs index 278c141b4b..5eafef4d42 100644 --- a/cli/colors.rs +++ b/cli/colors.rs @@ -4,7 +4,6 @@ #![allow(dead_code)] use regex::Regex; -use std::env; use std::fmt; use std::io::Write; use termcolor::Color::{Ansi256, Black, Blue, Cyan, Green, Red, White, Yellow}; @@ -13,14 +12,14 @@ use termcolor::{Ansi, ColorSpec, WriteColor}; #[cfg(windows)] use termcolor::{BufferWriter, ColorChoice}; -lazy_static! { +lazy_static::lazy_static! { // STRIP_ANSI_RE and strip_ansi_codes are lifted from the "console" crate. // Copyright 2017 Armin Ronacher . MIT License. static ref STRIP_ANSI_RE: Regex = Regex::new( r"[\x1b\x9b][\[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]" ).unwrap(); static ref NO_COLOR: bool = { - env::var_os("NO_COLOR").is_some() + std::env::var_os("NO_COLOR").is_some() }; } diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs index 0ba1a23ae2..4044614fc3 100644 --- a/cli/diagnostics.rs +++ b/cli/diagnostics.rs @@ -63,7 +63,7 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[ "utimeSync", ]; -lazy_static! { +lazy_static::lazy_static! { static ref MSG_MISSING_PROPERTY_DENO: Regex = Regex::new(r#"Property '([^']+)' does not exist on type 'typeof Deno'"#) .unwrap(); diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index 3803c93c9e..1c97d70189 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -10,8 +10,6 @@ use crate::http_util::FetchOnceResult; use crate::media_type::MediaType; use crate::text_encoding; use crate::version::get_user_agent; -use deno_runtime::permissions::Permissions; - use deno_core::error::custom_error; use deno_core::error::generic_error; use deno_core::error::uri_error; @@ -20,6 +18,9 @@ use deno_core::futures; use deno_core::futures::future::FutureExt; use deno_core::ModuleSpecifier; use deno_runtime::deno_fetch::reqwest; +use deno_runtime::permissions::Permissions; +use log::debug; +use log::info; use std::collections::HashMap; use std::env; use std::fs; diff --git a/cli/file_watcher.rs b/cli/file_watcher.rs index 7bc4dd7b72..651a3ee314 100644 --- a/cli/file_watcher.rs +++ b/cli/file_watcher.rs @@ -5,6 +5,7 @@ use deno_core::error::AnyError; use deno_core::futures::ready; use deno_core::futures::stream::{Stream, StreamExt}; use deno_core::futures::Future; +use log::info; use notify::event::Event as NotifyEvent; use notify::event::EventKind; use notify::Config; diff --git a/cli/flags.rs b/cli/flags.rs index 5ae2f90273..6edce35de6 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -10,11 +10,27 @@ use deno_core::serde::Deserialize; use deno_core::serde::Serialize; use deno_core::url::Url; use deno_runtime::permissions::PermissionsOptions; +use log::debug; use log::Level; use std::net::SocketAddr; use std::path::PathBuf; use std::str::FromStr; +lazy_static::lazy_static! { + static ref LONG_VERSION: String = format!( + "{} ({}, {})\nv8 {}\ntypescript {}", + crate::version::deno(), + if crate::version::is_canary() { + "canary" + } else { + env!("PROFILE") + }, + env!("TARGET"), + deno_core::v8_version(), + crate::version::TYPESCRIPT + ); +} + #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] pub enum DenoSubcommand { Bundle { @@ -259,21 +275,6 @@ To evaluate code in the shell: deno eval \"console.log(30933 + 404)\" "; -lazy_static! { - static ref LONG_VERSION: String = format!( - "{} ({}, {})\nv8 {}\ntypescript {}", - crate::version::deno(), - if crate::version::is_canary() { - "canary" - } else { - env!("PROFILE") - }, - env!("TARGET"), - deno_core::v8_version(), - crate::version::TYPESCRIPT - ); -} - /// Main entry point for parsing deno's command line flags. pub fn flags_from_vec(args: Vec) -> clap::Result { let version = crate::version::deno(); diff --git a/cli/http_cache.rs b/cli/http_cache.rs index e703ca05a3..7eff2b9bea 100644 --- a/cli/http_cache.rs +++ b/cli/http_cache.rs @@ -1,9 +1,8 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - -/// This module is meant to eventually implement HTTP cache -/// as defined in RFC 7234 (https://tools.ietf.org/html/rfc7234). -/// Currently it's a very simplified version to fulfill Deno needs -/// at hand. +//! This module is meant to eventually implement HTTP cache +//! as defined in RFC 7234 (https://tools.ietf.org/html/rfc7234). +//! Currently it's a very simplified version to fulfill Deno needs +//! at hand. use crate::fs_util; use crate::http_util::HeadersMap; use deno_core::error::generic_error; @@ -12,6 +11,7 @@ use deno_core::serde::Deserialize; use deno_core::serde::Serialize; use deno_core::serde_json; use deno_core::url::Url; +use log::error; use std::fs; use std::fs::File; use std::io; diff --git a/cli/http_util.rs b/cli/http_util.rs index 69778a101a..a199f20c8e 100644 --- a/cli/http_util.rs +++ b/cli/http_util.rs @@ -15,6 +15,7 @@ use deno_runtime::deno_fetch::reqwest::header::USER_AGENT; use deno_runtime::deno_fetch::reqwest::redirect::Policy; use deno_runtime::deno_fetch::reqwest::Client; use deno_runtime::deno_fetch::reqwest::StatusCode; +use log::debug; use std::collections::HashMap; /// Create new instance of async reqwest::Client. This client supports diff --git a/cli/import_map.rs b/cli/import_map.rs index 487c0d8792..d18633545f 100644 --- a/cli/import_map.rs +++ b/cli/import_map.rs @@ -6,6 +6,8 @@ use deno_core::serde_json::Map; use deno_core::serde_json::Value; use deno_core::url::Url; use indexmap::IndexMap; +use log::debug; +use log::info; use std::cmp::Ordering; use std::collections::HashSet; use std::error::Error; diff --git a/cli/lockfile.rs b/cli/lockfile.rs index d3470145ee..0b52f5ee7b 100644 --- a/cli/lockfile.rs +++ b/cli/lockfile.rs @@ -2,6 +2,7 @@ use deno_core::serde_json; use deno_core::serde_json::json; +use log::debug; use std::collections::BTreeMap; use std::io::Result; use std::path::PathBuf; diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs index 3359fc6669..103a9c8102 100644 --- a/cli/lsp/analysis.rs +++ b/cli/lsp/analysis.rs @@ -28,7 +28,7 @@ use std::collections::HashMap; use std::fmt; use std::rc::Rc; -lazy_static! { +lazy_static::lazy_static! { /// Diagnostic error codes which actually are the same, and so when grouping /// fixes we treat them the same. static ref FIX_ALL_ERROR_CODES: HashMap<&'static str, &'static str> = diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index d4ec3d4947..82a3656491 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -15,6 +15,7 @@ use deno_core::error::AnyError; use deno_core::serde_json; use deno_core::serde_json::json; use deno_core::ModuleSpecifier; +use log::error; use lspower::lsp; use lspower::Client; use std::collections::HashMap; diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 0dc9a95cb1..74dcf21362 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -10,6 +10,9 @@ use deno_core::serde_json::json; use deno_core::serde_json::Value; use deno_core::ModuleSpecifier; use dprint_plugin_typescript as dprint; +use log::error; +use log::info; +use log::warn; use lspower::jsonrpc::Error as LspError; use lspower::jsonrpc::Result as LspResult; use lspower::lsp::request::*; @@ -55,7 +58,7 @@ use super::tsc::Assets; use super::tsc::TsServer; use super::urls; -lazy_static! { +lazy_static::lazy_static! { static ref ABSTRACT_MODIFIER: Regex = Regex::new(r"\babstract\b").unwrap(); static ref EXPORT_MODIFIER: Regex = Regex::new(r"\bexport\b").unwrap(); } diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index e6943472b5..e3c094dfa9 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -31,6 +31,7 @@ use deno_core::JsRuntime; use deno_core::ModuleSpecifier; use deno_core::OpFn; use deno_core::RuntimeOptions; +use log::warn; use lspower::lsp; use regex::Captures; use regex::Regex; diff --git a/cli/main.rs b/cli/main.rs index 99178b10a0..6833665c15 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -2,11 +2,6 @@ #![deny(warnings)] -#[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate log; - mod ast; mod auth_tokens; mod checksum; @@ -70,6 +65,8 @@ use deno_runtime::web_worker::WebWorker; use deno_runtime::web_worker::WebWorkerOptions; use deno_runtime::worker::MainWorker; use deno_runtime::worker::WorkerOptions; +use log::debug; +use log::info; use log::Level; use log::LevelFilter; use std::env; diff --git a/cli/main_runtime.rs b/cli/main_runtime.rs index f6d20f67ea..db3f9fd021 100644 --- a/cli/main_runtime.rs +++ b/cli/main_runtime.rs @@ -2,9 +2,6 @@ #![deny(warnings)] -#[macro_use] -extern crate lazy_static; - mod colors; mod standalone; mod tokio_util; diff --git a/cli/module_graph.rs b/cli/module_graph.rs index f70fc1c411..18cb3209cd 100644 --- a/cli/module_graph.rs +++ b/cli/module_graph.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - use crate::ast; use crate::ast::parse; use crate::ast::transpile_module; @@ -23,11 +22,10 @@ use crate::tsc; use crate::tsc_config::IgnoredCompilerOptions; use crate::tsc_config::TsConfig; use crate::version; -use deno_core::error::AnyError; - use deno_core::error::anyhow; use deno_core::error::custom_error; use deno_core::error::get_custom_error_class; +use deno_core::error::AnyError; use deno_core::error::Context; use deno_core::futures::stream::FuturesUnordered; use deno_core::futures::stream::StreamExt; @@ -41,6 +39,7 @@ use deno_core::serde_json::Value; use deno_core::ModuleResolutionError; use deno_core::ModuleSource; use deno_core::ModuleSpecifier; +use log::debug; use regex::Regex; use std::collections::HashMap; use std::collections::HashSet; @@ -53,7 +52,7 @@ use std::sync::Arc; use std::sync::Mutex; use std::time::Instant; -lazy_static! { +lazy_static::lazy_static! { /// Matched the `@deno-types` pragma. static ref DENO_TYPES_RE: Regex = Regex::new(r#"(?i)^\s*@deno-types\s*=\s*(?:["']([^"']+)["']|(\S+))"#) @@ -846,7 +845,7 @@ impl Graph { // moved it out of here, we wouldn't know until after the check has already // happened, which isn't informative to the users. for specifier in &self.roots { - info!("{} {}", colors::green("Check"), specifier); + log::info!("{} {}", colors::green("Check"), specifier); } let root_names = self.get_root_names(!config.get_check_js())?; diff --git a/cli/program_state.rs b/cli/program_state.rs index ebe223ab02..f47dcf0e9f 100644 --- a/cli/program_state.rs +++ b/cli/program_state.rs @@ -25,6 +25,8 @@ use deno_core::resolve_url; use deno_core::url::Url; use deno_core::ModuleSource; use deno_core::ModuleSpecifier; +use log::debug; +use log::warn; use std::collections::HashMap; use std::env; use std::fs::read; diff --git a/cli/specifier_handler.rs b/cli/specifier_handler.rs index d65474b7a0..9f329819ef 100644 --- a/cli/specifier_handler.rs +++ b/cli/specifier_handler.rs @@ -17,6 +17,7 @@ use deno_core::serde::Deserialize; use deno_core::serde::Serialize; use deno_core::serde_json; use deno_core::ModuleSpecifier; +use log::debug; use std::collections::HashMap; use std::env; use std::fmt; diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index 1385f849a3..91d730c448 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -16,6 +16,8 @@ use deno_core::error::generic_error; use deno_core::error::AnyError; use deno_core::futures; use deno_core::futures::FutureExt; +use log::debug; +use log::info; use std::fs; use std::io::stdin; use std::io::stdout; diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index a616db7ef2..7547437a3e 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -1,23 +1,24 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - use crate::flags::Flags; use crate::fs_util::canonicalize_path; use deno_core::error::generic_error; use deno_core::error::AnyError; use deno_core::url::Url; use log::Level; -use regex::{Regex, RegexBuilder}; +use regex::Regex; +use regex::RegexBuilder; use std::env; use std::fs; use std::fs::File; use std::io; use std::io::Write; -#[cfg(not(windows))] -use std::os::unix::fs::PermissionsExt; use std::path::Path; use std::path::PathBuf; -lazy_static! { +#[cfg(not(windows))] +use std::os::unix::fs::PermissionsExt; + +lazy_static::lazy_static! { static ref EXEC_NAME_RE: Regex = RegexBuilder::new( r"^[a-z][\w-]*$" ).case_insensitive(true).build().unwrap(); @@ -337,7 +338,7 @@ mod tests { use std::sync::Mutex; use tempfile::TempDir; - lazy_static! { + lazy_static::lazy_static! { pub static ref ENV_LOCK: Mutex<()> = Mutex::new(()); } diff --git a/cli/tools/lint.rs b/cli/tools/lint.rs index 2f31c88d60..e2897b72ea 100644 --- a/cli/tools/lint.rs +++ b/cli/tools/lint.rs @@ -19,6 +19,8 @@ use deno_lint::linter::Linter; use deno_lint::linter::LinterBuilder; use deno_lint::rules; use deno_lint::rules::LintRule; +use log::debug; +use log::info; use serde::Serialize; use std::fs; use std::io::{stdin, Read}; diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs index e98ecf5ff1..cdca80dc72 100644 --- a/cli/tools/upgrade.rs +++ b/cli/tools/upgrade.rs @@ -12,7 +12,7 @@ use std::path::PathBuf; use std::process::Command; use tempfile::TempDir; -lazy_static! { +lazy_static::lazy_static! { static ref ARCHIVE_NAME: String = format!("deno-{}.zip", env!("TARGET")); } diff --git a/cli/tsc.rs b/cli/tsc.rs index 3e38a6918c..dd97cb6b76 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -55,7 +55,7 @@ macro_rules! inc { }; } -lazy_static! { +lazy_static::lazy_static! { /// Contains static assets that are not preloaded in the compiler snapshot. pub(crate) static ref STATIC_ASSETS: HashMap<&'static str, &'static str> = (&[ ("lib.dom.asynciterable.d.ts", inc!("lib.dom.asynciterable.d.ts")), diff --git a/core/bindings.rs b/core/bindings.rs index afa4fbbf39..4665803be1 100644 --- a/core/bindings.rs +++ b/core/bindings.rs @@ -9,6 +9,8 @@ use crate::OpTable; use crate::ZeroCopyBuf; use futures::future::FutureExt; use rusty_v8 as v8; +use serde::Serialize; +use serde_v8::to_v8; use std::cell::Cell; use std::convert::TryFrom; use std::convert::TryInto; @@ -17,10 +19,7 @@ use std::option::Option; use url::Url; use v8::MapFnTo; -use serde::Serialize; -use serde_v8::to_v8; - -lazy_static! { +lazy_static::lazy_static! { pub static ref EXTERNAL_REFERENCES: v8::ExternalReferences = v8::ExternalReferences::new(&[ v8::ExternalReference { diff --git a/core/examples/http_bench_bin_ops.rs b/core/examples/http_bench_bin_ops.rs index 1f649b235d..371ec60c30 100644 --- a/core/examples/http_bench_bin_ops.rs +++ b/core/examples/http_bench_bin_ops.rs @@ -1,8 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - -#[macro_use] -extern crate log; - use deno_core::error::bad_resource_id; use deno_core::error::AnyError; use deno_core::AsyncRefCell; @@ -128,7 +124,7 @@ fn op_listen( _rid: ResourceId, _bufs: &mut [ZeroCopyBuf], ) -> Result { - debug!("listen"); + log::debug!("listen"); let addr = "127.0.0.1:4544".parse::().unwrap(); let std_listener = std::net::TcpListener::bind(&addr)?; std_listener.set_nonblocking(true)?; @@ -142,7 +138,7 @@ fn op_close( rid: ResourceId, _bufs: &mut [ZeroCopyBuf], ) -> Result { - debug!("close rid={}", rid); + log::debug!("close rid={}", rid); state .resource_table .close(rid) @@ -155,7 +151,7 @@ async fn op_accept( rid: ResourceId, _bufs: BufVec, ) -> Result { - debug!("accept rid={}", rid); + log::debug!("accept rid={}", rid); let listener = state .borrow() @@ -173,7 +169,7 @@ async fn op_read( mut bufs: BufVec, ) -> Result { assert_eq!(bufs.len(), 1, "Invalid number of arguments"); - debug!("read rid={}", rid); + log::debug!("read rid={}", rid); let stream = state .borrow() @@ -190,7 +186,7 @@ async fn op_write( bufs: BufVec, ) -> Result { assert_eq!(bufs.len(), 1, "Invalid number of arguments"); - debug!("write rid={}", rid); + log::debug!("write rid={}", rid); let stream = state .borrow() diff --git a/core/examples/http_bench_json_ops.rs b/core/examples/http_bench_json_ops.rs index c241757471..bc96ce478b 100644 --- a/core/examples/http_bench_json_ops.rs +++ b/core/examples/http_bench_json_ops.rs @@ -1,8 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - -#[macro_use] -extern crate log; - use deno_core::error::bad_resource_id; use deno_core::error::AnyError; use deno_core::AsyncRefCell; @@ -135,7 +131,7 @@ fn op_listen( _args: (), _bufs: &mut [ZeroCopyBuf], ) -> Result { - debug!("listen"); + log::debug!("listen"); let addr = "127.0.0.1:4544".parse::().unwrap(); let std_listener = std::net::TcpListener::bind(&addr)?; std_listener.set_nonblocking(true)?; @@ -149,7 +145,7 @@ fn op_close( args: ResourceId, _buf: &mut [ZeroCopyBuf], ) -> Result<(), AnyError> { - debug!("close rid={}", args.rid); + log::debug!("close rid={}", args.rid); state .resource_table .close(args.rid) @@ -162,7 +158,7 @@ async fn op_accept( args: ResourceId, _bufs: BufVec, ) -> Result { - debug!("accept rid={}", args.rid); + log::debug!("accept rid={}", args.rid); let listener = state .borrow() @@ -180,7 +176,7 @@ async fn op_read( mut bufs: BufVec, ) -> Result { assert_eq!(bufs.len(), 1, "Invalid number of arguments"); - debug!("read rid={}", args.rid); + log::debug!("read rid={}", args.rid); let stream = state .borrow() @@ -197,7 +193,7 @@ async fn op_write( bufs: BufVec, ) -> Result { assert_eq!(bufs.len(), 1, "Invalid number of arguments"); - debug!("write rid={}", args.rid); + log::debug!("write rid={}", args.rid); let stream = state .borrow() diff --git a/core/gotham_state.rs b/core/gotham_state.rs index 04213f9779..fa22878bba 100644 --- a/core/gotham_state.rs +++ b/core/gotham_state.rs @@ -3,6 +3,7 @@ // https://github.com/gotham-rs/gotham/blob/bcbbf8923789e341b7a0e62c59909428ca4e22e2/gotham/src/state/mod.rs // Copyright 2017 Gotham Project Developers. MIT license. +use log::trace; use std::any::Any; use std::any::TypeId; use std::collections::HashMap; diff --git a/core/lib.rs b/core/lib.rs index c65ed7aac6..ea6968b600 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -1,10 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - -#[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate log; - mod async_cancel; mod async_cell; mod bindings; diff --git a/core/modules.rs b/core/modules.rs index b9b99d3b50..8c193bf5bf 100644 --- a/core/modules.rs +++ b/core/modules.rs @@ -21,7 +21,7 @@ use std::sync::atomic::Ordering; use std::task::Context; use std::task::Poll; -lazy_static! { +lazy_static::lazy_static! { pub static ref NEXT_LOAD_ID: AtomicI32 = AtomicI32::new(0); } diff --git a/core/runtime.rs b/core/runtime.rs index 9fa626636f..80fe90d2f1 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -31,6 +31,7 @@ use futures::stream::StreamExt; use futures::stream::StreamFuture; use futures::task::AtomicWaker; use futures::Future; +use log::debug; use std::any::Any; use std::cell::RefCell; use std::collections::HashMap; diff --git a/core/shared_queue.rs b/core/shared_queue.rs index 69d355e95c..dda54a4dfb 100644 --- a/core/shared_queue.rs +++ b/core/shared_queue.rs @@ -18,6 +18,7 @@ SharedQueue Binary Layout use crate::bindings; use crate::ops::OpId; +use log::debug; use rusty_v8 as v8; use std::convert::TryInto; diff --git a/runtime/colors.rs b/runtime/colors.rs index ac4643a0ca..6d020bb6d9 100644 --- a/runtime/colors.rs +++ b/runtime/colors.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - use regex::Regex; use std::env; use std::fmt; @@ -10,15 +9,13 @@ use termcolor::{Ansi, ColorSpec, WriteColor}; #[cfg(windows)] use termcolor::{BufferWriter, ColorChoice}; -lazy_static! { - // STRIP_ANSI_RE and strip_ansi_codes are lifted from the "console" crate. - // Copyright 2017 Armin Ronacher . MIT License. - static ref STRIP_ANSI_RE: Regex = Regex::new( - r"[\x1b\x9b][\[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]" - ).unwrap(); - static ref NO_COLOR: bool = { - env::var_os("NO_COLOR").is_some() - }; +lazy_static::lazy_static! { + // STRIP_ANSI_RE and strip_ansi_codes are lifted from the "console" crate. + // Copyright 2017 Armin Ronacher . MIT License. + static ref STRIP_ANSI_RE: Regex = Regex::new( + r"[\x1b\x9b][\[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]" + ).unwrap(); + static ref NO_COLOR: bool = env::var_os("NO_COLOR").is_some(); } /// Helper function to strip ansi codes. diff --git a/runtime/js.rs b/runtime/js.rs index d61572b213..9ad668467b 100644 --- a/runtime/js.rs +++ b/runtime/js.rs @@ -1,6 +1,6 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - use deno_core::Snapshot; +use log::debug; pub static CLI_SNAPSHOT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.bin")); diff --git a/runtime/lib.rs b/runtime/lib.rs index b30f10bd17..1606e9dfed 100644 --- a/runtime/lib.rs +++ b/runtime/lib.rs @@ -2,11 +2,6 @@ #![deny(warnings)] -#[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate log; - pub use deno_console; pub use deno_crypto; pub use deno_fetch; diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs index e88aa5ba8f..cb20cf471f 100644 --- a/runtime/ops/fs.rs +++ b/runtime/ops/fs.rs @@ -17,6 +17,7 @@ use deno_core::ResourceId; use deno_core::ZeroCopyBuf; use deno_crypto::rand::thread_rng; use deno_crypto::rand::Rng; +use log::debug; use serde::Deserialize; use std::cell::RefCell; use std::convert::From; diff --git a/runtime/ops/io.rs b/runtime/ops/io.rs index 75076f716a..d87cfcf94b 100644 --- a/runtime/ops/io.rs +++ b/runtime/ops/io.rs @@ -42,7 +42,7 @@ use tokio::net::unix; #[cfg(windows)] use std::os::windows::io::FromRawHandle; -lazy_static! { +lazy_static::lazy_static! { /// Due to portability issues on Windows handle to stdout is created from raw /// file descriptor. The caveat of that approach is fact that when this /// handle is dropped underlying file descriptor is closed - that is highly diff --git a/runtime/ops/net.rs b/runtime/ops/net.rs index 4d335c886b..6ec393bac8 100644 --- a/runtime/ops/net.rs +++ b/runtime/ops/net.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - use crate::ops::io::TcpStreamResource; use crate::permissions::Permissions; use crate::resolve_addr::resolve_addr; @@ -21,6 +20,7 @@ use deno_core::RcRef; use deno_core::Resource; use deno_core::ResourceId; use deno_core::ZeroCopyBuf; +use log::debug; use serde::Deserialize; use serde::Serialize; use std::borrow::Cow; diff --git a/runtime/ops/plugin.rs b/runtime/ops/plugin.rs index bfad7c673e..6952cf77f1 100644 --- a/runtime/ops/plugin.rs +++ b/runtime/ops/plugin.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - use crate::metrics::metrics_op; use crate::permissions::Permissions; use deno_core::error::AnyError; @@ -16,6 +15,7 @@ use deno_core::OpState; use deno_core::Resource; use deno_core::ZeroCopyBuf; use dlopen::symbor::Library; +use log::debug; use serde::Deserialize; use std::borrow::Cow; use std::cell::RefCell; diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs index 817a4c70fd..cddde985a9 100644 --- a/runtime/ops/worker_host.rs +++ b/runtime/ops/worker_host.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - use crate::permissions::resolve_read_allowlist; use crate::permissions::resolve_write_allowlist; use crate::permissions::NetDescriptor; @@ -28,6 +27,7 @@ use deno_core::BufVec; use deno_core::ModuleSpecifier; use deno_core::OpState; use deno_core::ZeroCopyBuf; +use log::debug; use std::cell::RefCell; use std::collections::HashMap; use std::collections::HashSet; diff --git a/runtime/permissions.rs b/runtime/permissions.rs index ba150f47ef..af05e69d5c 100644 --- a/runtime/permissions.rs +++ b/runtime/permissions.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - use crate::colors; use crate::fs_util::resolve_from_cwd; use deno_core::error::custom_error; @@ -9,6 +8,7 @@ use deno_core::serde::Deserialize; use deno_core::serde::Serialize; use deno_core::url; use deno_core::ModuleSpecifier; +use log::debug; use std::collections::HashSet; use std::fmt; use std::hash::Hash; @@ -717,7 +717,7 @@ fn permission_prompt(_message: &str) -> bool { } #[cfg(test)] -lazy_static! { +lazy_static::lazy_static! { /// Lock this when you use `set_prompt_result` in a test case. static ref PERMISSION_PROMPT_GUARD: Mutex<()> = Mutex::new(()); } diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index 2a0f60e21c..f5c81e6d48 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - use crate::colors; use crate::inspector::DenoInspector; use crate::inspector::InspectorServer; @@ -24,6 +23,7 @@ use deno_core::JsRuntime; use deno_core::ModuleLoader; use deno_core::ModuleSpecifier; use deno_core::RuntimeOptions; +use log::debug; use std::env; use std::rc::Rc; use std::sync::atomic::AtomicBool; diff --git a/runtime/worker.rs b/runtime/worker.rs index 51fe1dc273..00434b3131 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -21,6 +21,7 @@ use deno_core::ModuleId; use deno_core::ModuleLoader; use deno_core::ModuleSpecifier; use deno_core::RuntimeOptions; +use log::debug; use std::env; use std::rc::Rc; use std::sync::Arc; diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index b021811707..d156f4ebb5 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -1,10 +1,6 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. // Usage: provide a port as argument to run hyper_hello benchmark server // otherwise this starts multiple servers on many ports for test endpoints. - -#[macro_use] -extern crate lazy_static; - use futures::FutureExt; use futures::Stream; use futures::StreamExt; @@ -16,9 +12,8 @@ use hyper::Body; use hyper::Request; use hyper::Response; use hyper::StatusCode; +use lazy_static::lazy_static; use os_pipe::pipe; -#[cfg(unix)] -pub use pty; use regex::Regex; use serde::Serialize; use std::collections::HashMap; @@ -48,6 +43,9 @@ use tokio_rustls::rustls; use tokio_rustls::TlsAcceptor; use tokio_tungstenite::accept_async; +#[cfg(unix)] +pub use pty; + const PORT: u16 = 4545; const TEST_AUTH_TOKEN: &str = "abcdef123456789"; const REDIRECT_PORT: u16 = 4546;