Skip to content

Commit

Permalink
adding verbose logging
Browse files Browse the repository at this point in the history
update version to v1.0.7
  • Loading branch information
knopkem committed Sep 7, 2020
1 parent 37a6c22 commit ced82f2
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 11 deletions.
3 changes: 2 additions & 1 deletion examples/echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ addon.echoScu(JSON.stringify(
"aet": "CONQUESTSRV1",
"ip" : "127.0.0.1",
"port": "5678"
}
},
"verbose": true
}
), (result) => {
if (result && result.length > 0) {
Expand Down
12 changes: 8 additions & 4 deletions examples/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ addon.findScu(JSON.stringify(
"key": "00100010",
"value": "",
},
]
],
"verbose": true
}
), (result) => {
if (result && result.length > 0) {
Expand All @@ -39,7 +40,7 @@ addon.findScu(JSON.stringify(
}
}
});

/*
addon.findScu(JSON.stringify(
{
"source": {
Expand Down Expand Up @@ -69,7 +70,8 @@ addon.findScu(JSON.stringify(
"key": "00200011",
"value": "",
},
]
],
"verbose": true
}
), (result) => {
if (result && result.length > 0) {
Expand Down Expand Up @@ -109,7 +111,8 @@ addon.findScu(JSON.stringify(
"key": "00080052",
"value": "IMAGE",
},
]
],
"verbose": true
}
), (result) => {
if (result && result.length > 0) {
Expand All @@ -124,3 +127,4 @@ addon.findScu(JSON.stringify(
}
});
*/
3 changes: 2 additions & 1 deletion examples/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ addon.getScu(JSON.stringify(
"key": "00080052",
"value": "STUDY",
},
]
],
"verbose": true
}
), (result) => {
if (result && result.length > 0) {
Expand Down
8 changes: 5 additions & 3 deletions examples/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ addon.startScp(JSON.stringify(
"ip" : "127.0.0.1",
"port": "9999"
},
"storagePath": "./data"
}
"storagePath": "./data",
"verbose": true
}
), (result) => {
if (result && result.length > 0) {
try
Expand Down Expand Up @@ -44,7 +45,8 @@ setTimeout(function() {
"value": "STUDY",
},
],
"destination" : "IMEBRA"
"destination" : "IMEBRA",
"verbose": true
}
), (result) => {
if (result && result.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dicom-dimse-native",
"version": "1.0.6",
"version": "1.0.7",
"description": "native addon using DCMTK dicom toolkit",
"main": "index.js",
"scripts": {
Expand Down
11 changes: 10 additions & 1 deletion src/BaseAsyncWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@ void BaseAsyncWorker::SendInfo(const std::string& msg, const ExecutionProgress&
{
std::string msg2 = ns::createJsonResponse(status, msg);
progress.Send(msg2.c_str(), msg2.length());
}
}

void BaseAsyncWorker::EnableVerboseLogging(bool enabled)
{
if (enabled) {
OFLog::configure(OFLogger::INFO_LOG_LEVEL);
} else {
OFLog::configure(OFLogger::WARN_LOG_LEVEL);
}
}
2 changes: 2 additions & 0 deletions src/BaseAsyncWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class BaseAsyncWorker : public AsyncProgressWorker<char>

void SendInfo(const std::string& msg, const ExecutionProgress& progress, ns::eStatus status = ns::PENDING);

void EnableVerboseLogging(bool enabled);

std::string _input;
nlohmann::json _jsonOutput;
std::string _error;
Expand Down
2 changes: 2 additions & 0 deletions src/EchoAsyncWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ void EchoAsyncWorker::Execute(const ExecutionProgress &progress)
{
ns::sInput in = ns::parseInputJson(_input);

EnableVerboseLogging(in.verbose);

if (!in.source.valid())
{
SetErrorJson("Source not set");
Expand Down
2 changes: 2 additions & 0 deletions src/FindAsyncWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ void FindAsyncWorker::Execute(const ExecutionProgress &progress)
{
ns::sInput in = ns::parseInputJson(_input);

EnableVerboseLogging(in.verbose);

if (in.tags.empty())
{
SetErrorJson("Tags not set");
Expand Down
2 changes: 2 additions & 0 deletions src/GetAsyncWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ void GetAsyncWorker::Execute(const ExecutionProgress &progress)
{
ns::sInput in = ns::parseInputJson(_input);

EnableVerboseLogging(in.verbose);

if (in.tags.empty())
{
SetErrorJson("Tags not set");
Expand Down
2 changes: 2 additions & 0 deletions src/MoveAsyncWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ void MoveAsyncWorker::Execute(const ExecutionProgress &progress)
{
ns::sInput in = ns::parseInputJson(_input);

EnableVerboseLogging(in.verbose);

if (in.tags.empty())
{
SetErrorJson("Tags not set");
Expand Down
2 changes: 2 additions & 0 deletions src/ServerAsyncWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ void ServerAsyncWorker::Execute(const ExecutionProgress &progress)
{
ns::sInput in = ns::parseInputJson(_input);

EnableVerboseLogging(in.verbose);

if (!in.source.valid())
{
SetErrorJson("Source not set");
Expand Down
4 changes: 4 additions & 0 deletions src/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace ns {
std::string storagePath;
std::string destination;
std::vector<sTag> tags;
bool verbose;
inline bool valid() {
return source.valid() && target.valid();
}
Expand Down Expand Up @@ -121,6 +122,9 @@ namespace ns {
in.tags.push_back(tag);
}
} catch(...) {}
try {
in.verbose = j.at("verbose");
} catch(...) {}
return in;
}

Expand Down

0 comments on commit ced82f2

Please sign in to comment.