diff --git a/CHANGELOG.md b/CHANGELOG.md index 467c4cb..2e7274f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,13 @@ # CHANGELOG -## [3.4.0-beta.2] - 2022-06-08 +## [3.4.0-beta.3] - 2022-06-09 ### Added - `https` options for `HttpServer` - `wss` options for `WsServer` - Support using the same name with API and message ### Changed - Deprecate `serviceName` in `preRecvDataFlow`, use `serviceId` instead +- Optimized log color ## [3.3.3] - 2022-06-07 ### Fixed diff --git a/package.json b/package.json index b1e93fe..a186b71 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tsrpc", - "version": "3.4.0-beta.2", + "version": "3.4.0-beta.3", "description": "A TypeScript RPC Framework, with runtime type checking and built-in serialization, support both HTTP and WebSocket.", "main": "index.js", "exports": { diff --git a/src/server/base/ApiCall.ts b/src/server/base/ApiCall.ts index 9a684eb..b5c0423 100644 --- a/src/server/base/ApiCall.ts +++ b/src/server/base/ApiCall.ts @@ -1,3 +1,4 @@ +import chalk from 'chalk'; import { TSBuffer } from 'tsbuffer'; import { ApiService, TransportDataUtil } from "tsrpc-base-client"; import { ApiReturn, BaseServiceType, ServerOutputData, TsrpcError, TsrpcErrorData, TsrpcErrorType } from "tsrpc-proto"; @@ -41,7 +42,7 @@ export abstract class ApiCall, logger?: PrefixLogger) { super(options, logger ?? new PrefixLogger({ logger: options.conn.logger, - prefixs: [`[Api:${options.service.name}]${options.sn !== undefined ? ` SN=${options.sn}` : ''}`] + prefixs: [`${chalk.cyan.underline(`[Api:${options.service.name}]`)}${options.sn !== undefined ? chalk.gray(` SN=${options.sn}`) : ''}`] })); this.sn = options.sn; @@ -108,14 +109,14 @@ export abstract class ApiCall, logger?: PrefixLogger) { super(options, logger ?? new PrefixLogger({ logger: options.conn.logger, - prefixs: [`[Msg:${options.service.name}]`] + prefixs: [chalk.cyan.underline(`[Msg:${options.service.name}]`)] })); this.msg = options.msg; diff --git a/src/server/http/HttpConnection.ts b/src/server/http/HttpConnection.ts index b349131..4bf501c 100644 --- a/src/server/http/HttpConnection.ts +++ b/src/server/http/HttpConnection.ts @@ -1,3 +1,4 @@ +import chalk from "chalk"; import * as http from "http"; import { ParsedServerInput } from "tsrpc-base-client"; import { BaseServiceType } from "tsrpc-proto"; @@ -37,7 +38,7 @@ export class HttpConnection extends B constructor(options: HttpConnectionOptions) { super(options, new PrefixLogger({ logger: options.server.logger, - prefixs: [`${options.ip} #${options.id}`] + prefixs: [chalk.gray(`${options.ip} #${options.id}`)] })); this.httpReq = options.httpReq; diff --git a/src/server/inner/InnerConnection.ts b/src/server/inner/InnerConnection.ts index 3ddc96a..ab7b813 100644 --- a/src/server/inner/InnerConnection.ts +++ b/src/server/inner/InnerConnection.ts @@ -1,3 +1,4 @@ +import chalk from "chalk"; import { ApiReturn, TsrpcError, TsrpcErrorType } from "tsrpc-proto"; import { ApiCall, BaseConnection, BaseServiceType, PrefixLogger, TransportDataUtil } from "../.."; import { BaseConnectionOptions, ConnectionStatus } from "../base/BaseConnection"; @@ -27,7 +28,7 @@ export class InnerConnection extends constructor(options: InnerConnectionOptions) { super(options, new PrefixLogger({ logger: options.server.logger, - prefixs: [`Inner #${options.id}`] + prefixs: [chalk.gray(`Inner #${options.id}`)] })); this.return = options.return; diff --git a/src/server/ws/WsConnection.ts b/src/server/ws/WsConnection.ts index 86486b8..c765db4 100644 --- a/src/server/ws/WsConnection.ts +++ b/src/server/ws/WsConnection.ts @@ -1,3 +1,4 @@ +import chalk from "chalk"; import * as http from "http"; import { TransportDataUtil } from "tsrpc-base-client"; import { BaseServiceType } from "tsrpc-proto"; @@ -36,7 +37,7 @@ export class WsConnection extends Bas constructor(options: WsConnectionOptions) { super(options, new PrefixLogger({ logger: options.server.logger, - prefixs: [`${options.ip} Conn#${options.id}`] + prefixs: [chalk.gray(`${options.ip} Conn#${options.id}`)] })); this.ws = options.ws; this.httpReq = options.httpReq;