Skip to content

Commit

Permalink
docs: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Jun 3, 2023
1 parent 41f99b6 commit 7086da8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 30 deletions.
2 changes: 1 addition & 1 deletion libs/zhi-lib-base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-lib-base",
"version": "0.0.2",
"version": "0.1.0",
"type": "module",
"description": "minimization dependencies for class library",
"main": "./dist/index.js",
Expand Down
62 changes: 36 additions & 26 deletions libs/zhi-lib-base/src/logger/simpleLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,43 +63,53 @@ const simpleLogger = (name: string, customSign?: string, isDev?: boolean): ILogg
}
}

const infoLog = (msg: any, obj?: any) => {
const time = formatDate(new Date())
if (obj) {
console.info(`[${sign}] [${time}] [INFO] [${name}] ${msg}`, obj)
} else {
console.info(`[${sign}] [${time}] [INFO] [${name}] ${msg}`)
}
}
const warnLog = (msg: any, obj?: any) => {
const time = formatDate(new Date())
if (obj) {
console.warn(`[${sign}] [${time}] [WARN] [${name}] ${msg}`, obj)
} else {
console.warn(`[${sign}] [${time}] [WARN] [${name}] ${msg}`)
}
}
const errorLog = (msg: string | Error, obj?: any) => {
const time = formatDate(new Date())
if (obj) {
if (typeof msg == "string") {
console.error(`[${sign}] [${time}] [ERROR] [${name}] ${msg}`, obj)
} else {
console.error(`[${sign}] [${time}] [ERROR] [${name}] ${msg.toString()}`, obj)
}
} else {
if (typeof msg == "string") {
console.error(`[${sign}] [${time}] [ERROR] [${name}] ${msg.toString()}`)
} else {
console.error(`[${sign}] [${time}] [ERROR] [${name}] an error occurred =>`, msg)
}
}
}

return {
debug: (msg: string, obj?: any) => {
if (isDev) {
log("DEBUG", msg, obj)
}
},
info: (msg: string, obj?: any) => {
const time = formatDate(new Date())
if (obj) {
console.info(`[${sign}] [${time}] [INFO] ${msg}`, obj)
} else {
console.info(`[${sign}] [${time}] [INFO] ${msg}`)
}
infoLog(msg, obj)
},
warn: (msg: string, obj?: any) => {
const time = formatDate(new Date())
if (obj) {
console.warn(`[${sign}] [${time}] [WARN] ${msg}`, obj)
} else {
console.warn(`[${sign}] [${time}] [WARN] ${msg}`)
}
warnLog(msg, obj)
},
error: (msg: string | Error, obj?: any) => {
const time = formatDate(new Date())
if (obj) {
if (typeof msg == "string") {
console.error(`[${sign}] [${time}] [ERROR] ${msg}`, obj)
} else {
console.error(`[${sign}] [${time}] [ERROR] ${msg.toString()}`, obj)
}
} else {
if (typeof msg == "string") {
console.error(`[${sign}] [${time}] [ERROR] ${msg.toString()}`)
} else {
console.error(`[${sign}] [${time}] [ERROR] an error occurred =>`, msg)
}
}
errorLog(msg, obj)
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ class MetaWeblogApiAdaptor extends BlogApi {
*/
constructor(appInstance: any, cfg: MetaweblogConfig) {
super()
this.logger = simpleLogger("zhi-metaweblog-api", "metaweblog-api-adaptor", false)
this.logger = simpleLogger("metaweblog-api-adaptor", "zhi-metaweblog-api", false)

this.cfg = cfg
this.commonXmlrpcClient = new CommonXmlrpcClient(appInstance, cfg.apiUrl)
this.logger.info("MetaWeblog API inited")
}

public async getUsersBlogs(): Promise<Array<UserBlog>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class WordpressApiAdaptor extends MetaWeblogApiAdaptor {
constructor(appInstance: any, cfg: WordpressConfig) {
super(appInstance, cfg)

this.logger = simpleLogger("zhi-wordpress-api", "wordpress-api-adaptor", false)
this.logger = simpleLogger("wordpress-api-adaptor", "zhi-wordpress-api", false)
this.logger.info("WordPress API inited")
}
}

Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-xmlrpc-middleware/src/lib/commonXmlrpcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CommonXmlrpcClient {

constructor(appInstance: any, apiUrl: string) {
this.appInstance = appInstance
this.logger = simpleLogger("common-xmlrpc-client")
this.logger = simpleLogger("common-xmlrpc-client", "zhi-xmlrpc-middleware")
this.apiUrl = apiUrl
}

Expand Down

0 comments on commit 7086da8

Please sign in to comment.