本文整理汇总了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}`)
}
}
示例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!"
})
示例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 .",
)
}
}
}
示例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 {}
}
}
示例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
}
}
示例6: run
export async function run(command: string, content = "") {
const msg = await sendNativeMsg("run", { command, content })
logger.info(msg)
return msg
}