本文整理匯總了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', {})
}
}
}
示例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: {
示例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");
}
示例4:
socketIOServer.on('disconnect', () => {
logger.info('Browser extension disconnected')
})
示例5:
setTimeout(() => {
signale.timeEnd();
signale.timeEnd();
signale.timeEnd("test");
}, 500);