Skip to content

Commit 532a906

Browse files
committed
format logs and strings inline
1 parent 834412f commit 532a906

File tree

3 files changed

+18
-26
lines changed

3 files changed

+18
-26
lines changed

clarity-serialization/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,7 @@ pub fn version_string(pkg_name: &str, pkg_version: &str) -> String {
5252
let git_tree_clean = GIT_TREE_CLEAN.unwrap_or("");
5353

5454
format!(
55-
"{} {} ({}:{}{}, {} build, {} [{}])",
56-
pkg_name,
57-
pkg_version,
58-
&git_branch,
59-
git_commit,
60-
git_tree_clean,
61-
BUILD_TYPE,
55+
"{pkg_name} {pkg_version} ({git_branch}:{git_commit}{git_tree_clean}, {BUILD_TYPE} build {}, [{}])",
6256
std::env::consts::OS,
6357
std::env::consts::ARCH
6458
)

clarity-serialization/src/types/mod.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ impl Value {
10231023
Ok(String::from_utf8(data)
10241024
.map_err(|_| CodecError::Expect("Non UTF-8 data in string".into()))?)
10251025
} else {
1026-
error!("Value '{:?}' is not an ASCII string", &self);
1026+
error!("Value '{self:?}' is not an ASCII string");
10271027
Err(CodecError::Expect("Expected ASCII string".into()))
10281028
}
10291029
}
@@ -1032,7 +1032,7 @@ impl Value {
10321032
if let Value::UInt(inner) = self {
10331033
Ok(inner)
10341034
} else {
1035-
error!("Value '{:?}' is not a u128", &self);
1035+
error!("Value '{self:?}' is not a u128");
10361036
Err(CodecError::Expect("Expected u128".into()))
10371037
}
10381038
}
@@ -1041,7 +1041,7 @@ impl Value {
10411041
if let Value::Int(inner) = self {
10421042
Ok(inner)
10431043
} else {
1044-
error!("Value '{:?}' is not an i128", &self);
1044+
error!("Value '{self:?}' is not an i128");
10451045
Err(CodecError::Expect("Expected i128".into()))
10461046
}
10471047
}
@@ -1052,14 +1052,13 @@ impl Value {
10521052
Ok(buffdata.data)
10531053
} else {
10541054
error!(
1055-
"Value buffer has len {}, expected {}",
1056-
buffdata.data.len(),
1057-
sz
1055+
"Value buffer has len {}, expected {sz}",
1056+
buffdata.data.len()
10581057
);
10591058
Err(CodecError::Expect("Unexpected buff length".into()))
10601059
}
10611060
} else {
1062-
error!("Value '{:?}' is not a buff", &self);
1061+
error!("Value '{self:?}' is not a buff");
10631062
Err(CodecError::Expect("Expected buff".into()))
10641063
}
10651064
}
@@ -1068,7 +1067,7 @@ impl Value {
10681067
if let Value::Sequence(SequenceData::List(listdata)) = self {
10691068
Ok(listdata.data)
10701069
} else {
1071-
error!("Value '{:?}' is not a list", &self);
1070+
error!("Value '{self:?}' is not a list");
10721071
Err(CodecError::Expect("Expected list".into()))
10731072
}
10741073
}
@@ -1087,7 +1086,7 @@ impl Value {
10871086
if let Value::Bool(b) = self {
10881087
Ok(b)
10891088
} else {
1090-
error!("Value '{:?}' is not a bool", &self);
1089+
error!("Value '{self:?}' is not a bool");
10911090
Err(CodecError::Expect("Expected bool".into()))
10921091
}
10931092
}
@@ -1096,7 +1095,7 @@ impl Value {
10961095
if let Value::Tuple(data) = self {
10971096
Ok(data)
10981097
} else {
1099-
error!("Value '{:?}' is not a tuple", &self);
1098+
error!("Value '{self:?}' is not a tuple");
11001099
Err(CodecError::Expect("Expected tuple".into()))
11011100
}
11021101
}
@@ -1108,7 +1107,7 @@ impl Value {
11081107
None => Ok(None),
11091108
}
11101109
} else {
1111-
error!("Value '{:?}' is not an optional", &self);
1110+
error!("Value '{self:?}' is not an optional");
11121111
Err(CodecError::Expect("Expected optional".into()))
11131112
}
11141113
}
@@ -1117,7 +1116,7 @@ impl Value {
11171116
if let Value::Principal(p) = self {
11181117
Ok(p)
11191118
} else {
1120-
error!("Value '{:?}' is not a principal", &self);
1119+
error!("Value '{self:?}' is not a principal");
11211120
Err(CodecError::Expect("Expected principal".into()))
11221121
}
11231122
}
@@ -1126,7 +1125,7 @@ impl Value {
11261125
if let Value::CallableContract(t) = self {
11271126
Ok(t)
11281127
} else {
1129-
error!("Value '{:?}' is not a callable contract", &self);
1128+
error!("Value '{self:?}' is not a callable contract");
11301129
Err(CodecError::Expect("Expected callable".into()))
11311130
}
11321131
}
@@ -1139,7 +1138,7 @@ impl Value {
11391138
Ok(Err(*res_data.data))
11401139
}
11411140
} else {
1142-
error!("Value '{:?}' is not a response", &self);
1141+
error!("Value '{self:?}' is not a response");
11431142
Err(CodecError::Expect("Expected response".into()))
11441143
}
11451144
}
@@ -1153,7 +1152,7 @@ impl Value {
11531152
Err(CodecError::Expect("Expected ok response".into()))
11541153
}
11551154
} else {
1156-
error!("Value '{:?}' is not a response", &self);
1155+
error!("Value '{self:?}' is not a response");
11571156
Err(CodecError::Expect("Expected response".into()))
11581157
}
11591158
}
@@ -1167,7 +1166,7 @@ impl Value {
11671166
Err(CodecError::Expect("Expected err response".into()))
11681167
}
11691168
} else {
1170-
error!("Value '{:?}' is not a response", &self);
1169+
error!("Value '{self:?}' is not a response");
11711170
Err(CodecError::Expect("Expected response".into()))
11721171
}
11731172
}

clarity-serialization/src/types/serialization.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,7 @@ impl Value {
483483
if bytes_read > expect_size as u64 {
484484
// this can happen due to sanitization, so its no longer indicative of a *problem* with the node.
485485
debug!(
486-
"Deserialized more bytes than expected size during deserialization. Expected size = {}, bytes read = {}, type = {}",
487-
expect_size, bytes_read, expected_type,
486+
"Deserialized more bytes than expected size during deserialization. Expected size = {expect_size}, bytes read = {bytes_read}, type = {expected_type:?}"
488487
);
489488
}
490489
}
@@ -1297,7 +1296,7 @@ impl StacksMessageCodec for Value {
12971296
fn consensus_deserialize<R: Read>(fd: &mut R) -> Result<Value, codec_error> {
12981297
Value::deserialize_read(fd, None, false).map_err(|e| match e {
12991298
CodecError::Io(io_e) => codec_error::ReadError(io_e),
1300-
_ => codec_error::DeserializeError(format!("Failed to decode clarity value: {:?}", &e)),
1299+
_ => codec_error::DeserializeError(format!("Failed to decode clarity value: {e:?}")),
13011300
})
13021301
}
13031302
}

0 commit comments

Comments
 (0)