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


TypeScript signale.Signale類代碼示例

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


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

示例1: return

export const initializeServer = () => {
    const logger = new signale.Signale({ scope: 'Auto reloading' })
    logger.config({ displayTimestamp: true })

    // Since this port is hard-coded, it must match background.tsx
    const socketIOServer = io.listen(8890)
    logger.await('Ready for a browser extension to connect')
    socketIOServer.on('connect', () => {
        logger.info('Browser extension connected')
    })
    socketIOServer.on('disconnect', () => {
        logger.info('Browser extension disconnected')
    })

    return () => {
        if (Object.keys(socketIOServer.clients().connected).length === 0) {
            logger.warn('No browser extension has connected yet, so no reload was triggered')
            logger.warn("- Make sure it's enabled")
            logger.warn("- Make sure it's in developer mode (unpacked extension)")
            logger.warn('- Try manually reloading it 🔄')
        } else {
            logger.info('Triggering a reload of browser extensions')
            socketIOServer.emit('file.change', {})
        }
    }
}
開發者ID:JoYiRis,項目名稱:sourcegraph,代碼行數:26,代碼來源:auto-reloading.ts

示例2: Signale

import { Signale, SignaleOptions } from "signale";

// --- Test 1: Basic Usage --- //

const signale = new Signale();

signale.success("Operation successful");
signale.debug("Hello", "from", "L59");
signale.pending("Write release notes for 1.2.0");
signale.fatal(new Error("Unable to acquire lock"));
signale.watch("Recursively watching build directory...");
signale.complete({
    prefix: "[task]",
    message: "Fix issue #59",
    suffix: "(@klauscfhq)"
});

// --- Test 2: Custom Loggers --- //

type CustomLogger = "remind" | "santa";

const optionsCustom: SignaleOptions<CustomLogger> = {
    stream: process.stdout,
    scope: "custom",
    types: {
        remind: {
            badge: "**",
            color: "yellow",
            label: "reminder"
        },
        santa: {
開發者ID:Jeremy-F,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:signale-tests.ts

示例3: scopedConfigTest

function scopedConfigTest() {
    // `fooLogger` inherits the config of `signale`
    const fooLogger = signale.scope("foo scope");

    // Overrides both `signale` and `package.json` configs
    fooLogger.config({
        displayFilename: true,
        displayTimestamp: false,
        displayDate: true
    });

    fooLogger.success("Hello from the Local scope");
}
開發者ID:Jeremy-F,項目名稱:DefinitelyTyped,代碼行數:13,代碼來源:signale-tests.ts

示例4:

 socketIOServer.on('disconnect', () => {
     logger.info('Browser extension disconnected')
 })
開發者ID:JoYiRis,項目名稱:sourcegraph,代碼行數:3,代碼來源:auto-reloading.ts

示例5:

setTimeout(() => {
    signale.timeEnd();
    signale.timeEnd();
    signale.timeEnd("test");
}, 500);
開發者ID:Jeremy-F,項目名稱:DefinitelyTyped,代碼行數:5,代碼來源:signale-tests.ts


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