File tree Expand file tree Collapse file tree 4 files changed +29
-3
lines changed
Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -24,3 +24,4 @@ base64 = "0.11"
2424lazy_static = " 1.4.0"
2525envy = " 0.4"
2626rand = " 0.7"
27+ log = " 0.4"
Original file line number Diff line number Diff line change @@ -55,6 +55,29 @@ fn main() {
5555}
5656```
5757
58+ ### Log Config
59+
60+ In order to produce log output, executables have to use a logger implementation compatible with the log facade.
61+ There are many available implementations to chose from, for example:
62+
63+ [ env_logger] ( https://github.com/sebasmagri/env_logger/ ) is an excellent way to log in your executables.
64+
65+ ```
66+ [dependencies]
67+ log = "0.4"
68+ env_logger = "0.7"
69+ ```
70+
71+ ```
72+ fn main() {
73+ env_logger::init();
74+
75+ info!("starting up");
76+
77+ // ...
78+ }
79+ ```
80+
5881## Subscribing
5982
6083### Connecting to existing subscription
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use goauth::auth::JwtClaims;
55use goauth:: scopes:: Scope ;
66use hyper:: client:: HttpConnector ;
77use hyper_tls:: HttpsConnector ;
8+ use log:: { error, info} ;
89use smpl_jwt:: Jwt ;
910use std:: sync:: atomic:: { AtomicBool , Ordering } ;
1011use std:: sync:: { Arc , RwLock } ;
@@ -105,7 +106,7 @@ impl Client {
105106 int. tick ( ) . await ;
106107 println ! ( "Renewing pubsub token" ) ;
107108 if let Err ( e) = client. refresh_token ( ) {
108- eprintln ! ( "Failed to update token: {}" , e) ;
109+ error ! ( "Failed to update token: {}" , e) ;
109110 }
110111 }
111112 }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use crate::message::{FromPubSubMessage, Message};
44use bytes:: buf:: BufExt as _;
55use hyper:: { Method , StatusCode } ;
66use lazy_static:: lazy_static;
7+ use log:: error;
78use serde_derive:: { Deserialize , Serialize } ;
89use std:: env;
910
@@ -53,7 +54,7 @@ impl Subscription {
5354 * req. uri_mut ( ) = uri. clone ( ) ;
5455
5556 if let Err ( e) = client. hyper_client ( ) . request ( req) . await {
56- eprintln ! ( "Failed ACk: {}" , e) ;
57+ error ! ( "Failed ACk: {}" , e) ;
5758 }
5859 }
5960
@@ -98,7 +99,7 @@ impl Subscription {
9899 . filter_map ( |packet| match T :: from ( packet. message ) {
99100 Ok ( o) => Some ( o) ,
100101 Err ( e) => {
101- eprintln ! ( "Failed converting pubsub {}" , e, ) ;
102+ error ! ( "Failed converting pubsub {}" , e, ) ;
102103 None
103104 }
104105 } )
You can’t perform that action at this time.
0 commit comments