修改日志方式

Signed-off-by: linqili <charlielin06@gmail.com>
This commit is contained in:
linqili 2020-04-16 01:52:00 +08:00
parent f81fc36cdb
commit 92c4fb628a
3 changed files with 10 additions and 5 deletions

View file

@ -22,6 +22,8 @@ repositories {
dependencies {
implementation group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.0.+'
implementation group: 'org.json', name: 'json', version: '20180813'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
implementation group: 'ch.qos.logbak', name: 'logback-classic', version: '1.1.11'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
testImplementation 'org.assertj:assertj-core:3.11.1'
testImplementation 'org.mockito:mockito-core:2.+'

View file

@ -1,5 +1,6 @@
#Thu Apr 16 01:34:12 CST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

View file

@ -3,8 +3,6 @@ SPDX-License-Identifier: Apache-2.0
*/
package org.example;
import java.util.logging.Logger;
import org.example.ledgerapi.State;
import org.hyperledger.fabric.contract.Context;
import org.hyperledger.fabric.contract.ContractInterface;
@ -15,6 +13,8 @@ import org.hyperledger.fabric.contract.annotation.Info;
import org.hyperledger.fabric.contract.annotation.License;
import org.hyperledger.fabric.contract.annotation.Transaction;
import org.hyperledger.fabric.shim.ChaincodeStub;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A custom context provides easy access to list of all commercial papers
@ -29,7 +29,7 @@ import org.hyperledger.fabric.shim.ChaincodeStub;
public class CommercialPaperContract implements ContractInterface {
// use the classname for the logger, this way you can refactor
private final static Logger LOG = Logger.getLogger(CommercialPaperContract.class.getName());
private Logger LOG = LoggerFactory.getLogger(CommercialPaperContract.class);
@Override
public Context createContext(ChaincodeStub stub) {
@ -83,6 +83,8 @@ public class CommercialPaperContract implements ContractInterface {
paper.setOwner(issuer);
System.out.println(paper);
LOG.info("==== issue ====");
LOG.info("here is the paper:\n {}", paper);
// Add the paper to the list of all similar commercial papers in the ledger
// world state
ctx.paperList.addPaper(paper);