2023-07-23 07:27:41 +07:00
|
|
|
import { Spinner } from "cli-spinner"
|
2023-06-05 00:37:43 +07:00
|
|
|
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-24 01:49:26 +07:00
|
|
|
end(text?: string) {
|
2023-06-05 00:37:43 +07:00
|
|
|
if (!this.verbose) {
|
|
|
|
this.spinner!.stop(true)
|
|
|
|
}
|
2023-07-24 01:49:26 +07:00
|
|
|
if (text) {
|
|
|
|
console.log(text)
|
|
|
|
}
|
2023-06-05 00:37:43 +07:00
|
|
|
}
|
|
|
|
}
|