1
0
mirror of https://github.com/bitwarden/mobile synced 2025-02-05 21:05:00 +01:00

Remove verbose state & value storage debug logging (#1857)

This commit is contained in:
Matt Portune 2022-03-21 16:44:54 -04:00 committed by GitHub
parent 840925c479
commit f10307c72d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,6 @@
using System; using System;
using Bit.Core.Abstractions; using Bit.Core.Abstractions;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Core.Enums; using Bit.Core.Enums;
@ -9,7 +8,6 @@ using Bit.Core.Models.Data;
using Bit.Core.Models.Domain; using Bit.Core.Models.Domain;
using Bit.Core.Models.View; using Bit.Core.Models.View;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Newtonsoft.Json;
namespace Bit.Core.Services namespace Bit.Core.Services
{ {
@ -1183,20 +1181,16 @@ namespace Bit.Core.Services
private async Task<T> GetValueAsync<T>(string key, StorageOptions options) private async Task<T> GetValueAsync<T>(string key, StorageOptions options)
{ {
var value = await GetStorageService(options).GetAsync<T>(key); return await GetStorageService(options).GetAsync<T>(key);
Log("GET", options, key, JsonConvert.SerializeObject(value));
return value;
} }
private async Task SetValueAsync<T>(string key, T value, StorageOptions options) private async Task SetValueAsync<T>(string key, T value, StorageOptions options)
{ {
if (value == null) if (value == null)
{ {
Log("REMOVE", options, key, null);
await GetStorageService(options).RemoveAsync(key); await GetStorageService(options).RemoveAsync(key);
return; return;
} }
Log("SET", options, key, JsonConvert.SerializeObject(value));
await GetStorageService(options).SaveAsync(key, value); await GetStorageService(options).SaveAsync(key, value);
} }
@ -1512,19 +1506,12 @@ namespace Bit.Core.Services
private async Task<State> GetStateFromStorageAsync() private async Task<State> GetStateFromStorageAsync()
{ {
var state = await _storageService.GetAsync<State>(Constants.StateKey); return await _storageService.GetAsync<State>(Constants.StateKey);
// TODO Remove logging once all bugs are squished
Debug.WriteLine(JsonConvert.SerializeObject(state, Formatting.Indented),
">>> GetStateFromStorageAsync()");
return state;
} }
private async Task SaveStateToStorageAsync(State state) private async Task SaveStateToStorageAsync(State state)
{ {
await _storageService.SaveAsync(Constants.StateKey, state); await _storageService.SaveAsync(Constants.StateKey, state);
// TODO Remove logging once all bugs are squished
Debug.WriteLine(JsonConvert.SerializeObject(state, Formatting.Indented),
">>> SaveStateToStorageAsync()");
} }
private async Task CheckStateAsync() private async Task CheckStateAsync()
@ -1567,17 +1554,5 @@ namespace Bit.Core.Services
} }
throw new Exception("User does not exist in account list"); throw new Exception("User does not exist in account list");
} }
private void Log(string tag, StorageOptions options, string key, string value)
{
// TODO Remove this once all bugs are squished
var text = options?.UseSecureStorage ?? false ? "SECURE / " : "";
text += "Key: " + key + " / ";
if (value != null)
{
text += "Value: " + value;
}
Debug.WriteLine(text, ">>> " + tag);
}
} }
} }