diff --git a/cicd/test_script/ca-gen.sh b/cicd/test_script/ca-gen.sh index c5a41875..a1ddb024 100755 --- a/cicd/test_script/ca-gen.sh +++ b/cicd/test_script/ca-gen.sh @@ -1,8 +1,7 @@ -#!/bin/bash -ve +#! /bin/bash -ve -export NODE_ENV=development # testing development production +export NODE_ENV=production # testing development production export BDK_NETWORK_NAME=shell-network-ca -export DOCKER_LOGGING=true export BDK_ORG_TYPE=peer ICA_DOMAIN_BEN='ica.ben.cathaybc.com' diff --git a/cicd/test_script/crypto-gen.sh b/cicd/test_script/crypto-gen.sh index 81eee5fa..c590a69e 100755 --- a/cicd/test_script/crypto-gen.sh +++ b/cicd/test_script/crypto-gen.sh @@ -1,8 +1,7 @@ -#!/bin/bash -ve +#! /bin/bash -ve -export NODE_ENV=development # testing development production +export NODE_ENV=production # testing development production export BDK_NETWORK_NAME=shell-network-cryptogen -export DOCKER_LOGGING=true export BDK_ORG_TYPE=peer ORDERER_ORG_DOMAIN_BEN=$(jq --raw-output '.ordererOrgs[0].domain' ./cicd/test_script/network-create.json) diff --git a/src/config.ts b/src/config.ts index 7a0bc9bc..7d70c7d2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -43,7 +43,7 @@ export interface Config { environment: EnvironmentEnum isDevMode: boolean isTestMode: boolean - dockerLogging: boolean + isSillyMode: boolean infraConfig: InfraConfig networkName: string orgName: string @@ -82,7 +82,7 @@ const config: Config = { environment: environment, isDevMode: isDevMode, isTestMode: isTestMode, - dockerLogging: (process.env.DOCKER_LOGGING?.toLowerCase() === 'true') || false, + isSillyMode: (process.env.LOGGER_SILLY?.toLowerCase() === 'true') || false, infraConfig: { bdkPath: bdkPath, dockerHostPath: process.env.BDK_DOCKER_HOST_PATH || bdkPath, diff --git a/src/model/type/config.type.ts b/src/model/type/config.type.ts index 6ad6a043..4e24464d 100644 --- a/src/model/type/config.type.ts +++ b/src/model/type/config.type.ts @@ -7,7 +7,7 @@ import { EnvironmentEnum } from '../../config' * @requires BDK_ORG_NAME - [string] org 的名稱 * @requires BDK_ORG_DOMAIN - [string] org 的 domain 名稱 * @requires BDK_HOSTNAME - [string] hostname 的名稱 - * @requires DOCKER_LOGGING - [boolean] 是否要顯示 docker log 資訊 + * @requires LOGGER_SILLY - [boolean] 是否要顯示 silly log 資訊 */ export interface ConfigEnvType { NODE_ENV: EnvironmentEnum @@ -16,7 +16,7 @@ export interface ConfigEnvType { BDK_ORG_NAME: string BDK_ORG_DOMAIN: string BDK_HOSTNAME: string - DOCKER_LOGGING: boolean + LOGGER_SILLY: boolean BDK_DOCKER_HOST_PATH?: string } diff --git a/src/service/config.ts b/src/service/config.ts index b2d892fa..ce8f741b 100644 --- a/src/service/config.ts +++ b/src/service/config.ts @@ -11,7 +11,7 @@ const defaultEnv: ConfigEnvType = { BDK_ORG_NAME: 'Org1', BDK_ORG_DOMAIN: 'org1.example.com', BDK_HOSTNAME: 'peer0', - DOCKER_LOGGING: false, + LOGGER_SILLY: false, } export default class Config extends AbstractService { diff --git a/src/util/logger.ts b/src/util/logger.ts index 1c55907a..393cd0fa 100644 --- a/src/util/logger.ts +++ b/src/util/logger.ts @@ -3,7 +3,7 @@ import { transports, format, createLogger } from 'winston' import { LEVEL } from 'triple-beam' const defaultLoggerConfig = { - level: 'debug', + level: config.isSillyMode ? 'silly' : 'debug', silent: config.isTestMode, format: format.combine( format.splat(), diff --git a/test/service/config.test.ts b/test/service/config.test.ts index 78dc7107..9bdd528d 100644 --- a/test/service/config.test.ts +++ b/test/service/config.test.ts @@ -14,7 +14,7 @@ describe('Config service: ', () => { BDK_ORG_NAME: 'TestOrg', BDK_ORG_DOMAIN: 'test.domain.com', BDK_HOSTNAME: 'peer0', - DOCKER_LOGGING: true, + LOGGER_SILLY: true, } const configSetEnv: ConfigSetType = { @@ -37,7 +37,7 @@ describe('Config service: ', () => { it('.env content and inputs should be the same', () => { (new Config(config)).init() - const checkConfig = 'NODE_ENV=production\nBDK_NETWORK_NAME=bdk-network\nBDK_ORG_TYPE=peer\nBDK_ORG_NAME=Org1\nBDK_ORG_DOMAIN=org1.example.com\nBDK_HOSTNAME=peer0\nDOCKER_LOGGING=false\n' + const checkConfig = 'NODE_ENV=production\nBDK_NETWORK_NAME=bdk-network\nBDK_ORG_TYPE=peer\nBDK_ORG_NAME=Org1\nBDK_ORG_DOMAIN=org1.example.com\nBDK_HOSTNAME=peer0\nLOGGER_SILLY=false\n' assert.strictEqual(fs.readFileSync(`${config.infraConfig.bdkPath}/.env`).toString(), checkConfig) }) @@ -57,7 +57,7 @@ describe('Config service: ', () => { it('.env content and inputs should be the same', () => { (new Config(config)).init(configEnv) - const checkConfig = 'NODE_ENV=testing\nBDK_NETWORK_NAME=test-network\nBDK_ORG_TYPE=peer\nBDK_ORG_NAME=TestOrg\nBDK_ORG_DOMAIN=test.domain.com\nBDK_HOSTNAME=peer0\nDOCKER_LOGGING=true\n' + const checkConfig = 'NODE_ENV=testing\nBDK_NETWORK_NAME=test-network\nBDK_ORG_TYPE=peer\nBDK_ORG_NAME=TestOrg\nBDK_ORG_DOMAIN=test.domain.com\nBDK_HOSTNAME=peer0\nLOGGER_SILLY=true\n' assert.strictEqual(fs.readFileSync(`${config.infraConfig.bdkPath}/.env`).toString(), checkConfig) }) @@ -78,7 +78,7 @@ describe('Config service: ', () => { (new Config(config)).init(); (new Config(config)).set(configSetEnv) - const checkConfig = 'NODE_ENV=production\nBDK_NETWORK_NAME=bdk-network\nBDK_ORG_TYPE=peer\nBDK_ORG_NAME=Org1\nBDK_ORG_DOMAIN=test.set.domain.com\nBDK_HOSTNAME=peer0\nDOCKER_LOGGING=false\n' + const checkConfig = 'NODE_ENV=production\nBDK_NETWORK_NAME=bdk-network\nBDK_ORG_TYPE=peer\nBDK_ORG_NAME=Org1\nBDK_ORG_DOMAIN=test.set.domain.com\nBDK_HOSTNAME=peer0\nLOGGER_SILLY=false\n' assert.strictEqual(fs.readFileSync(`${config.infraConfig.bdkPath}/.env`).toString(), checkConfig) }) @@ -98,7 +98,7 @@ describe('Config service: ', () => { (new Config(config)).init(); (new Config(config)).ls() - const checkConfig = 'NODE_ENV=production\nBDK_NETWORK_NAME=bdk-network\nBDK_ORG_TYPE=peer\nBDK_ORG_NAME=Org1\nBDK_ORG_DOMAIN=org1.example.com\nBDK_HOSTNAME=peer0\nDOCKER_LOGGING=false\n' + const checkConfig = 'NODE_ENV=production\nBDK_NETWORK_NAME=bdk-network\nBDK_ORG_TYPE=peer\nBDK_ORG_NAME=Org1\nBDK_ORG_DOMAIN=org1.example.com\nBDK_HOSTNAME=peer0\nLOGGER_SILLY=false\n' assert.strictEqual(fs.readFileSync(`${config.infraConfig.bdkPath}/.env`).toString(), checkConfig) })