File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use crate :: dispatch:: DISPATCH ;
22use serde:: Serialize ;
3+ use std:: fmt;
34use std:: sync:: atomic:: { AtomicU64 , Ordering } ;
45use time:: OffsetDateTime ;
56
@@ -104,6 +105,20 @@ pub enum LogLevel {
104105 Silly ,
105106}
106107
108+ impl fmt:: Display for LogLevel {
109+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
110+ match self {
111+ LogLevel :: Error => write ! ( f, "error" ) ,
112+ LogLevel :: Warn => write ! ( f, "warn" ) ,
113+ LogLevel :: Info => write ! ( f, "info" ) ,
114+ LogLevel :: Http => write ! ( f, "http" ) ,
115+ LogLevel :: Verbose => write ! ( f, "verbose" ) ,
116+ LogLevel :: Debug => write ! ( f, "debug" ) ,
117+ LogLevel :: Silly => write ! ( f, "silly" ) ,
118+ }
119+ }
120+ }
121+
107122pub trait IntoLog {
108123 fn into_log ( self ) -> String ;
109124}
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ pub struct MetricMessage {
3737 pub operation : MetricOperation ,
3838}
3939
40- #[ derive( Debug , Serialize ) ]
40+ #[ derive( Debug , Clone , Serialize ) ]
4141#[ serde( rename_all = "camelCase" ) ]
4242pub enum MetricOperation {
4343 Set ,
Original file line number Diff line number Diff line change 1+ use crate :: metric:: MetricOperation ;
2+
13use super :: {
24 MessageType , PropagatorConfig ,
35 worker:: { Worker , WorkerJob } ,
@@ -22,17 +24,28 @@ impl WorkerJob for HttpPropagator {
2224 MessageType :: Log ( log) => {
2325 ureq:: post ( & log_url)
2426 . header ( "project-api-key" , & api_key)
25- . send_json ( log)
27+ . send_json ( & log)
2628 . unwrap ( ) ;
2729 if cfg. verbose {
28- println ! ( "Log sent" , ) ;
30+ println ! ( "Log sent: {} {}" , log . level , log . message ) ;
2931 }
3032 }
3133 MessageType :: Metric ( metric) => {
3234 ureq:: put ( & metric_url)
3335 . header ( "project-api-key" , & api_key)
34- . send_json ( metric)
36+ . send_json ( & metric)
3537 . unwrap ( ) ;
38+ if cfg. verbose {
39+ match metric. operation . clone ( ) {
40+ MetricOperation :: Set => {
41+ println ! ( "Metric set: {} = {}" , metric. name, metric. value) ;
42+ }
43+
44+ MetricOperation :: Change => {
45+ println ! ( "Metric changed: {} = {}" , metric. name, metric. value) ;
46+ }
47+ }
48+ }
3649 }
3750 } ,
3851 Err ( e) => {
You can’t perform that action at this time.
0 commit comments