本文整理汇总了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);