當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript log-cool.logWarn函數代碼示例

本文整理匯總了TypeScript中log-cool.logWarn函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript logWarn函數的具體用法?TypeScript logWarn怎麽用?TypeScript logWarn使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了logWarn函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: checkDependency

function checkDependency(serviceName: string, command: string, transform: (x: string) => string): void {
	try {
		const x = execSync(command, { stdio: ['pipe', 'pipe', 'ignore'] });
		const ver = transform(x.toString());
		if (ver !== null) {
			logInfo(`${serviceName} ${ver}`);
		} else {
			logWarn(`Check dependencies error (${serviceName})`);
			logWarn(`Regexp used for version check of ${serviceName} is probably messed up`);
		}
	} catch (e) {
		logWarn(`Unable to find (${serviceName})`);
	}
}
開發者ID:Tosuke,項目名稱:Misskey-API,代碼行數:14,代碼來源:check-dependencies.ts

示例2: init

/**
 * Init app
 */
async function init(): Promise<State> {
	console.log('Welcome to Misskey!\n');

	console.log(chalk.bold('Misskey Core <aoi>'));

	let warn = false;

	// Get commit info
	const commit = await prominence(git).getLastCommit();
	console.log(`commit: ${commit.shortHash} ${commit.author.name} <${commit.author.email}>`);
	console.log(`        ${new Date(parseInt(commit.committedOn, 10) * 1000)}`);

	console.log('\nInitializing...\n');

	if (IS_DEBUG) {
		logWarn('It is not in the Production mode. Do not use in the Production environment.');
	}

	logInfo(`environment: ${env}`);

	// Get machine info
	const totalmem = (os.totalmem() / 1024 / 1024 / 1024).toFixed(1);
	const freemem = (os.freemem() / 1024 / 1024 / 1024).toFixed(1);
	logInfo(`MACHINE: ${os.hostname()}`);
	logInfo(`MACHINE: CPU: ${os.cpus().length}core`);
	logInfo(`MACHINE: MEM: ${totalmem}GB (available: ${freemem}GB)`);

	if (!fs.existsSync(require('./config').configPath)) {
		logFailed('Configuration not found');
		return State.failed;
	}

	// Load config
	const conf = require('./config').default;

	logDone('Success to load configuration');
	logInfo(`maintainer: ${conf.maintainer}`);

	checkDependencies();

	// Check if a port is being used
	if (await portUsed.check(conf.port)) {
		logFailed(`Port: ${conf.port} is already used!`);
		return State.failed;
	}

	// Try to connect to MongoDB
	try {
		await initdb(conf);
		logDone('Success to connect to MongoDB');
	} catch (e) {
		logFailed(`MongoDB: ${e}`);
		return State.failed;
	}

	return warn ? State.warn : State.success;
}
開發者ID:syuilo,項目名稱:misskey-core,代碼行數:60,代碼來源:index.ts

示例3: checkDependency

function checkDependency(serviceName: string, command: string, transform: (x: string) => string): void {
	const code = {
		success: 0,
		notFound: 127
	};
	const x = exec(command, { silent: true }) as any;
	if (x.code === code.success) {
		logInfo(`DEPS: ${serviceName} ${transform(x.stdout)}`);
	} else if (x.code === code.notFound) {
		logWarn(`Unable to find ${serviceName}`);
	}
}
開發者ID:syuilo,項目名稱:misskey-core,代碼行數:12,代碼來源:check-dependencies.ts

示例4: notFoundHandler

function notFoundHandler(req: any, res: any): any {
	logWarn(`Request not handled: ${req.method.toUpperCase()} ${req.path}`);
	return res({
		error: 'api-not-found'
	}).code(404);
}
開發者ID:akionux,項目名稱:Misskey-API,代碼行數:6,代碼來源:server.ts


注:本文中的log-cool.logWarn函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。