zcash-android-wallet-sdk
zcash-android-wallet-sdk copied to clipboard
Introduce log-to-file API
Is your feature request related to a problem? Please describe.
We'd like to have a new logging SDK feature that would log all the selected priority logs from our custom Twig
logger into a cyclic file and provide its file path in the SDK's public API.
Describe the solution you'd like
Add a new Sychnronizer parameter, e.g., logToFile
:
suspend fun new(
zcashNetwork: ZcashNetwork,
alias: String,
repository: DerivedDataRepository,
txManager: OutboundTransactionManager,
processor: CompactBlockProcessor,
backend: TypesafeBackend
-->logToFile = LogToFileParams(
fileDir: String
fileName: String,
fileSizeLimit: Long,
fileNumberLimit: Int,
minPriority: Int
)
)
That will then create a new instance of a new FileLogger
component, which takes care of collecting and writing logs into the file. The new file would be created under the private no_backup
SDK directory in the fileDir
sub-directory and with the fileName
file name.
The minPriority
would specify which log priority should persist to the file. By default, it could work with ERROR, WARNING, and INFO, omitting the rest.
The new obtain file path API could then look like this:
suspend fun getLoggerFilePath(): String?
It copies the existing suspend fun getExistingDataDbFilePath
API for getting the private data file path.
Alternatives you've considered
The file for logs will work as FIFO, but we could introduce more files with the fileNumberLimit
parameter, and then it could clear and use the first file after the last was filled to the fileSizeLimit
limit or the file-system file size limit.
Additional context
- The result log file could be named, e.g.,
zcash_sdk_mainnet_logs.txt
- Remember that the logging might be suppressed by proguard
- Part of this task would be analyzing the current logging with Twig to avoid logging sensitive or too big data to the file
- After implemented, don't forget to make a time and CPU consuming tests of this feature