Просмотр исходного кода

In Client Library, use log file facility when EmitDiagnosticNotices is set

Rod Hynes 6 лет назад
Родитель
Сommit
4c2cbfe564
1 измененных файлов с 11 добавлено и 0 удалено
  1. 11 0
      ClientLibrary/clientlib/clientlib.go

+ 11 - 0
ClientLibrary/clientlib/clientlib.go

@@ -154,6 +154,17 @@ func StartTunnel(ctx context.Context,
 		}
 		}
 	}
 	}
 
 
+	// As Client Library doesn't currently implement callbacks, diagnostic
+	// notices aren't relayed to the client application. So, when
+	// EmitDiagnosticNotices is set, initialize the rotating diagnostic log file
+	// facility.
+	if config.EmitDiagnosticNotices {
+		err := psiphon.SetNoticeFiles("", filepath.Join(config.DataStoreDirectory, "diagnostics.log"), 0, 0)
+		if err != nil {
+			return nil, common.ContextErrorMsg(err, "failed to initialize diagnostic logging")
+		}
+	}
+
 	err = psiphon.OpenDataStore(config)
 	err = psiphon.OpenDataStore(config)
 	if err != nil {
 	if err != nil {
 		return nil, common.ContextErrorMsg(err, "failed to open data store")
 		return nil, common.ContextErrorMsg(err, "failed to open data store")