mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-01-01 04:55:40 +00:00
35cbae61bc
* Respond directly with LemmyError Instrument Perform implementations for more precise traces Use ApiError to format JSON errors when messages are present Keep SpanTrace output in LemmyError Display impl * Hide SpanTrace debug output from LemmyError * Don't log when entering spans, only when leaving * Update actix-web * Update actix-rt * Add newline after error info in LemmyError Display impl * Propogate span information to blocking operations * Instrument apub functions * Use skip_all for more instrument attributes, don't skip 'self' in some api actions * Make message a static string * Send proper JSON over websocket * Add 'message' to LemmyError display if present * Use a quieter root span builder, don't pretty-print logs * Keep passwords and emails out of logs * Re-enable logging Login * Instrument feeds * Emit our own errors * Move error log after status code recording * Make Sensitive generic over the inner type * Remove line that logged secrets
99 lines
1.6 KiB
Rust
99 lines
1.6 KiB
Rust
use std::{
|
|
borrow::Borrow,
|
|
ops::{Deref, DerefMut},
|
|
};
|
|
|
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Deserialize, serde::Serialize)]
|
|
#[serde(transparent)]
|
|
pub struct Sensitive<T>(T);
|
|
|
|
impl<T> Sensitive<T> {
|
|
pub fn new(item: T) -> Self {
|
|
Sensitive(item)
|
|
}
|
|
|
|
pub fn into_inner(this: Self) -> T {
|
|
this.0
|
|
}
|
|
}
|
|
|
|
impl<T> std::fmt::Debug for Sensitive<T> {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
f.debug_struct("Sensitive").finish()
|
|
}
|
|
}
|
|
|
|
impl<T> AsRef<T> for Sensitive<T> {
|
|
fn as_ref(&self) -> &T {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
impl AsRef<str> for Sensitive<String> {
|
|
fn as_ref(&self) -> &str {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
impl AsRef<[u8]> for Sensitive<String> {
|
|
fn as_ref(&self) -> &[u8] {
|
|
self.0.as_ref()
|
|
}
|
|
}
|
|
|
|
impl AsRef<[u8]> for Sensitive<Vec<u8>> {
|
|
fn as_ref(&self) -> &[u8] {
|
|
self.0.as_ref()
|
|
}
|
|
}
|
|
|
|
impl<T> AsMut<T> for Sensitive<T> {
|
|
fn as_mut(&mut self) -> &mut T {
|
|
&mut self.0
|
|
}
|
|
}
|
|
|
|
impl AsMut<str> for Sensitive<String> {
|
|
fn as_mut(&mut self) -> &mut str {
|
|
&mut self.0
|
|
}
|
|
}
|
|
|
|
impl Deref for Sensitive<String> {
|
|
type Target = str;
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
impl DerefMut for Sensitive<String> {
|
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
&mut self.0
|
|
}
|
|
}
|
|
|
|
impl<T> From<T> for Sensitive<T> {
|
|
fn from(t: T) -> Self {
|
|
Sensitive(t)
|
|
}
|
|
}
|
|
|
|
impl From<&str> for Sensitive<String> {
|
|
fn from(s: &str) -> Self {
|
|
Sensitive(s.into())
|
|
}
|
|
}
|
|
|
|
impl<T> Borrow<T> for Sensitive<T> {
|
|
fn borrow(&self) -> &T {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
impl Borrow<str> for Sensitive<String> {
|
|
fn borrow(&self) -> &str {
|
|
&self.0
|
|
}
|
|
}
|