Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@re-ai/inner-tool-sdk

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@re-ai/inner-tool-sdk - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

4

dist/utils/Logger.d.ts

@@ -10,3 +10,6 @@ export declare enum LogLevel {

private static logLevel;
private static initialized;
static initialize(): void;
private static getCurrentTime;
private static logMessage;
static error(...args: any): void;

@@ -16,2 +19,3 @@ static warn(...args: any): void;

static debug(...args: any): void;
static log(type: LogLevel, ...args: any): void;
}

32

dist/utils/Logger.js

@@ -12,14 +12,26 @@ "use strict";

})(LogLevel || (exports.LogLevel = LogLevel = {}));
const LOGGER_PREFIX = process.env.LOGGER_PREFIX || "[ReAI-TOOL-SDK]";
class Logger {
static logLevel = LogLevel.INFO; // 默认日志级别
static initialized = false;
static initialize() {
const logLevelEnv = process.env.REAI_VECTOR_LOG_LEVEL;
if (logLevelEnv) {
this.logLevel = LogLevel[logLevelEnv] || LogLevel.INFO;
if (!this.initialized) {
const logLevelEnv = process.env.LOGGER_LEVEL || process.env.LOGGER_LEVEL_REAI_TOOL_SDK || "INFO";
if (logLevelEnv) {
this.logLevel = LogLevel[logLevelEnv] || LogLevel.INFO;
}
this.initialized = true;
}
}
static getCurrentTime() {
return new Date().toLocaleString();
}
static logMessage(level, ...args) {
const currentTime = this.getCurrentTime();
console.log(`${LOGGER_PREFIX}[${level}] [${currentTime}]`, ...args);
}
static error(...args) {
this.initialize();
if (this.logLevel >= LogLevel.ERROR) {
console.error("[ReAI-Tool-SDK]", ...args);
this.logMessage("ERROR", ...args);
}

@@ -30,3 +42,3 @@ }

if (this.logLevel >= LogLevel.WARN) {
console.warn("[ReAI-Tool-SDK]", ...args);
this.logMessage("WARN", ...args);
}

@@ -37,3 +49,3 @@ }

if (this.logLevel >= LogLevel.INFO) {
console.log("[ReAI-Tool-SDK]", ...args);
this.logMessage("INFO", ...args);
}

@@ -44,6 +56,12 @@ }

if (this.logLevel >= LogLevel.DEBUG) {
console.debug("[ReAI-Tool-SDK]", ...args);
this.logMessage("DEBUG", ...args);
}
}
static log(type, ...args) {
this.initialize();
if (this.logLevel >= type) {
this.logMessage(LogLevel[type], ...args);
}
}
}
exports.Logger = Logger;
{
"name": "@re-ai/inner-tool-sdk",
"version": "0.1.0",
"version": "0.1.1",
"description": "ReAI内部接口sdk",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -12,2 +12,12 @@

### 环境变量
| 环境变量 | 描述 | 默认值 |
| --- | --- | --- |
| RPC_PORT_SMS | 短信服务端口 | 4682 |
| RPC_HOST_SMS | 支付服务地址 | 127.0.0.1 |
| RPC_PORT_PAY | 支付服务端口 | 4681 |
| RPC_HOST_PAY | 支付服务地址 | 127.0.0.1 |
### 示例
```typescript

@@ -14,0 +24,0 @@ import { ReAITool, SMSPlatforms } from '@re-ai/inner-tool-sdk'

@@ -9,16 +9,31 @@ export enum LogLevel {

const LOGGER_PREFIX = process.env.LOGGER_PREFIX || "[ReAI-TOOL-SDK]";
export class Logger {
private static logLevel: LogLevel = LogLevel.INFO; // 默认日志级别
private static initialized: boolean = false;
static initialize() {
const logLevelEnv = process.env.REAI_VECTOR_LOG_LEVEL;
if (logLevelEnv) {
this.logLevel = LogLevel[logLevelEnv as keyof typeof LogLevel] || LogLevel.INFO;
if (!this.initialized) {
const logLevelEnv = process.env.LOGGER_LEVEL || process.env.LOGGER_LEVEL_REAI_TOOL_SDK || "INFO";
if (logLevelEnv) {
this.logLevel = LogLevel[logLevelEnv as keyof typeof LogLevel] || LogLevel.INFO;
}
this.initialized = true;
}
}
private static getCurrentTime(): string {
return new Date().toLocaleString();
}
private static logMessage(level: string, ...args: any) {
const currentTime = this.getCurrentTime();
console.log(`${LOGGER_PREFIX}[${level}] [${currentTime}]`, ...args);
}
static error(...args: any) {
this.initialize()
this.initialize();
if (this.logLevel >= LogLevel.ERROR) {
console.error("[ReAI-Tool-SDK]", ...args);
this.logMessage("ERROR", ...args);
}

@@ -28,5 +43,5 @@ }

static warn(...args: any) {
this.initialize()
this.initialize();
if (this.logLevel >= LogLevel.WARN) {
console.warn("[ReAI-Tool-SDK]", ...args);
this.logMessage("WARN", ...args);
}

@@ -36,5 +51,5 @@ }

static info(...args: any) {
this.initialize()
this.initialize();
if (this.logLevel >= LogLevel.INFO) {
console.log("[ReAI-Tool-SDK]", ...args);
this.logMessage("INFO", ...args);
}

@@ -44,7 +59,14 @@ }

static debug(...args: any) {
this.initialize()
this.initialize();
if (this.logLevel >= LogLevel.DEBUG) {
console.debug("[ReAI-Tool-SDK]", ...args);
this.logMessage("DEBUG", ...args);
}
}
static log(type: LogLevel, ...args: any) {
this.initialize();
if (this.logLevel >= type) {
this.logMessage(LogLevel[type], ...args);
}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc