Runtime logging. (#3821)

* Implement Printable for tuples.

* Add debugging function.

* Add debug 1.

* Implement  for everything.

* RuntimeDebug derive.

* Introduce RuntimeDebug.

* Add some dummy logging.

* Replace RuntimeDebug with Debug.

* Revert "Replace RuntimeDebug with Debug."

This reverts commit bc47070a8cb30241b2b590b2fa29fd195088162f.

* Working on Debug for all.

* Fix bounds.

* Add debug utils.

* Implement runtime logging.

* Add some docs and clean up.

* Clean up derives.

* Fix custom derive impl.

* Bump runtime.

* Fix long lines.

* Fix doc test.

* Use CARGO_CFG_STD.

* Revert "Use CARGO_CFG_STD."

This reverts commit ea429566de18ed0fa052571b359eb9826a64a9f4.

* Use parse_macro_input

* Update lockfile.

* Apply review suggestions.

* Remove stray re-export.

* Add no-std impl.

* Update lockfile.
This commit is contained in:
Tomasz Drwięga
2019-10-22 14:13:44 +02:00
committed by Bastian Köcher
parent 934d7aac1c
commit 20a3989785
86 changed files with 1266 additions and 469 deletions
@@ -51,6 +51,7 @@ use rstd::str;
use rstd::prelude::Vec;
#[cfg(not(feature = "std"))]
use rstd::prelude::vec;
use primitives::RuntimeDebug;
use primitives::offchain::{
Timestamp,
HttpRequestId as RequestId,
@@ -59,8 +60,7 @@ use primitives::offchain::{
};
/// Request method (HTTP verb)
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, PartialEq, Eq, RuntimeDebug)]
pub enum Method {
/// GET request
Get,
@@ -93,8 +93,7 @@ mod header {
use super::*;
/// A header type.
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, PartialEq, Eq, RuntimeDebug)]
pub struct Header {
name: Vec<u8>,
value: Vec<u8>,
@@ -128,8 +127,7 @@ mod header {
}
/// An HTTP request builder.
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, PartialEq, Eq, RuntimeDebug)]
pub struct Request<'a, T = Vec<&'static [u8]>> {
/// Request method
pub method: Method,
@@ -249,8 +247,7 @@ impl<'a, I: AsRef<[u8]>, T: IntoIterator<Item=I>> Request<'a, T> {
}
/// A request error
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, PartialEq, Eq, RuntimeDebug)]
pub enum Error {
/// Deadline has been reached.
DeadlineReached,
@@ -261,8 +258,7 @@ pub enum Error {
}
/// A struct representing an uncompleted http request.
#[derive(PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(PartialEq, Eq, RuntimeDebug)]
pub struct PendingRequest {
/// Request ID
pub id: RequestId,
@@ -323,7 +319,7 @@ impl PendingRequest {
}
/// A HTTP response.
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(RuntimeDebug)]
pub struct Response {
/// Request id
pub id: RequestId,
@@ -452,8 +448,7 @@ impl Iterator for ResponseBody {
}
/// A collection of Headers in the response.
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, PartialEq, Eq, RuntimeDebug)]
pub struct Headers {
/// Raw headers
pub raw: Vec<(Vec<u8>, Vec<u8>)>,
@@ -483,8 +478,7 @@ impl Headers {
}
/// A custom iterator traversing all the headers.
#[derive(Clone)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, RuntimeDebug)]
pub struct HeadersIterator<'a> {
collection: &'a [(Vec<u8>, Vec<u8>)],
index: Option<usize>,