mirror of https://github.com/vitalif/grive2
disable debug log during authenication
parent
54b65bb738
commit
53f9c39941
|
@ -127,8 +127,8 @@ void Drive::SyncFolders( http::Agent *http )
|
||||||
Log( "Synchronizing folders", log::info ) ;
|
Log( "Synchronizing folders", log::info ) ;
|
||||||
|
|
||||||
http::XmlResponse xml ;
|
http::XmlResponse xml ;
|
||||||
http::ResponseLog log( "dir-", ".xml", &xml ) ;
|
// http::ResponseLog log( "dir-", ".xml", &xml ) ;
|
||||||
http->Get( feed_base + "/-/folder?max-results=50&showroot=true", &log, m_http_hdr ) ;
|
http->Get( feed_base + "/-/folder?max-results=50&showroot=true", &xml, m_http_hdr ) ;
|
||||||
|
|
||||||
xml::Node resp = xml.Response() ;
|
xml::Node resp = xml.Response() ;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "Json.hh"
|
#include "Json.hh"
|
||||||
|
|
||||||
#include "http/Agent.hh"
|
#include "http/Agent.hh"
|
||||||
|
#include "util/Log.hh"
|
||||||
|
|
||||||
// for debugging
|
// for debugging
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -62,6 +63,7 @@ void OAuth2::Auth( const std::string& auth_code )
|
||||||
http::JsonResponse resp ;
|
http::JsonResponse resp ;
|
||||||
http::Agent http ;
|
http::Agent http ;
|
||||||
|
|
||||||
|
DisableLog dlog( log::debug ) ;
|
||||||
http.Post( token_url, post, &resp ) ;
|
http.Post( token_url, post, &resp ) ;
|
||||||
|
|
||||||
Json jresp = resp.Response() ;
|
Json jresp = resp.Response() ;
|
||||||
|
@ -98,6 +100,7 @@ void OAuth2::Refresh( )
|
||||||
http::JsonResponse resp ;
|
http::JsonResponse resp ;
|
||||||
http::Agent http ;
|
http::Agent http ;
|
||||||
|
|
||||||
|
DisableLog dlog( log::debug ) ;
|
||||||
http.Post( token_url, post, &resp ) ;
|
http.Post( token_url, post, &resp ) ;
|
||||||
|
|
||||||
m_access = resp.Response()["access_token"].Str() ;
|
m_access = resp.Response()["access_token"].Str() ;
|
||||||
|
|
|
@ -66,10 +66,12 @@ void DefaultLog::Log( const log::Fmt& msg, log::Serverity s )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultLog::Enable( log::Serverity s, bool enable )
|
bool DefaultLog::Enable( log::Serverity s, bool enable )
|
||||||
{
|
{
|
||||||
assert( s >= log::debug && s <= log::critical ) ;
|
assert( s >= log::debug && s <= log::critical ) ;
|
||||||
|
bool prev = m_enabled[s] ;
|
||||||
m_enabled[s] = enable ;
|
m_enabled[s] = enable ;
|
||||||
|
return prev ;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of namespace
|
} // end of namespace
|
||||||
|
|
|
@ -34,7 +34,7 @@ public :
|
||||||
explicit DefaultLog( const std::string& filename ) ;
|
explicit DefaultLog( const std::string& filename ) ;
|
||||||
|
|
||||||
void Log( const log::Fmt& msg, log::Serverity s ) ;
|
void Log( const log::Fmt& msg, log::Serverity s ) ;
|
||||||
void Enable( log::Serverity s, bool enable ) ;
|
bool Enable( log::Serverity s, bool enable ) ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
std::ofstream m_file ;
|
std::ofstream m_file ;
|
||||||
|
|
|
@ -30,8 +30,9 @@ public :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Enable( log::Serverity s, bool enable )
|
bool Enable( log::Serverity s, bool enable )
|
||||||
{
|
{
|
||||||
|
return enable ;
|
||||||
}
|
}
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
@ -66,4 +67,15 @@ void Trace( const std::string& str )
|
||||||
LogBase::Inst()->Log( log::Fmt(str), log::debug ) ;
|
LogBase::Inst()->Log( log::Fmt(str), log::debug ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DisableLog::DisableLog( log::Serverity s ) :
|
||||||
|
m_sev( s ),
|
||||||
|
m_prev( LogBase::Inst()->Enable( s, false ) )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DisableLog::~DisableLog()
|
||||||
|
{
|
||||||
|
LogBase::Inst()->Enable( m_sev, m_prev ) ;
|
||||||
|
}
|
||||||
|
|
||||||
} // end of namespace
|
} // end of namespace
|
||||||
|
|
|
@ -57,7 +57,7 @@ class LogBase
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
virtual void Log( const log::Fmt& msg, log::Serverity s = log::info ) = 0 ;
|
virtual void Log( const log::Fmt& msg, log::Serverity s = log::info ) = 0 ;
|
||||||
virtual void Enable( log::Serverity s, bool enable = true ) = 0 ;
|
virtual bool Enable( log::Serverity s, bool enable = true ) = 0 ;
|
||||||
|
|
||||||
static LogBase* Inst( LogBase *log = 0 ) ;
|
static LogBase* Inst( LogBase *log = 0 ) ;
|
||||||
|
|
||||||
|
@ -66,6 +66,17 @@ protected :
|
||||||
~LogBase() ;
|
~LogBase() ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
class DisableLog
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
DisableLog( log::Serverity s ) ;
|
||||||
|
~DisableLog() ;
|
||||||
|
|
||||||
|
private :
|
||||||
|
log::Serverity m_sev ;
|
||||||
|
bool m_prev ;
|
||||||
|
} ;
|
||||||
|
|
||||||
void Log( const std::string& str, log::Serverity s = log::info ) ;
|
void Log( const std::string& str, log::Serverity s = log::info ) ;
|
||||||
|
|
||||||
template <typename P1>
|
template <typename P1>
|
||||||
|
|
Loading…
Reference in New Issue