How to use the fabric-shim.newLogger function in fabric-shim

To help you get started, we’ve selected a few fabric-shim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / fabric-sdk-node / test / fixtures / chaincode / node_cc / example_cc1 / chaincode.js View on Github external
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// This is a node-js version of example_02.go

const shim = require('fabric-shim');

// An log4js logger instance
const logger = shim.newLogger('example_cc1');
// The logger level can also be set by environment variable 'CORE_CHAINCODE_LOGGING_SHIM'
// to CRITICAL, ERROR, WARNING, DEBUG
logger.level = 'info';

const Chaincode = class {
	async Init(stub) {

		logger.info('########### example_cc1 Init ###########');
		// test the transient map support with chaincode instantiation
		return this.testTransient(stub);
	}

	async Invoke(stub) {
		logger.info('########### example_cc1 Invoke ###########');
		const ret = stub.getFunctionAndParameters();
		const fcn = ret.fcn;
github hyperledger / fabric-sdk-node / test / fixtures / chaincode / node_cc / example_cc / chaincode.js View on Github external
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// This is a node-js version of example_02.go

const shim = require('fabric-shim');

// An log4js logger instance
const logger = shim.newLogger('example_cc0');
// The logger level can also be set by environment variable 'CORE_CHAINCODE_LOGGING_SHIM'
// to CRITICAL, ERROR, WARNING, DEBUG
logger.level = 'info';

const Chaincode = class {
	async Init(stub) {
		logger.info('########### example_cc0 Init ###########');
		const ret = stub.getFunctionAndParameters();

		let A, B;    // Entities
		let Aval, Bval; // Asset holdings
		const args = ret.params;

		if (args.length === 4) {
			A = args[0];
			B = args[2];
github hyperledger / fabric-chaincode-node / test / typescript / chaincode.ts View on Github external
async Init(stub: ChaincodeStub): Promise {
        const logger: LoggerInstance = shim.newLogger('init');
        return shim.success();
    }