pub struct LoggingClientBuilder { /* private fields */ }Implementations§
Source§impl LoggingClientBuilder
impl LoggingClientBuilder
pub fn new(socket: impl Into<String>) -> Self
Sourcepub fn auth_token(self, token: impl Into<String>) -> Self
pub fn auth_token(self, token: impl Into<String>) -> Self
Examples found in repository?
examples/logging.rs (line 19)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let socket = env::var("FALCORN_LOG_SOCKET").unwrap_or_else(|_| DEFAULT_LOG_SOCKET.to_string());
10 let token = env::var("FALCORN_LOG_TOKEN").ok();
11 let client_name = env::var("FALCORN_LOG_CLIENT").ok();
12 let filter = env::var("FALCORN_LOG_FILTER")
13 .ok()
14 .and_then(|value| value.parse::<u8>().ok())
15 .unwrap_or(PLUGIN_FILTER_ALL);
16
17 let mut builder = LoggingClient::builder(socket);
18 if let Some(token) = token {
19 builder = builder.auth_token(token);
20 }
21 if let Some(client_name) = client_name {
22 builder = builder.client_name(client_name);
23 }
24 builder = builder.filter_mask(filter);
25
26 let mut client = builder.connect()?;
27 println!(
28 "Connected. Filters: log={} access={} metrics={} (mask={:#04x})",
29 filter & PLUGIN_FILTER_LOG_MESSAGE != 0,
30 filter & PLUGIN_FILTER_ACCESS_LOG != 0,
31 filter & PLUGIN_FILTER_METRICS != 0,
32 filter
33 );
34
35 loop {
36 let event = client.next_event()?;
37 match event {
38 falcorn_sdk::proto::logging::PluginEvent::LogMessage {
39 ts_millis,
40 level,
41 pid,
42 worker_id,
43 message,
44 } => {
45 println!(
46 "[{}] {} pid={} worker={:?} - {}",
47 ts_millis,
48 level.as_str(),
49 pid,
50 worker_id,
51 message
52 );
53 }
54 falcorn_sdk::proto::logging::PluginEvent::AccessLog {
55 ts_millis,
56 remote,
57 method,
58 uri,
59 status,
60 duration_micros,
61 ..
62 } => {
63 println!(
64 "[{}] {} {} {} status={} {}us",
65 ts_millis, remote, method, uri, status, duration_micros
66 );
67 }
68 falcorn_sdk::proto::logging::PluginEvent::Metrics(metrics) => {
69 println!(
70 "METRICS rps={:.2} success_rate={:.4} avg_us={} active_conn={}",
71 metrics.requests_per_second,
72 metrics.success_rate,
73 metrics.avg_response_time_micros,
74 metrics.active_connections
75 );
76 }
77 }
78 }
79}Sourcepub fn client_name(self, name: impl Into<String>) -> Self
pub fn client_name(self, name: impl Into<String>) -> Self
Examples found in repository?
examples/logging.rs (line 22)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let socket = env::var("FALCORN_LOG_SOCKET").unwrap_or_else(|_| DEFAULT_LOG_SOCKET.to_string());
10 let token = env::var("FALCORN_LOG_TOKEN").ok();
11 let client_name = env::var("FALCORN_LOG_CLIENT").ok();
12 let filter = env::var("FALCORN_LOG_FILTER")
13 .ok()
14 .and_then(|value| value.parse::<u8>().ok())
15 .unwrap_or(PLUGIN_FILTER_ALL);
16
17 let mut builder = LoggingClient::builder(socket);
18 if let Some(token) = token {
19 builder = builder.auth_token(token);
20 }
21 if let Some(client_name) = client_name {
22 builder = builder.client_name(client_name);
23 }
24 builder = builder.filter_mask(filter);
25
26 let mut client = builder.connect()?;
27 println!(
28 "Connected. Filters: log={} access={} metrics={} (mask={:#04x})",
29 filter & PLUGIN_FILTER_LOG_MESSAGE != 0,
30 filter & PLUGIN_FILTER_ACCESS_LOG != 0,
31 filter & PLUGIN_FILTER_METRICS != 0,
32 filter
33 );
34
35 loop {
36 let event = client.next_event()?;
37 match event {
38 falcorn_sdk::proto::logging::PluginEvent::LogMessage {
39 ts_millis,
40 level,
41 pid,
42 worker_id,
43 message,
44 } => {
45 println!(
46 "[{}] {} pid={} worker={:?} - {}",
47 ts_millis,
48 level.as_str(),
49 pid,
50 worker_id,
51 message
52 );
53 }
54 falcorn_sdk::proto::logging::PluginEvent::AccessLog {
55 ts_millis,
56 remote,
57 method,
58 uri,
59 status,
60 duration_micros,
61 ..
62 } => {
63 println!(
64 "[{}] {} {} {} status={} {}us",
65 ts_millis, remote, method, uri, status, duration_micros
66 );
67 }
68 falcorn_sdk::proto::logging::PluginEvent::Metrics(metrics) => {
69 println!(
70 "METRICS rps={:.2} success_rate={:.4} avg_us={} active_conn={}",
71 metrics.requests_per_second,
72 metrics.success_rate,
73 metrics.avg_response_time_micros,
74 metrics.active_connections
75 );
76 }
77 }
78 }
79}Sourcepub fn filter_mask(self, mask: u8) -> Self
pub fn filter_mask(self, mask: u8) -> Self
Examples found in repository?
examples/logging.rs (line 24)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let socket = env::var("FALCORN_LOG_SOCKET").unwrap_or_else(|_| DEFAULT_LOG_SOCKET.to_string());
10 let token = env::var("FALCORN_LOG_TOKEN").ok();
11 let client_name = env::var("FALCORN_LOG_CLIENT").ok();
12 let filter = env::var("FALCORN_LOG_FILTER")
13 .ok()
14 .and_then(|value| value.parse::<u8>().ok())
15 .unwrap_or(PLUGIN_FILTER_ALL);
16
17 let mut builder = LoggingClient::builder(socket);
18 if let Some(token) = token {
19 builder = builder.auth_token(token);
20 }
21 if let Some(client_name) = client_name {
22 builder = builder.client_name(client_name);
23 }
24 builder = builder.filter_mask(filter);
25
26 let mut client = builder.connect()?;
27 println!(
28 "Connected. Filters: log={} access={} metrics={} (mask={:#04x})",
29 filter & PLUGIN_FILTER_LOG_MESSAGE != 0,
30 filter & PLUGIN_FILTER_ACCESS_LOG != 0,
31 filter & PLUGIN_FILTER_METRICS != 0,
32 filter
33 );
34
35 loop {
36 let event = client.next_event()?;
37 match event {
38 falcorn_sdk::proto::logging::PluginEvent::LogMessage {
39 ts_millis,
40 level,
41 pid,
42 worker_id,
43 message,
44 } => {
45 println!(
46 "[{}] {} pid={} worker={:?} - {}",
47 ts_millis,
48 level.as_str(),
49 pid,
50 worker_id,
51 message
52 );
53 }
54 falcorn_sdk::proto::logging::PluginEvent::AccessLog {
55 ts_millis,
56 remote,
57 method,
58 uri,
59 status,
60 duration_micros,
61 ..
62 } => {
63 println!(
64 "[{}] {} {} {} status={} {}us",
65 ts_millis, remote, method, uri, status, duration_micros
66 );
67 }
68 falcorn_sdk::proto::logging::PluginEvent::Metrics(metrics) => {
69 println!(
70 "METRICS rps={:.2} success_rate={:.4} avg_us={} active_conn={}",
71 metrics.requests_per_second,
72 metrics.success_rate,
73 metrics.avg_response_time_micros,
74 metrics.active_connections
75 );
76 }
77 }
78 }
79}pub fn read_timeout(self, timeout: Duration) -> Self
pub fn write_timeout(self, timeout: Duration) -> Self
Sourcepub fn connect(self) -> Result<LoggingClient>
pub fn connect(self) -> Result<LoggingClient>
Examples found in repository?
examples/logging.rs (line 26)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let socket = env::var("FALCORN_LOG_SOCKET").unwrap_or_else(|_| DEFAULT_LOG_SOCKET.to_string());
10 let token = env::var("FALCORN_LOG_TOKEN").ok();
11 let client_name = env::var("FALCORN_LOG_CLIENT").ok();
12 let filter = env::var("FALCORN_LOG_FILTER")
13 .ok()
14 .and_then(|value| value.parse::<u8>().ok())
15 .unwrap_or(PLUGIN_FILTER_ALL);
16
17 let mut builder = LoggingClient::builder(socket);
18 if let Some(token) = token {
19 builder = builder.auth_token(token);
20 }
21 if let Some(client_name) = client_name {
22 builder = builder.client_name(client_name);
23 }
24 builder = builder.filter_mask(filter);
25
26 let mut client = builder.connect()?;
27 println!(
28 "Connected. Filters: log={} access={} metrics={} (mask={:#04x})",
29 filter & PLUGIN_FILTER_LOG_MESSAGE != 0,
30 filter & PLUGIN_FILTER_ACCESS_LOG != 0,
31 filter & PLUGIN_FILTER_METRICS != 0,
32 filter
33 );
34
35 loop {
36 let event = client.next_event()?;
37 match event {
38 falcorn_sdk::proto::logging::PluginEvent::LogMessage {
39 ts_millis,
40 level,
41 pid,
42 worker_id,
43 message,
44 } => {
45 println!(
46 "[{}] {} pid={} worker={:?} - {}",
47 ts_millis,
48 level.as_str(),
49 pid,
50 worker_id,
51 message
52 );
53 }
54 falcorn_sdk::proto::logging::PluginEvent::AccessLog {
55 ts_millis,
56 remote,
57 method,
58 uri,
59 status,
60 duration_micros,
61 ..
62 } => {
63 println!(
64 "[{}] {} {} {} status={} {}us",
65 ts_millis, remote, method, uri, status, duration_micros
66 );
67 }
68 falcorn_sdk::proto::logging::PluginEvent::Metrics(metrics) => {
69 println!(
70 "METRICS rps={:.2} success_rate={:.4} avg_us={} active_conn={}",
71 metrics.requests_per_second,
72 metrics.success_rate,
73 metrics.avg_response_time_micros,
74 metrics.active_connections
75 );
76 }
77 }
78 }
79}Trait Implementations§
Source§impl Clone for LoggingClientBuilder
impl Clone for LoggingClientBuilder
Source§fn clone(&self) -> LoggingClientBuilder
fn clone(&self) -> LoggingClientBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for LoggingClientBuilder
impl RefUnwindSafe for LoggingClientBuilder
impl Send for LoggingClientBuilder
impl Sync for LoggingClientBuilder
impl Unpin for LoggingClientBuilder
impl UnsafeUnpin for LoggingClientBuilder
impl UnwindSafe for LoggingClientBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more