From e6c2f89f03479e0dfd80226f68d51ffc3dd1a2b4 Mon Sep 17 00:00:00 2001 From: frank Date: Tue, 10 Dec 2024 09:19:08 +0800 Subject: [PATCH] chore_: remove endpoint InitLogging (#6182) --- mobile/init_logging_test.go | 47 ------------------------------------- mobile/status.go | 31 ------------------------ 2 files changed, 78 deletions(-) delete mode 100644 mobile/init_logging_test.go diff --git a/mobile/init_logging_test.go b/mobile/init_logging_test.go deleted file mode 100644 index 4f2159b71..000000000 --- a/mobile/init_logging_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package statusgo - -import ( - "fmt" - "os" - "path" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/status-im/status-go/logutils/requestlog" - "github.com/status-im/status-go/protocol/requests" -) - -func TestInitLogging(t *testing.T) { - tempDir := t.TempDir() - t.Logf("temp dir: %s", tempDir) - gethLogFile := path.Join(tempDir, "geth.log") - requestsLogFile := path.Join(tempDir, "requests.log") - logSettings := fmt.Sprintf(`{"LogRequestGo": true, "LogRequestFile": "%s", "File": "%s", "Level": "INFO", "Enabled": true, "MobileSystem": false}`, requestsLogFile, gethLogFile) - response := InitLogging(logSettings) - require.Equal(t, `{"error":""}`, response) - _, err := os.Stat(gethLogFile) - require.NoError(t, err) - require.NotNil(t, requestlog.GetRequestLogger()) - - // requests log file should not be created yet - _, err = os.Stat(requestsLogFile) - require.Error(t, err) - require.True(t, os.IsNotExist(err)) - - createAccountRequest := &requests.CreateAccount{ - DisplayName: "some-display-name", - CustomizationColor: "#ffffff", - Password: "some-password", - RootDataDir: tempDir, - LogFilePath: gethLogFile, - } - _, err = statusBackend.CreateAccountAndLogin(createAccountRequest) - require.NoError(t, err) - result := CallPrivateRPC(`{"jsonrpc":"2.0","method":"settings_getSettings","params":[],"id":1}`) - require.NotContains(t, result, "error") - // Check if request log file exists now - _, err = os.Stat(requestsLogFile) - require.NoError(t, err) - require.FileExists(t, requestsLogFile) -} diff --git a/mobile/status.go b/mobile/status.go index a0ac63b46..189a93816 100644 --- a/mobile/status.go +++ b/mobile/status.go @@ -2218,37 +2218,6 @@ func deserializeAndCompressKey(DesktopKey string) string { return CompressPublicKey(sanitisedKey) } -type InitLoggingRequest struct { - logutils.LogSettings - LogRequestGo bool `json:"LogRequestGo"` - LogRequestFile string `json:"LogRequestFile"` -} - -// InitLogging The InitLogging function should be called when the application starts. -// This ensures that we can capture logs before the user login. Subsequent calls will update the logger settings. -// Before this, we can only capture logs after user login since we will only configure the logging after the login process. -// Deprecated: Use InitializeApplication instead -func InitLogging(logSettingsJSON string) string { - var logSettings InitLoggingRequest - var err error - if err = json.Unmarshal([]byte(logSettingsJSON), &logSettings); err != nil { - return makeJSONResponse(err) - } - - if err = logutils.OverrideRootLoggerWithConfig(logSettings.LogSettings); err == nil { - logutils.ZapLogger().Info("logging initialised", zap.String("logSettings", logSettingsJSON)) - } - - if logSettings.LogRequestGo { - err = requestlog.ConfigureAndEnableRequestLogging(logSettings.LogRequestFile) - if err != nil { - return makeJSONResponse(err) - } - } - - return makeJSONResponse(err) -} - func GetRandomMnemonic() string { mnemonic, err := account.GetRandomMnemonic() if err != nil {