• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript logging.Logger类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@src/lib/logging.Logger的典型用法代码示例。如果您正苦于以下问题:TypeScript Logger类的具体用法?TypeScript Logger怎么用?TypeScript Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Logger类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: parser

export function parser(exstr: string, all_excmds: any): any[] {
    // Expand aliases
    const expandedExstr = aliases.expandExstr(exstr)
    const [func, ...args] = expandedExstr.trim().split(/\s+/)

    // Try to find which namespace (ex, text, ...) the command is in
    const dotIndex = func.indexOf(".")
    const namespce = func.substring(0, dotIndex)
    const funcName = func.substring(dotIndex + 1)
    const excmds = all_excmds[namespce]

    if (excmds === undefined) {
        throw new Error(`Unknwown namespace: ${namespce}.`);
    }

    // Convert arguments, but only for ex commands
    let converted_args
    if (namespce == "") {
        let types
        try {
            types = (metadata
                .getFile("src/excmds.ts")
                .getFunction(funcName)
                .type as FunctionType)
                .args
        } catch (e) {
            throw `Could not find type information for excmd ${funcName}`
        }
        try {
            converted_args = convertArgs(types, args)
        } catch (e) {
            logger.error("Error executing or parsing:", exstr, e)
            throw e
        }
    } else {
        converted_args = args
    }

    if (excmds[funcName] === undefined) {
        logger.error("Not an excmd:", exstr)
        throw `Not an excmd: ${func}`
    }

    return [excmds[funcName], converted_args]
}
开发者ID:antonva,项目名称:tridactyl,代码行数:45,代码来源:exmode.ts


示例2: updateVersion

async function updateVersion() {
    try {
        // If any monster any makes a novelty tag this will break.
        // So let's just ignore any errors.
        const parser = new RssParser()
        const feed = await parser.parseURL("https://github.com/tridactyl/tridactyl/tags.atom")
        const mostRecent = feed.items[0]

        // Update our last update check timestamp and the version itself.
        Config.set("update", "lastchecktime", Date.now())
        highestKnownVersion = {
            version: mostRecent.title,
            releaseDate: new Date(mostRecent.pubDate), // e.g. 2018-12-04T15:24:43.000Z
        }
        logger.debug("Checked for new version of Tridactyl, found ", highestKnownVersion)
    } catch (e) {
        logger.error("Error while checking for updates: ", e)
    }
}
开发者ID:antonva,项目名称:tridactyl,代码行数:19,代码来源:updates.ts


示例3: Error

export async function create(
    name: string,
    color = "random",
    icon = "fingerprint",
): Promise<string> {
    if (color === "random") color = chooseRandomColor()
    const container = fromString(name, color, icon)
    // browser.contextualIdentities.create does not accept a cookieStoreId property.
    delete container.cookieStoreId
    logger.debug(container)

    if (await exists(name)) {
        logger.debug(`[Container.create] container already exists ${container}`)
        throw new Error(
            `[Container.create] container already exists, aborting.`,
        )
    } else {
        const res = await browser.contextualIdentities.create(container)
        return res.cookieStoreId
    }
}
开发者ID:antonva,项目名称:tridactyl,代码行数:21,代码来源:containers.ts


示例4: addContentStateChangedListener

    addContentStateChangedListener((property, oldMode, oldValue, newValue) => {
        let mode = newValue
        let suffix = ""
        let result = ""
        if (property !== "mode") {
            if (property === "suffix") {
                mode = oldMode
                suffix = newValue
            } else {
                return
            }
        }

        const privateMode = browser.extension.inIncognitoContext
            ? "TridactylPrivate"
            : ""
        statusIndicator.className =
            "cleanslate TridactylStatusIndicator " + privateMode
        if (
            dom.isTextEditable(document.activeElement) &&
            !["input", "ignore"].includes(mode)
        ) {
            statusIndicator.textContent = "insert"
            // this doesn't work; statusIndicator.style is full of empty string
            // statusIndicator.style.borderColor = "green !important"
            // need to fix loss of focus by click: doesn't do anything here.
        } else if (
            mode === "insert" &&
            !dom.isTextEditable(document.activeElement)
        ) {
            statusIndicator.textContent = "normal"
            // statusIndicator.style.borderColor = "lightgray !important"
        } else {
            result = mode
        }
        const modeindicatorshowkeys = Config.get("modeindicatorshowkeys")
        if (modeindicatorshowkeys === "true" && suffix !== "") {
            result = mode + " " + suffix
        }
        logger.debug(
            "statusindicator: ",
            result,
            ";",
            "config",
            modeindicatorshowkeys,
        )
        statusIndicator.textContent = result
        statusIndicator.className +=
            " TridactylMode" + statusIndicator.textContent

        if (config.get("modeindicator") !== "true") statusIndicator.remove()
    })
开发者ID:antonva,项目名称:tridactyl,代码行数:52,代码来源:content.ts


示例5: registerEvListenerAction

export function registerEvListenerAction(
    elem: EventTarget,
    add: boolean,
    event: string,
) {
    // We're only interested in the subset of EventTargets that are Elements.
    if (!(elem instanceof Element)) {
        return
    }

    // Prevent bad elements from being processed
    //
    // This is defence in depth: we should never receive an invalid elem here
    // because add/removeEventListener currently throws a TypeError if the given
    // element is not a standard library EventTarget subclass.
    try {
        // Node prototype functions work on the C++ representation of the
        // Node, which a faked JS object won't have.
        // hasChildNodes() is chosen because it should be cheap.
        Node.prototype.hasChildNodes.apply(elem)
    } catch (e) {
        // Don't throw a real exception because addEventListener wouldn't and we
        // don't want to break content code.
        logger.error("Elem is not a real Node", elem)
        return
    }

    switch (event) {
        case "click":
        case "mousedown":
        case "mouseup":
        case "mouseover":
            if (add) {
                hintworthy_js_elems.push(elem)
            } else {
                // Possible bug: If a page adds an event listener for "click" and
                // "mousedown" and removes "mousedown" twice, we lose track of the
                // elem even though it still has a "click" listener.
                // Fixing this might not be worth the added complexity.
                const index = hintworthy_js_elems.indexOf(elem)
                if (index >= 0) hintworthy_js_elems.splice(index, 1)
            }
    }
}
开发者ID:antonva,项目名称:tridactyl,代码行数:44,代码来源:dom.ts


示例6: exists

export async function exists(cname: string): Promise<boolean> {
    let exists = false
    try {
        const containers = await getAll()
        const res = containers.filter(c => {
            return c.name.toLowerCase() === cname.toLowerCase()
        })
        if (res.length > 0) {
            exists = true
        }
    } catch (e) {
        exists = true // Make sure we don't accidentally break the constraint on query error.
        logger.error(
            "[Container.exists] Error querying contextualIdentities:",
            e,
        )
    }
    return exists
}
开发者ID:antonva,项目名称:tridactyl,代码行数:19,代码来源:containers.ts


示例7: theme

export async function theme(element) {
    // Remove any old theme
    for (const theme of THEMES.map(prefixTheme)) {
        element.classList.remove(theme)
    }
    if (insertedCSS) {
        // Typescript doesn't seem to be aware than remove/insertCSS's tabid
        // argument is optional
        await browserBg.tabs.removeCSS(await ownTabId(), customCss)
        insertedCSS = false
    }

    const newTheme = await config.getAsync("theme")

    // Add a class corresponding to config.get('theme')
    if (newTheme !== "default") {
        element.classList.add(prefixTheme(newTheme))
    }

    // Insert custom css if needed
    if (newTheme !== "default" && !THEMES.includes(newTheme)) {
        customCss.code = await config.getAsync("customthemes", newTheme)
        if (customCss.code) {
            await browserBg.tabs.insertCSS(await ownTabId(), customCss)
            insertedCSS = true
        } else {
            logger.error("Theme " + newTheme + " couldn't be found.")
        }
    }

    // Record for re-theming
    // considering only elements :root (page and cmdline_iframe)
    // TODO:
    //     - Find ways to check if element is already pushed
    if (
        THEMED_ELEMENTS.length < 2 &&
        element.tagName.toUpperCase() === "HTML"
    ) {
        THEMED_ELEMENTS.push(element)
    }
}
开发者ID:antonva,项目名称:tridactyl,代码行数:41,代码来源:styling.ts



注:本文中的@src/lib/logging.Logger类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript messaging.addListener函数代码示例发布时间:2022-05-28
下一篇:
TypeScript logging.info函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap