Skip to content

Commit

Permalink
feat: 增加日志
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed May 14, 2023
1 parent 25a750e commit 07a075e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions plugins/publisher-main/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@ import { Dialog, isMobile, Menu, Plugin } from "siyuan"
import App from "./App.svelte"
import { DeviceDetection, DeviceTypeEnum } from "zhi-device"
import { Env } from "zhi-env"
import { CustomLogFactory, DefaultLogger, LogLevelEnum } from "zhi-log"

const STORAGE_NAME = "menu-config"
const SETTING_CONTAINER = "publish-tool-setting"

// https://github.com/sveltejs/svelte-preprocess/issues/91#issuecomment-548527600
export default class PublishTool extends Plugin {
private env: Env = new Env(import.meta.env)
private logger: DefaultLogger = new CustomLogFactory(LogLevelEnum.LOG_LEVEL_INFO, "publish-tool", this.env).getLogger(
"main"
)

// lifecycle
public onload() {
this._addTopBar()
console.log(`Publish Tool loaded ${new Date().getTime()}`)
this.logger.debug(`Publish Tool loaded ${new Date().getTime()}`)
}

public onunload() {
console.log("Publish Tool unloaded")
this.logger.debug("Publish Tool unloaded")
}

public openSetting() {
Expand Down Expand Up @@ -125,7 +129,7 @@ export default class PublishTool extends Plugin {
private _showPublisherWidget() {
const win = window as any
const deviceType: DeviceTypeEnum = DeviceDetection.getDevice()
console.log(`you are from ${deviceType}`)
this.logger.info(`you are from ${deviceType}`)

const publisherIndex = `/widgets/sy-post-publisher/index.html`

Expand All @@ -146,7 +150,7 @@ export default class PublishTool extends Plugin {
// const pageUrl = "detail/index.html"

win.syp.renderPublishHelper(pageId, pageUrl, win, this.env.isDev())
console.log("publisherHook inited")
this.logger.debug("publisherHook inited")
})
})
} else {
Expand Down

0 comments on commit 07a075e

Please sign in to comment.