Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nestjs 中日志管理 #5

Open
fzc2018 opened this issue Mar 27, 2019 · 1 comment
Open

nestjs 中日志管理 #5

fzc2018 opened this issue Mar 27, 2019 · 1 comment

Comments

@fzc2018
Copy link

fzc2018 commented Mar 27, 2019

No description provided.

@StormKid
Copy link

可以用自己封装一个provider

import { Logger, Injectable } from '@nestjs/common';
@Injectable()
export class Log extends Logger {
  readonly isLog = true; // TODO 正式版本一定需要改成false

  w(key: string, content: any) {
    if (this.isLog) {
      this.warn(content, key);
    }
  }

  i(key: string, content: any) {
    if (this.isLog) {
      this.log(content, key);
    }
  }

  e(key: string, content: any) {
    if (this.isLog) {
      this.error(content, key);
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants