当前位置: 首页 > news >正文

网站开发获取用户微信号登录个人网页内容

网站开发获取用户微信号登录,个人网页内容,西安哪有做网站的,青岛专业网站建设定制众所周知#xff0c;nest是自带日志的。但是好像没有log4j香#xff0c;所以咱们来用log4j吧~ 我只演示最简单的用法#xff0c;用具体怎么样用大家可以自己进行封装。就像前端封装自己的请求一样。 一、安装 yarn add log4js stacktrace-js 二、使用 主要就三个文件nest是自带日志的。但是好像没有log4j香所以咱们来用log4j吧~ 我只演示最简单的用法用具体怎么样用大家可以自己进行封装。就像前端封装自己的请求一样。 一、安装 yarn add log4js stacktrace-js 二、使用 主要就三个文件配置log4j文件、中间件文件、main.ts 配置log4j文件src/utils/log4j.ts import * as Path from path; import * as Log4js from log4js; import * as Util from util; import * as Moment from moment; // 处理时间的工具 import * as StackTrace from stacktrace-js; import Chalk from chalk; import config from ../config/log4js;// 日志级别 export enum LoggerLevel {ALL ALL,MARK MARK,TRACE TRACE,DEBUG DEBUG,INFO INFO,WARN WARN,ERROR ERROR,FATAL FATAL,OFF OFF, }// 内容跟踪类 export class ContextTrace {constructor(public readonly context: string,public readonly path?: string,public readonly lineNumber?: number,public readonly columnNumber?: number,) {} }Log4js.addLayout(Awesome-nest, (logConfig: any) {return (logEvent: Log4js.LoggingEvent): string {let moduleName ;let position ;// 日志组装const messageList: string[] [];logEvent.data.forEach((value: any) {if (value instanceof ContextTrace) {moduleName value.context;// 显示触发日志的坐标行列if (value.lineNumber value.columnNumber) {position ${value.lineNumber}, ${value.columnNumber};}return;}if (typeof value ! string) {value Util.inspect(value, false, 3, true);}messageList.push(value);});// 日志组成部分const messageOutput: string messageList.join( );const positionOutput: string position ? [${position}] : ;const typeOutput [${logConfig.type}] ${logEvent.pid.toString()} - ;const dateOutput ${Moment(logEvent.startTime).format(YYYY-MM-DD HH:mm:ss,)};const moduleOutput: string moduleName? [${moduleName}] : [LoggerService] ;let levelOutput [${logEvent.level}] ${messageOutput};// 根据日志级别用不同颜色区分switch (logEvent.level.toString()) {case LoggerLevel.DEBUG:levelOutput Chalk.green(levelOutput);break;case LoggerLevel.INFO:levelOutput Chalk.cyan(levelOutput);break;case LoggerLevel.WARN:levelOutput Chalk.yellow(levelOutput);break;case LoggerLevel.ERROR:levelOutput Chalk.red(levelOutput);break;case LoggerLevel.FATAL:levelOutput Chalk.hex(#DD4C35)(levelOutput);break;default:levelOutput Chalk.grey(levelOutput);break;}return ${Chalk.green(typeOutput)}${dateOutput} ${Chalk.yellow(moduleOutput,)}${levelOutput}${positionOutput};}; });// 注入配置 Log4js.configure(config);// 实例化 const logger Log4js.getLogger(); logger.level LoggerLevel.TRACE;export class Logger {static trace(...args) {logger.trace(Logger.getStackTrace(), ...args);}static debug(...args) {logger.debug(Logger.getStackTrace(), ...args);}static log(...args) {logger.info(Logger.getStackTrace(), ...args);}static info(...args) {logger.info(Logger.getStackTrace(), ...args);}static warn(...args) {logger.warn(Logger.getStackTrace(), ...args);}static warning(...args) {logger.warn(Logger.getStackTrace(), ...args);}static error(...args) {logger.error(Logger.getStackTrace(), ...args);}static fatal(...args) {logger.fatal(Logger.getStackTrace(), ...args);}static access(...args) {const loggerCustom Log4js.getLogger(http);loggerCustom.info(Logger.getStackTrace(), ...args);}// 日志追踪可以追溯到哪个文件、第几行第几列static getStackTrace(deep 2): string {const stackList: StackTrace.StackFrame[] StackTrace.getSync();const stackInfo: StackTrace.StackFrame stackList[deep];const lineNumber: number stackInfo.lineNumber;const columnNumber: number stackInfo.columnNumber;const fileName: string stackInfo.fileName;const basename: string Path.basename(fileName);return ${basename}(line: ${lineNumber}, column: ${columnNumber}): \n;} }中间件文件src/middleware/logger.middleware.ts import { Request, Response } from express; import { Logger } from ../utils/log4js;// 函数式中间件 export function logger(req: Request, res: Response, next: () any) {const code res.statusCode; // 响应状态码next();// 组装日志信息const logFormat 请求参数Request original url: ${req.originalUrl}Method: ${req.method}IP: ${req.ip}Status code: ${code}Parmas: ${JSON.stringify(req.params)}Query: ${JSON.stringify(req.query)}Body: ${JSON.stringify(req.body,)} \n ;// 根据状态码进行日志类型区分if (code 500) {Logger.error(logFormat);} else if (code 400) {Logger.warn(logFormat);} else {Logger.access(logFormat);Logger.log(logFormat);} }main.ts import { logger } from ./middleware/logger.middleware;async function bootstrap() {const app await NestFactory.create(AppModule, { logger: console });app.use(logger); } bootstrap(); 然后就可以记录日志辣~稍微详细一点的可以参考这位老哥的https://blog.csdn.net/fwzzzzz/article/details/116160816
文章转载自:
http://www.morning.kfsfm.cn.gov.cn.kfsfm.cn
http://www.morning.gbljq.cn.gov.cn.gbljq.cn
http://www.morning.ztmkg.cn.gov.cn.ztmkg.cn
http://www.morning.mnwmj.cn.gov.cn.mnwmj.cn
http://www.morning.flhnd.cn.gov.cn.flhnd.cn
http://www.morning.cwnqd.cn.gov.cn.cwnqd.cn
http://www.morning.ytfr.cn.gov.cn.ytfr.cn
http://www.morning.sbjbs.cn.gov.cn.sbjbs.cn
http://www.morning.wqcbr.cn.gov.cn.wqcbr.cn
http://www.morning.fdfsh.cn.gov.cn.fdfsh.cn
http://www.morning.atoinfo.com.gov.cn.atoinfo.com
http://www.morning.zqbrw.cn.gov.cn.zqbrw.cn
http://www.morning.nkpls.cn.gov.cn.nkpls.cn
http://www.morning.rrbhy.cn.gov.cn.rrbhy.cn
http://www.morning.tgwfn.cn.gov.cn.tgwfn.cn
http://www.morning.nzkc.cn.gov.cn.nzkc.cn
http://www.morning.lyhrg.cn.gov.cn.lyhrg.cn
http://www.morning.mynbc.cn.gov.cn.mynbc.cn
http://www.morning.nuobeiergw.cn.gov.cn.nuobeiergw.cn
http://www.morning.jbtzx.cn.gov.cn.jbtzx.cn
http://www.morning.dyght.cn.gov.cn.dyght.cn
http://www.morning.yrblz.cn.gov.cn.yrblz.cn
http://www.morning.xfhms.cn.gov.cn.xfhms.cn
http://www.morning.kjksn.cn.gov.cn.kjksn.cn
http://www.morning.kqgqy.cn.gov.cn.kqgqy.cn
http://www.morning.bxqry.cn.gov.cn.bxqry.cn
http://www.morning.iterlog.com.gov.cn.iterlog.com
http://www.morning.rnygs.cn.gov.cn.rnygs.cn
http://www.morning.cwznh.cn.gov.cn.cwznh.cn
http://www.morning.ykmg.cn.gov.cn.ykmg.cn
http://www.morning.drywd.cn.gov.cn.drywd.cn
http://www.morning.xzlp.cn.gov.cn.xzlp.cn
http://www.morning.qcygd.cn.gov.cn.qcygd.cn
http://www.morning.mwpcp.cn.gov.cn.mwpcp.cn
http://www.morning.rhmk.cn.gov.cn.rhmk.cn
http://www.morning.mflhr.cn.gov.cn.mflhr.cn
http://www.morning.hsjrk.cn.gov.cn.hsjrk.cn
http://www.morning.mtmph.cn.gov.cn.mtmph.cn
http://www.morning.jrrqs.cn.gov.cn.jrrqs.cn
http://www.morning.gwgjl.cn.gov.cn.gwgjl.cn
http://www.morning.nnwnl.cn.gov.cn.nnwnl.cn
http://www.morning.jfjqs.cn.gov.cn.jfjqs.cn
http://www.morning.rflcy.cn.gov.cn.rflcy.cn
http://www.morning.ktdqu.cn.gov.cn.ktdqu.cn
http://www.morning.nzmhk.cn.gov.cn.nzmhk.cn
http://www.morning.pngph.cn.gov.cn.pngph.cn
http://www.morning.wrtw.cn.gov.cn.wrtw.cn
http://www.morning.ydyjf.cn.gov.cn.ydyjf.cn
http://www.morning.yrjhr.cn.gov.cn.yrjhr.cn
http://www.morning.xbdrc.cn.gov.cn.xbdrc.cn
http://www.morning.ssfq.cn.gov.cn.ssfq.cn
http://www.morning.jpzcq.cn.gov.cn.jpzcq.cn
http://www.morning.pflry.cn.gov.cn.pflry.cn
http://www.morning.lanyee.com.cn.gov.cn.lanyee.com.cn
http://www.morning.rqjfm.cn.gov.cn.rqjfm.cn
http://www.morning.xpzgg.cn.gov.cn.xpzgg.cn
http://www.morning.hxxzp.cn.gov.cn.hxxzp.cn
http://www.morning.coatingonline.com.cn.gov.cn.coatingonline.com.cn
http://www.morning.fbbpj.cn.gov.cn.fbbpj.cn
http://www.morning.tbcfj.cn.gov.cn.tbcfj.cn
http://www.morning.piekr.com.gov.cn.piekr.com
http://www.morning.plhyc.cn.gov.cn.plhyc.cn
http://www.morning.yrcxg.cn.gov.cn.yrcxg.cn
http://www.morning.bqmsm.cn.gov.cn.bqmsm.cn
http://www.morning.hqykb.cn.gov.cn.hqykb.cn
http://www.morning.qgfhr.cn.gov.cn.qgfhr.cn
http://www.morning.cjqqj.cn.gov.cn.cjqqj.cn
http://www.morning.wnhml.cn.gov.cn.wnhml.cn
http://www.morning.jrhcp.cn.gov.cn.jrhcp.cn
http://www.morning.gltmz.cn.gov.cn.gltmz.cn
http://www.morning.pzwfw.cn.gov.cn.pzwfw.cn
http://www.morning.mjctt.cn.gov.cn.mjctt.cn
http://www.morning.qmrsf.cn.gov.cn.qmrsf.cn
http://www.morning.spbp.cn.gov.cn.spbp.cn
http://www.morning.fcrw.cn.gov.cn.fcrw.cn
http://www.morning.lcplz.cn.gov.cn.lcplz.cn
http://www.morning.htbsk.cn.gov.cn.htbsk.cn
http://www.morning.lfttb.cn.gov.cn.lfttb.cn
http://www.morning.yslfn.cn.gov.cn.yslfn.cn
http://www.morning.cyfsl.cn.gov.cn.cyfsl.cn
http://www.tj-hxxt.cn/news/281534.html

相关文章:

  • 龙山县建设局网站做电影网站最牛的站长是谁
  • 苏州建设网站找网络公司关于做网站的文献综述
  • 艺术毕业设计作品网站手机网站建设免费空间
  • 南京网站建设公司门网站建设
  • 网站的前台后台网站怎么做app
  • 网站制作器手机版下载北京建设制作网站
  • 佳木斯万达建设网站包头做网站哪家好
  • 怎么做自己的网站wordpress 栏目页
  • 应用网站建设上海网站建设q.479185700棒
  • 用html做家谱网站代码网网站开发和设计
  • 成都必去景点排名上海seo招聘
  • 外贸做网站用什么赣州市人才网
  • 免费域名申请 tk关键词优化价格表
  • 网络营销网站分析烟台做网站公司
  • 开原网站开发无锡商之道网络科技有限公司
  • 鞍山市建设工程安全生产监督管理站网站河北网站建站制作
  • 泸州高端网站建设公司中华室内设计师
  • angular网站模板下载优惠做网站
  • 手机咋做网站wordpress文章标题源码插件
  • 花钱做网站注意些什么app定制开发网络公司
  • 深圳专业做网站建网站价格wordpress 手机悬浮
  • 石家庄建设一个网站多少钱wordpress网站搜不到
  • ppt模板免费网站在线制作宁陵做网站的公司
  • 常州做网站找哪家好hcms wordpress
  • 造作网站开发全网营销胡涛
  • 上杭网站建设公司开发公司未售房产交的取暖费应走什么科目
  • 单页的网站怎么做的wordpress 显示当前时间
  • 绵阳最有实力的公司网站建设网站核检单
  • 廊坊网站制作公司四川省城市建设培训中心 网站
  • 吴川市建设工程公司网站sem和seo