Separate logger from utils

This commit is contained in:
morrigan
2019-12-03 15:19:08 +01:00
parent acb9b87537
commit c8c03b5093
3 changed files with 3 additions and 4 deletions

View File

@ -6,11 +6,11 @@ import { KeyPair, PeerId } from "./@types/libp2p";
import { import {
createHandshakePayload, createHandshakePayload,
getHandshakePayload, getHandshakePayload,
logger,
signEarlyDataPayload, signEarlyDataPayload,
signPayload, signPayload,
verifySignedPayload, verifySignedPayload,
} from "./utils"; } from "./utils";
import { logger } from "./logger";
import { decodeMessageBuffer, encodeMessageBuffer } from "./encoder"; import { decodeMessageBuffer, encodeMessageBuffer } from "./encoder";
import { WrappedConnection } from "./noise"; import { WrappedConnection } from "./noise";

2
src/logger.ts Normal file
View File

@ -0,0 +1,2 @@
import debug from "debug";
export const logger = debug('libp2p:noise');

View File

@ -1,15 +1,12 @@
import { x25519, ed25519 } from 'bcrypto'; import { x25519, ed25519 } from 'bcrypto';
import protobuf from "protobufjs"; import protobuf from "protobufjs";
import { Buffer } from "buffer"; import { Buffer } from "buffer";
import debug from "debug";
import PeerId from "peer-id"; import PeerId from "peer-id";
import * as crypto from 'libp2p-crypto'; import * as crypto from 'libp2p-crypto';
import { KeyPair } from "./@types/libp2p"; import { KeyPair } from "./@types/libp2p";
import { bytes } from "./@types/basic"; import { bytes } from "./@types/basic";
export const logger = debug('libp2p:noise');
export async function loadPayloadProto () { export async function loadPayloadProto () {
const payloadProtoBuf = await protobuf.load("protos/payload.proto"); const payloadProtoBuf = await protobuf.load("protos/payload.proto");
return payloadProtoBuf.lookupType("pb.NoiseHandshakePayload"); return payloadProtoBuf.lookupType("pb.NoiseHandshakePayload");