This repository has been archived on 2024-09-06. You can view files and clone it, but cannot push or open issues or pull requests.
quartz-wiki/quartz/util/log.ts

29 lines
530 B
TypeScript
Raw Permalink Normal View History

2024-01-10 14:39:54 +08:00
import { Spinner } from "cli-spinner"
export class QuartzLogger {
verbose: boolean
spinner: Spinner | undefined
constructor(verbose: boolean) {
this.verbose = verbose
}
start(text: string) {
if (this.verbose) {
console.log(text)
} else {
this.spinner = new Spinner(`%s ${text}`)
this.spinner.setSpinnerString(18)
this.spinner.start()
}
}
end(text?: string) {
if (!this.verbose) {
this.spinner!.stop(true)
}
if (text) {
console.log(text)
}
}
}