Node.js
-
[Nodejs] Winston모듈이용하여 로그파일 생성 및 설정, httpd로그도 파일에 저장되게하기Node.js 2019. 5. 14. 15:56
1. npm install --save -y winston winston-daily-rotate-file : 모듈설치 ** log 파일 경로 지정하기 위해 app-root-path 모듈을 이용했다.(npm install --save app-root-path 필요) 리눅스일 경우 winston.js var winstonDaily = require('winston-daily-rotate-file'); const { createLogger, format, transports } = require('winston'); // 한번에 여러개의 객체를 한번에 만든다. 모든 변수가 winston관련 모듈을 불러온다 // const { combine, timestamp, printf } = format; // forma..
-
[Nodejs] module.export, export 의 차이점Node.js 2019. 5. 9. 19:27
nodejs에서 분리된 소스파일을 별도의 모듈처럼 사용할 수 있다. 일단 모듈을 생성하는 방법에는 두가지가 있다. 직접 exports 객체에 프로퍼티를 할당하는방법, module.exports 에 객체를 할당하는 방법 일단 두가지가 있다고 이해하고 넘어가자 1. export = export는 단순히 module.exports 를 참조할 뿐이다. 짧은 alias로 생각하면된다. module.exports 외 exports는 같은 객체를 참조 있으며 리턴은 항상 module.exports 이다. 결국에 같은거 아니야? 라고 생각할 수 도 있다. 생각이 아니라 같다라고하는 말도 맞다. 그래서 어떻게 사용해야되는지가 문제이다. 사용방법의 목적따라 다르다 2. module.exports sss.js 파일 var ..