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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@lactea-blue/lululala

v1.2.0

Published

logging interceptor using winston

Downloads

17

Readme

lululala

서버에서 발생하는 로그들을 같은 패턴으로 파일에 저장하는 라이브러리
local 환경에서는 console 창에도 로그가 같이 기록된다.
로그는 2가지 타입으(api-log, console-log, exception-log)로 나눌 수 있다.
api-log는 API의 request, response 값을 저장하며, exception-log는 exception이 발생하였을 때, exception 메세지를 저장하는 로그이며, console-log는 프로그래머 지정 로그를 저장한다.

Installation

$ npm install --save @lactea-blue/lululala

How to use

  1. configuration 라이브러리를 다운받는다.
    기록되는 로그 파일의 이름을 환경변수 지정해주기 위해 해당 라이브러리를 사용한다.
  2. configuration이 참조할 환경 변수 파일(.env 파일)에 해당 변수들을 지정한다.
    API_LOG_FILE_NAME_PREFIX=api-test-server (api-log가 저장되는 파일 이름)
    CONSOLE_FILE_NAME_PREFIX=cosole-test-server (console-log가 저장되는 파일 이름)
    EXCEPTION_LOG_FILE_NAME_PREFIX=exception-test-server (exception-log가 저장되는 파일 이름)
  3. main 함수에서 global interceptor로 지정한다.
     import { NestFactory } from '@nestjs/core';
     import {ConfigService} from "@nestjs/config";
     import {LoggingInterceptor} from "@lactea-blue/lululala";
        
     async function bootstrap() {
       const app = await NestFactory.create(AppModule)
        
       let configService = app.get(ConfigService);
        
       app.useGlobalInterceptors(new LoggingInterceptor(configService))
        
       await app.listen(3000)
     }
     bootstrap();
  4. 프로그램 build nest build
  5. 프로그램 실행시 아래를 참조하여 각 환경에 맞는 시스템 환경변수(NODE_ENV)를 지정해준다.
    #로컬 환경: NODE_ENV=local
    #개발 환경: NODE_ENV=dev  | NODE_ENV=development 
    #운영 환경: NODE_ENV=prod | NODE_ENV=production
    NODE_ENV=local nest start 

Custom Log

  • 방법 1
    1. main.ts에 log를 기록할 수 있는 logger를 global 변수로 등록한다.
        import { NestFactory } from '@nestjs/core';
        import { AppModule } from './app.module';
        import {CustomLogger, LoggingInterceptor} from "@lactea-blue/lululala";
        import {ConfigService} from "@nestjs/config";
           
        async function bootstrap() {
         const app = await NestFactory.create(AppModule);
           
         let configService = app.get(ConfigService);
         app.useGlobalInterceptors(new LoggingInterceptor(configService))
                
         //global 변수로 설정
         global.customLogger = new CustomLogger(configService).createLogger();
         await app.listen(3000);
        }
        bootstrap();
    2. 실제 서비스에서 사용
      class TestServcie {
           
         async testFunction() {
            global.customLogger.info("test용 custion log");
         }
      }
  • 방법 2
    import {ConfigService} from "@nestjs/config";
    import {CustomLogger} from "@lactea-blue/lululala";
      
    class TestServcie {
      constructor(
      private readonly configService: ConfigService 
      ) {}
        
      private logger = new CustomLogger(this.configService).createLogger();
      async testFunction() {
        this.logger.info("test용 custion log");
      }
    }

File output

  • api-log
    {
      "@timestamp": "2023-01-04T09:01:41.065Z",
      "apiLog": {
        "requestLog": {
          "uri": "/test-api",
          "httpMethod": "GET",
          "controllerMethodArgs": "{\"body\":{},\"query\":{}}",
          "requestHeader": "{header에 있는 정보들....}"
        },
        "responseLog": {
          "responseBody": "{}",
          "httpStatusCode": 200
        },
        "apiStartTime": "2023-01-04T09:01:41.058Z",
        "apiEndTime": "2023-01-04T09:01:41.062Z",
        "duration": {
          "time": 4,
          "unit": "MILLIS",
          "readableString": "0시간 0분 0.004초"
        }
      }
    }
    위의 형태로 ./logs/api/{api-log 파일 이름}_yyyy-dd-mm.log 파일에 적힌다.
  • console-log
     {
     "@timestamp": "2023-01-05T01:31:27.830Z",
     "level": "info",
     "message": "test message"
     }
    위의 형태로 ./logs/normal/{console-log 파일 이름}_yyyy-dd-mm.log 파일에 적힌다.
  • exception-log
    {
      "@timestamp": "2023-01-04T09:01:41.067Z",
      "level": "error",
      "message": {
        "requestLog": {
          "uri": "/test-exception",
          "httpMethod": "GET",
          "controllerMethodArgs": "{\"body\":{},\"query\":{}}",
          "requestHeader": "{header에 있는 정보들....}"
        },
        "responseLog": {
          "httpStatusCode": 500
        },
        "exceptionMessage": "error message",
        "exceptionStack": "Error stack"
      }
    }

위의 형태로 ./logs/exception/{exception-log 파일 이름}_yyyy-dd-mm.log 파일에 적힌다.