本文整理匯總了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})`);
}
}
示例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;
}
示例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}`);
}
}
示例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);
}