@@ -77,6 +77,7 @@ static BuddyState_e TryToStart ( const char * sArgs, CSphString & sError );
77
77
static CSphString GetUrl ( const ListenerDesc_t & tDesc );
78
78
static CSphString BuddyGetPath ( const CSphString & sPath , const CSphString & sPluginDir , bool bHasBuddyPath, int iHostPort, const CSphString & sDataDir );
79
79
static void BuddyStop ();
80
+ static CSphString GetLogLevel ();
80
81
81
82
#if _WIN32
82
83
static CSphString g_sBuddyBind = " --bind=0.0.0.0:9999" ;
@@ -482,12 +483,14 @@ void BuddyStart ( const CSphString & sConfigPath, const CSphString & sPluginDir,
482
483
g_dLogBuf.Resize ( 0 );
483
484
g_sPath = sPath ;
484
485
485
- g_sStartArgs.SetSprintf ( " %s --listen=%s %s %s --threads=%d" ,
486
+ CSphString sLogLevel = GetLogLevel ();
487
+
488
+ g_sStartArgs.SetSprintf ( " %s --listen=%s %s %s --threads=%d %s" ,
486
489
g_sPath.cstr (),
487
490
g_sListener4Buddy.cstr (),
488
491
g_sBuddyBind.scstr (),
489
492
( bTelemetry ? " " : " --disable-telemetry" ),
490
- iThreads );
493
+ iThreads, sLogLevel . scstr () );
491
494
492
495
sphLogDebug ( " [BUDDY] start args: %s" , g_sStartArgs.cstr () );
493
496
@@ -572,6 +575,13 @@ static bool BuddyQueryAddErrorBody ( JsonEscapedBuilder & tBuddyQuery, const Vec
572
575
return true ;
573
576
}
574
577
578
+ // disable Expect: 100-continue
579
+ // as Expect: 100-continue header option added by curl library does not work with the buddy
580
+ static void DisableExpectHeader ( StrVec_t & dHeaders )
581
+ {
582
+ dHeaders.Add ( " Expect:" );
583
+ }
584
+
575
585
static std::pair<bool , CSphString> BuddyQuery ( bool bHttp, Str_t sQueryError , Str_t sPathQuery , Str_t sQuery , http_method eRequestType, const VecTraits_T<BYTE> & dSrcHttpReply )
576
586
{
577
587
if ( !HasBuddy () )
@@ -604,9 +614,7 @@ static std::pair<bool, CSphString> BuddyQuery ( bool bHttp, Str_t sQueryError, S
604
614
605
615
StrVec_t dHeaders;
606
616
dHeaders.Add ( SphSprintf ( " Request-ID: %d_%u" , session::GetConnID (), sphCRC32 ( sQuery .first , sQuery .second , sphRand () ) ) );
607
- // disable Expect: 100-continue
608
- // as Expect: 100-continue header added by curl library do not with the buddy
609
- dHeaders.Add ( " Expect:" );
617
+ DisableExpectHeader ( dHeaders );
610
618
611
619
return PostToHelperUrl ( g_sUrlBuddy, (Str_t)tBuddyQuery, dHeaders );
612
620
}
@@ -947,3 +955,46 @@ CSphString BuddyGetPath ( const CSphString & sConfigPath, const CSphString & sPl
947
955
return sFullPath ;
948
956
}
949
957
#endif
958
+
959
+ static const char * GetBuddyLogLevel ( ESphLogLevel eLogLevel )
960
+ {
961
+ switch ( eLogLevel )
962
+ {
963
+ case SPH_LOG_DEBUG: return " debug" ;
964
+ case SPH_LOG_RPL_DEBUG: return " debug" ;
965
+ case SPH_LOG_VERBOSE_DEBUG: return " debugv" ;
966
+ case SPH_LOG_VERY_VERBOSE_DEBUG: return " debugvv" ;
967
+
968
+ default : return " info" ;
969
+ }
970
+ }
971
+
972
+ CSphString GetLogLevel ()
973
+ {
974
+ CSphString sLogLevel ;
975
+ if ( g_eLogLevel==SPH_LOG_INFO )
976
+ return sLogLevel ;
977
+
978
+ sLogLevel .SetSprintf ( " --log-level=%s" , GetBuddyLogLevel ( g_eLogLevel ) );
979
+ return sLogLevel ;
980
+ }
981
+
982
+ void BuddySetLogLevel ( ESphLogLevel eLogLevel )
983
+ {
984
+ if ( !HasBuddy () )
985
+ return ;
986
+
987
+ JsonEscapedBuilder tBuddyQuery;
988
+ {
989
+ auto tRoot = tBuddyQuery.Object ();
990
+ tBuddyQuery.NamedString ( " log_level" , GetBuddyLogLevel ( eLogLevel ) );
991
+ }
992
+
993
+ StrVec_t dHeaders;
994
+ DisableExpectHeader ( dHeaders );
995
+
996
+ CSphString sUrl ;
997
+ sUrl .SetSprintf ( " %s/config" , g_sUrlBuddy.cstr () );
998
+
999
+ PostToHelperUrl ( sUrl , (Str_t)tBuddyQuery, dHeaders );
1000
+ }
0 commit comments