本文整理匯總了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
}