npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ajielog

v2.0.2

Published

1. 安装日志模块 ```shell npm install ajielog ```

Downloads

11

Readme

AjieLog日志模块

基础使用

  1. 安装日志模块

    npm install ajielog
  2. 创建日志模块实例

    let logger = new AjieLog();
  3. 输出日志

    logger.debug("debug类型日志");
    logger.info("info类型日志");
    logger.warn("warn类型日志");
    logger.err("err类型日志");
    logger.fatal("fatal类型日志\n");
    logger.log("指定类型的日志", "my_type");
    logger.log("空类型日志1", "");
    logger.log("空类型日志2");
    logger.saveLog();
  4. 注意事项

    • 日志模块应在结束应用时手动保存所有数据,否则可能出现缓冲区中日志未写入日志文件的问题。

接口

declare class AjieLog {
	constructor(config: {
		name: string | undefined,	// 日志模块名称(默认为匿名模块)
		file: {
			root_path: string | undefined, // 日志文件保存根路径(默认为log)
			split_by_date: boolean | undefined,	// 日志是否按日期分割(默认为true)
			extension: string | undefined,	// 日志文件拓展名(默认为log)
			file_name: string | undefined	// 日志文件前缀(默认为myLog)
		} | undefined,
		format: {
			force_single_row: boolean	// 日志是否强制单行(默认为true)
		},
		level: {
			file: number,	// 文件保存的日志等级(默认为0)
			console: number	// 控制台输出的日志等级(默认为0)
		} | number | undefined,	// 一次性设置文件保存和控制台输出的日志等级(默认为0)
		time_format: string | undefined,	// 时间日期的格式(默认为"YYYY-MM-DD HH:mm:ss.SSS")
		save_interval: number,	// 日志文件保存间隔,单位秒。0为立即保存(默认为5)
	} | undefined);

	/**
	 * 获取一个实例
	 */
	static getInstance(name: string): AjieLog;

	/**
	 * 指定类型写入一行日志
	 */
	log(content: string, type: ?string): void;

	/**
	 * 写入一行debug类型日志
	 */
	debug(content: string): void;

	/**
	 * 写入一行debug类型日志
	 */
	info(content: string): void;

	/**
	 * 写入一行warn类型日志
	 */
	warn(content: string): void;

	/**
	 * 写入一行err类型日志
	 */
	err(content: string): void;

	/**
	 * 写入一行fatal类型日志
	 */
	fatal(content: string): void;

	/**
	 * 手动保存日志
	 */
	saveLog(): Promise<void>
}