Unverified Commit e3b4a5f1 authored by kladko's avatar kladko

SKALE-2871-reduce-sgx-logs

parent 7fa76e24
......@@ -29,6 +29,8 @@
#include <stdio.h>
#include "sgxwallet_common.h"
#include "sgxwallet.h"
#include "SGXException.h"
#include "LevelDB.h"
......@@ -50,27 +52,30 @@
#include "Log.h"
void setFullOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm, int _encryptKeys) {
if (_printDebugInfo)
spdlog::set_level(spdlog::level::debug);
else if (_printTraceInfo) {
using namespace std;
void setFullOptions(uint64_t _logLevel, int _useHTTPS, int _autoconfirm, int _encryptKeys) {
CHECK_STATE(_logLevel <= 2)
if (_logLevel == L_TRACE) {
spdlog::set_level(spdlog::level::trace);
} else if (_printTraceInfo) {
} else if (_logLevel == L_DEBUG) {
spdlog::set_level(spdlog::level::debug);
} else {
spdlog::set_level(spdlog::level::info);
}
useHTTPS = _useHTTPS;
spdlog::info("useHTTPS set to " + std::to_string(_useHTTPS));
spdlog::info("useHTTPS set to " + to_string(_useHTTPS));
autoconfirm = _autoconfirm;
spdlog::info("autoconfirm set to " + std::to_string(autoconfirm));
spdlog::info("autoconfirm set to " + to_string(autoconfirm));
encryptKeys = _encryptKeys;
spdlog::info("encryptKeys set to " + std::to_string(encryptKeys));
spdlog::info("encryptKeys set to " + to_string(encryptKeys));
}
void setOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm) {
setFullOptions(_printDebugInfo,
_printTraceInfo, _useHTTPS, _autoconfirm, false);
void setOptions(uint64_t _logLevel, int _useHTTPS, int _autoconfirm) {
setFullOptions(_logLevel, _useHTTPS, _autoconfirm, false);
}
bool isStringDec(const string &_str) {
......
......@@ -30,11 +30,9 @@
#define EXTERNC
#endif
EXTERNC void setFullOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm, int _encryptKeys);
EXTERNC void setFullOptions(uint64_t _logLevel, int _useHTTPS, int _autoconfirm, int _encryptKeys);
EXTERNC void setOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm);
EXTERNC void setOptions(uint64_t _logLevel, int _useHTTPS, int _autoconfirm);
#endif //SGXWALLET_SGXWALLETSERVER_H
......@@ -56,7 +56,7 @@ void SGXWallet::printUsage() {
cerr << "-T Generate test keys \n";
}
enum log_level {L_TRACE = 0, L_DEBUG = 1, L_INFO = 2,L_WARNING = 3, L_ERROR = 4 };
void SGXWallet::serializeKeys(const vector<string>& _ecdsaKeyNames, const vector<string>& _blsKeyNames, const string& _fileName) {
Json::Value top(Json::objectValue);
......@@ -149,13 +149,25 @@ int main(int argc, char *argv[]) {
}
}
setFullOptions(printDebugInfoOption, printTraceInfoOption, useHTTPSOption, autoconfirmOption, encryptKeysOption);
uint64_t logLevel = L_INFO;
if (printDebugInfoOption) {
logLevel = L_DEBUG;
}
if (printTraceInfoOption) {
logLevel = L_TRACE;
}
setFullOptions(logLevel, useHTTPSOption, autoconfirmOption, encryptKeysOption);
uint32_t enclaveLogLevel = L_INFO;
if (printTraceInfoOption) {
enclaveLogLevel = L_TRACE;
} else if (printDebugInfoOption) {
}
if (printDebugInfoOption) {
enclaveLogLevel = L_DEBUG;
}
......
......@@ -51,4 +51,6 @@ extern sgx_status_t status;
#define ENCLAVE_NAME "secure_enclave.signed.so"
enum log_level {L_TRACE = 0, L_DEBUG = 1, L_INFO = 2,L_WARNING = 3, L_ERROR = 4 };
#endif //SGXWALLET_SGXWALLET_H
......@@ -70,8 +70,8 @@ class TestFixture {
public:
TestFixture() {
TestUtils::resetDB();
setOptions(false, false, false, true);
initAll(2, false, true);
setOptions(L_INFO, false, true);
initAll(L_INFO, false, true);
}
~TestFixture() {
......@@ -83,7 +83,7 @@ class TestFixtureHTTPS {
public:
TestFixtureHTTPS() {
TestUtils::resetDB();
setOptions(false, false, true, true);
setOptions(L_INFO, true, true);
initAll(0, false, true);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment