当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript logging.info函数代码示例

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


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

示例1: getrc

export async function getrc(): Promise<string> {
    const res = await sendNativeMsg("getconfig", {})

    if (res.content && !res.error) {
        logger.info(`Successfully retrieved fs config:\n${res.content}`)
        return res.content
    } else {
        // Have to make this a warning as async exceptions apparently don't get caught
        logger.info(`Error in retrieving config: ${res.error}`)
    }
}
开发者ID:antonva,项目名称:tridactyl,代码行数:11,代码来源:native.ts

示例2: applyWithTmpTextArea

 applyWithTmpTextArea(scratchpad => {
     scratchpad.value = content
     scratchpad.select()
     if (document.execCommand("Copy")) {
         // // todo: Maybe we can consider to using some logger and show it with status bar in the future
         logger.info("set clipboard:", scratchpad.value)
     } else throw "Failed to copy!"
 })
开发者ID:antonva,项目名称:tridactyl,代码行数:8,代码来源:commandline_frame.ts

示例3: sendNativeMsg

/**
 * Posts using the one-time message API; native is killed after message returns
 */
async function sendNativeMsg(
    cmd: MessageCommand,
    opts: object,
    quiet = false,
): Promise<MessageResp> {
    const send = Object.assign({ cmd }, opts)
    let resp
    logger.info(`Sending message: ${JSON.stringify(send)}`)

    try {
        resp = await browserBg.runtime.sendNativeMessage(NATIVE_NAME, send)
        logger.info(`Received response:`, resp)
        return resp as MessageResp
    } catch (e) {
        if (!quiet) {
            throw new Error(
                "Failed to send message to native messenger. If it is correctly installed (run `:native`), please report this bug on https://github.com/tridactyl/tridactyl/issues .",
            )
        }
    }
}
开发者ID:antonva,项目名称:tridactyl,代码行数:24,代码来源:native.ts

示例4: clobberCSP

export function clobberCSP(response) {
    const headers = response.responseHeaders
    const cspHeader = headers.find(
        header => header.name.toLowerCase() === "content-security-policy",
    )

    if (cspHeader !== undefined) {
        const policy = new DefaultMap<string, Set<string>>(
            () => new Set(),
            csp.parse(cspHeader.value),
        )
        logger.info(
            "given CSP",
            cspHeader.value,
            "parsed CSP",
            policy,
            "reserialized CSP",
            csp.serialize(policy),
        )
        policy.delete("sandbox")

        // Loosen style-src directive if it or default-src are present.
        if (policy.has("default-src") && !policy.has("style-src")) {
            policy.set("style-src", policy.get("default-src"))
        }
        if (policy.has("style-src")) {
            policy
                .get("style-src")
                .add("'unsafe-inline'")
                .add("'self'")
        }

        // Replace old CSP
        cspHeader.value = csp.serialize(policy)
        logger.info("new CSP", cspHeader.value, "parsed as", policy)
        return { responseHeaders: headers }
    } else {
        return {}
    }
}
开发者ID:antonva,项目名称:tridactyl,代码行数:40,代码来源:requests.ts

示例5: getNativeMessengerVersion

export async function getNativeMessengerVersion(
    quiet = false,
): Promise<number> {
    const res = await sendNativeMsg("version", {}, quiet)
    if (res === undefined) {
        if (quiet) return undefined
        throw `Error retrieving version: ${res.error}`
    }
    if (res.version && !res.error) {
        logger.info(`Native version: ${res.version}`)
        return res.version
    }
}
开发者ID:antonva,项目名称:tridactyl,代码行数:13,代码来源:native.ts

示例6: run

export async function run(command: string, content = "") {
    const msg = await sendNativeMsg("run", { command, content })
    logger.info(msg)
    return msg
}
开发者ID:antonva,项目名称:tridactyl,代码行数:5,代码来源:native.ts


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