diff --git a/apps/hashblock_rest/app.py b/apps/hashblock_rest/app.py index 4e65658..d522bd5 100644 --- a/apps/hashblock_rest/app.py +++ b/apps/hashblock_rest/app.py @@ -38,17 +38,6 @@ import shared.asset as asset import shared.exchange as exchange -LOGGER = logging.getLogger(__name__) - -# Initialize configuration -load_hashblock_config() -print("Succesfully loaded hasblock-rest configuration") - -# Initialize ZMQ -initialize_txn_vc() -print("Succesfully initialized ZMQ connection") -# Initialize decoder -initialize_decode() # Setup upload location for batch submissions UPLOAD_FOLDER = '/uploads/files/' @@ -61,6 +50,11 @@ application = Flask(__name__) application.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER +if __name__ != '__main__': + gunicorn_logger = logging.getLogger('gunicorn.error') + application.logger.handlers = gunicorn_logger.handlers + application.logger.setLevel(gunicorn_logger.level) + api = Api( application, validate=True, @@ -70,7 +64,17 @@ ns = api.namespace('hashblock', description='hashblock operations') -# Utility functions +LOGGER = application.logger + +# Initialize configuration +load_hashblock_config() +LOGGER.info("Succesfully loaded hasblock-rest configuration") + +# Initialize ZMQ +initialize_txn_vc() +LOGGER.info("Succesfully initialized ZMQ connection") +# Initialize decoder +initialize_decode() def assetlinks(data): diff --git a/docker/compose/hashblock-local.yaml b/docker/compose/hashblock-local.yaml index a5450b2..44d882f 100644 --- a/docker/compose/hashblock-local.yaml +++ b/docker/compose/hashblock-local.yaml @@ -53,6 +53,7 @@ services: command: > gunicorn -b 0.0.0.0:8000 --access-logfile - + --log-level=debug --reload "hashblock_rest.app:application" stop_signal: SIGKILL diff --git a/modules/config.py b/modules/config.py index adf9cc7..fced627 100644 --- a/modules/config.py +++ b/modules/config.py @@ -16,6 +16,7 @@ import sys import os +import logging from yaml import load from modules.state import State @@ -39,6 +40,8 @@ UNKNOWN_OWNER = '__unknown_key_owner_value__' UNKNOWN_AGREEMENT = '__unknown_agreement__' +LOGGER = logging + def keys_path(): return KEYS_PATH @@ -211,12 +214,12 @@ def __fabricate_signer(): def __load_cfg_and_keys(configfile): """Reads the configuration file and converts any priv keys to public""" - print("Reading {} from {}".format(configfile, DEFAULT_CFGR_PATH)) + LOGGER.debug("Reading {} from {}".format(configfile, DEFAULT_CFGR_PATH)) try: with open(os.path.join(DEFAULT_CFGR_PATH, configfile), 'r') as f: doc = load(f) except IOError: - print("Could not read {}".format(configfile)) + LOGGER.error("Could not read {}".format(configfile)) raise signer_keys = {} diff --git a/modules/dualities.py b/modules/dualities.py index c9cf75c..7bc82a9 100644 --- a/modules/dualities.py +++ b/modules/dualities.py @@ -15,18 +15,21 @@ # ------------------------------------------------------------------------------ import os +import logging from yaml import load from abc import ABC, abstractmethod +LOGGER = logging + def _load_dualities(cfg_path, configfile): """Reads the duality configuration file""" - print("Reading {} from {}".format(configfile, cfg_path)) + LOGGER.info("Reading {} from {}".format(configfile, cfg_path)) try: with open(os.path.join(cfg_path, configfile), 'r') as f: doc = load(f) except IOError: - print("Could not read {}".format(configfile)) + LOGGER.error("Could not read {}".format(configfile)) raise return doc diff --git a/zkPROC/hashblock_zkproc/CMakeLists.txt b/zkPROC/hashblock_zkproc/CMakeLists.txt index 1026e10..e37f41b 100644 --- a/zkPROC/hashblock_zkproc/CMakeLists.txt +++ b/zkPROC/hashblock_zkproc/CMakeLists.txt @@ -16,19 +16,18 @@ set(SOURCES src/hbzkproc.c) set(CMAKE_C_FLAGS "-Wall -std=c99 -Wall -Wextra -Wfatal-errors -O2") # Link settings -find_library(HB_LIBUNIVALUE NAMES libunivalue) -find_library(HB_LIBMEMENV NAMES libmemenv) -find_library(HB_LIBSNARK NAMES libsnark PATHS /root/zcash/src/snark) -find_library(HB_LIBBITCOIN_CRYPTO NAMES libbitcoin_crypto) -find_library(HB_LIBSECP256K1 NAMES libsecp256k1) -find_library(HB_LIBBITCOIN_UTIL NAMES libbitcoin_util) -find_library(HB_LIBBITCOIN_CLI NAMES libbitcoin_cli) -find_library(HB_LIBZCASH NAMES libzcash) +find_library(HB_LIBUNIVALUE NAMES univalue PATHS /root/zcash/src/univalue/.libs) +find_library(HB_LIBMEMENV NAMES memenv PATHS /root/zcash/src/leveldb) +find_library(HB_LIBSNARK NAMES snark PATHS /root/zcash/src/snark) +find_library(HB_LIBBITCOIN_CRYPTO NAMES bitcoin_crypto PATHS /root/zcash/src/crypto) +find_library(HB_LIBSECP256K1 NAMES secp256k1 PATHS /root/zcash/src/secp256k1/.libs) +find_library(HB_LIBBITCOIN_UTIL NAMES bitcoin_util PATHS /root/zcash/src) +find_library(HB_LIBBITCOIN_CLI NAMES bitcoin_cli PATHS /root/zcash/src) +find_library(HB_LIBZCASH NAMES zcash) add_executable(hbzkproc ${SOURCES}) target_link_libraries(hbzkproc - -rdynamic -std=c99 -Wall -Wextra -Wfatal-errors ${HB_LIBUNIVALUE} ${HB_LIBMEMENV}