Unverified Commit 86e8b271 authored by kladko's avatar kladko

Fixed docs

parent c10e1191
...@@ -24,20 +24,15 @@ ...@@ -24,20 +24,15 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "sgxwallet_common.h" #include "sgxwallet_common.h"
#include "common.h" #include "common.h"
#include "SGXException.h"
#include "Log.h" #include "Log.h"
using namespace std; using namespace std;
void Log::setGlobalLogLevel(string &_s) { void Log::setGlobalLogLevel(string &_s) {
globalLogLevel = logLevelFromString(_s); globalLogLevel = logLevelFromString(_s);
} }
level_enum Log::logLevelFromString(string &_s) { level_enum Log::logLevelFromString(string &_s) {
level_enum result = trace; level_enum result = trace;
...@@ -58,6 +53,11 @@ level_enum Log::logLevelFromString(string &_s) { ...@@ -58,6 +53,11 @@ level_enum Log::logLevelFromString(string &_s) {
} }
void Log::handleSGXException(Json::Value& _result, SGXException& _e ) {
spdlog::error("Responding with JSON error:" + _e.errString);
_result["status"] = _e.status;
_result["errorMessage"] = _e.errString;
}
...@@ -30,7 +30,11 @@ ...@@ -30,7 +30,11 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include "json/json.h"
#include "spdlog/spdlog.h"
#include "SGXException.h"
#include "InvalidArgumentException.h" #include "InvalidArgumentException.h"
#include "InvalidStateException.h" #include "InvalidStateException.h"
...@@ -39,21 +43,18 @@ ...@@ -39,21 +43,18 @@
using namespace std; using namespace std;
class Exception; class Exception;
#define __CLASS_NAME__ className( __PRETTY_FUNCTION__ ) #define __CLASS_NAME__ className( __PRETTY_FUNCTION__ )
#define LOG( __SEVERITY__, __MESSAGE__ ) \ #define LOG(__SEVERITY__, __MESSAGE__) \
cerr << to_string(__SEVERITY__) << " " << __MESSAGE__ << " " << className( __PRETTY_FUNCTION__ ) << endl; cerr << to_string(__SEVERITY__) << " " << __MESSAGE__ << " " << className( __PRETTY_FUNCTION__ ) << endl;
enum level_enum {
trace, debug, info, warn, err
enum level_enum { trace, debug, info, warn, err }; };
class Log { class Log {
...@@ -62,8 +63,16 @@ public: ...@@ -62,8 +63,16 @@ public:
level_enum globalLogLevel; level_enum globalLogLevel;
void setGlobalLogLevel( string& _s ); void setGlobalLogLevel(string &_s);
static level_enum logLevelFromString(string &_s); static level_enum logLevelFromString(string &_s);
static void handleSGXException(Json::Value &_result, SGXException &_e);
}; };
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; __RESULT__["status"] = 0; __RESULT__["errorMessage"] = "";
#define HANDLE_SGX_EXCEPTION(_RESULT_) catch (SGXException &__e) { Log::handleSGXException(_RESULT_, __e);}
#define LOCK(__M__) lock_guard<recursive_mutex> lock(__M__);
#endif #endif
This diff is collapsed.
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