HOME 개발팁 폴더 로그 기록함수

프로그램 작업하다 좋은 팁, 정보, 테스트를 기록하는 곳입니다.


node | 폴더 로그 기록함수

페이지 정보

작성자 굿스웹 작성일20-02-25 15:04 조회673회 댓글0건

본문

function saveLog (nick, command) {
var dt = new Date();
var today = dt.toFormat('YYYY-MM-DD');
var todaytime = dt.toFormat('YYYY-MM-DD HH24:MI:SS');
    var file = 'log/' + nick + '_' + today + '.log';
    var datetime = '[' + todaytime + '] : ';
    var text = datetime + command + '\r\n';
    fs.appendFile(file, text, function (err) {
        if (err) return console.log(err);
        //console.log('successfully appended : ' + text + '');
    });
}




var fs = require('fs');


function quicklog(s) {
    var logpath = "log/api_quick.log";
    var fs = require('fs');
    s = s.toString().replace(/\r\n|\r/g, '\n'); // hack
    var fd = fs.openSync(logpath, 'a+', 0666);
    fs.writeSync(fd, s + '\n');
    fs.closeSync(fd);
}

quicklog('11')




var winston = require('winston');
  require('winston-daily-rotate-file');
 
  var transport = new (winston.transports.DailyRotateFile)({
    filename: 'log/application-%DATE%.log',
    datePattern: 'YYYY-MM-DD-HH',
    zippedArchive: true,
    maxSize: '20m',
    maxFiles: '14d'
  });
 
  transport.on('rotate', function(oldFilename, newFilename) {
    // do something fun
  });
 
  var logger = winston.createLogger({
    transports: [
      transport
    ]
  });
 
  logger.info('Hello World!');

  /*
  npm install winston-daily-rotate-file
 
  */

[주소복사] https://www.goodsweb.kr/?u=D416BK8S
SNS 알리기
핀터레스트
텔레그램로
블로그로
카카오스토리
카톡 공유

관련 블로그
로딩중


3명  IP : 3.23.♡.197
001 40.♡.167.5 알림톡 카카오
(/bbs/content.php?co_id=kakao_sms)
002 18.♡.46.36 다음 - 시작페이지
(/bbs/board.php?bo_table=startpage&wr_id=2&page=2)
003 207.♡.13.154 전체검색 결과
(/bbs/search.php?sfl=wr_subject%7C%7Cwr_content&stx=6&sop=and&gr_id=&srows=10&onetable=tip&page=8)

접속자
  • 오늘 : 324
  • 어제 : 363
  • 최대 : 874
  • 전체 : 404,246

검색로봇(Robots) 최근 방문시간
  • NAVER : 6시간 전
  • BING : 17시간 전
  • GOOGLE : 1일 전
  • DAUM : 4일 전

ETH : 0x8abf3B748ab78828AE07685e4fd53d1a606f18D3



페이스북 네이버 블로그 굿스웹 쇼핑몰 네이버 카페 굿스웹 트위터 굿스웹 티스토리 Google Play