StrongLoop / IBM์— ์˜ํ•ด ์ œ๊ณต์ด ๋ฒˆ์—ญ.

์ด ๋ฌธ์„œ๋Š” ์˜๋ฌธํŒ ๋ฌธ์„œ์— ๋น„ํ•ด ๋” ์˜ค๋ž˜๋œ ๋ฒ„์ „์ผ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์ตœ์‹  ์—…๋ฐ์ดํŠธ๋ฅผ ํ™•์ธํ•˜๋ ค๋ฉด ์˜๋ฌธํŒ ๋ฌธ์„œ๋ฅผ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค.

โœ–

Express ๋””๋ฒ„๊น…

Express์—์„œ ์‚ฌ์šฉ๋˜๋Š” ๋ชจ๋“  ๋‚ด๋ถ€ ๋กœ๊ทธ๋ฅผ ํ™•์ธํ•˜๋ ค๋ฉด, ์•ฑ์„ ์‹คํ–‰ํ•  ๋•Œ DEBUG ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ express:*๋กœ ์„ค์ •ํ•˜์‹ญ์‹œ์˜ค.

$ DEBUG=express:* node index.js

Windows์—์„œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ช…๋ น์„ ์‚ฌ์šฉํ•˜์‹ญ์‹œ์˜ค.

> set DEBUG=express:* & node index.js

Express ์ƒ์„ฑ๊ธฐ๊ฐ€ ์ƒ์„ฑํ•œ ๊ธฐ๋ณธ ์•ฑ์— ๋Œ€ํ•ด ์ด ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ธ์‡„๋ฉ๋‹ˆ๋‹ค.

$ DEBUG=express:* node ./bin/www
  express:router:route new / +0ms
  express:router:layer new / +1ms
  express:router:route get / +1ms
  express:router:layer new / +0ms
  express:router:route new / +1ms
  express:router:layer new / +0ms
  express:router:route get / +0ms
  express:router:layer new / +0ms
  express:application compile etag weak +1ms
  express:application compile query parser extended +0ms
  express:application compile trust proxy false +0ms
  express:application booting in development mode +1ms
  express:router use / query +0ms
  express:router:layer new / +0ms
  express:router use / expressInit +0ms
  express:router:layer new / +0ms
  express:router use / favicon +1ms
  express:router:layer new / +0ms
  express:router use / logger +0ms
  express:router:layer new / +0ms
  express:router use / jsonParser +0ms
  express:router:layer new / +1ms
  express:router use / urlencodedParser +0ms
  express:router:layer new / +0ms
  express:router use / cookieParser +0ms
  express:router:layer new / +0ms
  express:router use / stylus +90ms
  express:router:layer new / +0ms
  express:router use / serveStatic +0ms
  express:router:layer new / +0ms
  express:router use / router +0ms
  express:router:layer new / +1ms
  express:router use /users router +0ms
  express:router:layer new /users +0ms
  express:router use / <anonymous> +0ms
  express:router:layer new / +0ms
  express:router use / <anonymous> +0ms
  express:router:layer new / +0ms
  express:router use / <anonymous> +0ms
  express:router:layer new / +0ms

์ดํ›„ ์•ฑ์— ๋Œ€ํ•œ ์š”์ฒญ์ด ์ด๋ฃจ์–ด์ง€๋ฉด, Express ์ฝ”๋“œ์— ์ง€์ •๋œ ๋กœ๊ทธ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  express:router dispatching GET / +4h
  express:router query  : / +2ms
  express:router expressInit  : / +0ms
  express:router favicon  : / +0ms
  express:router logger  : / +1ms
  express:router jsonParser  : / +0ms
  express:router urlencodedParser  : / +1ms
  express:router cookieParser  : / +0ms
  express:router stylus  : / +0ms
  express:router serveStatic  : / +2ms
  express:router router  : / +2ms
  express:router dispatching GET / +1ms
  express:view lookup "index.pug" +338ms
  express:view stat "/projects/example/views/index.pug" +0ms
  express:view render "/projects/example/views/index.pug" +1ms

๋ผ์šฐํ„ฐ ๊ตฌํ˜„์˜ ๋กœ๊ทธ๋งŒ ํ™•์ธํ•˜๋ ค๋ฉด DEBUG์˜ ๊ฐ’์„ express:router๋กœ ์„ค์ •ํ•˜์‹ญ์‹œ์˜ค. ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ, ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ตฌํ˜„์˜ ๋กœ๊ทธ๋งŒ ํ™•์ธํ•˜๋ ค๋ฉด DEBUG์˜ ๊ฐ’์„ express:application์œผ๋กœ ์„ค์ •ํ•˜์‹ญ์‹œ์˜ค. ๋‚˜๋จธ์ง€๋„ ์ด์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

express๋ฅผ ํ†ตํ•ด ์ƒ์„ฑ๋œ ์• ํ”Œ์ผ€์ด์…˜

express ๋ช…๋ น์„ ํ†ตํ•ด ์ƒ์„ฑ๋œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋˜ํ•œ debug ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ•˜๋ฉฐ, ์ด๋Ÿฌํ•œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๋””๋ฒ„๊ทธ ๋„ค์ž„์ŠคํŽ˜์ด์Šค์˜ ๋ฒ”์œ„๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์ด๋ฆ„์œผ๋กœ ํ•œ์ •๋ฉ๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด $ express sample-app์„ ํ†ตํ•ด ์•ฑ์„ ์ƒ์„ฑํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ช…๋ น์„ ํ†ตํ•ด ๋””๋ฒ„๊ทธ ๋ช…๋ น๋ฌธ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ DEBUG=sample-app:* node ./bin/www

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์‰ผํ‘œ๋กœ ๊ตฌ๋ถ„๋œ ์ด๋ฆ„ ๋ชฉ๋ก์„ ์ง€์ •ํ•˜๋ฉด 2๊ฐœ ์ด์ƒ์˜ ๋””๋ฒ„๊ทธ ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ DEBUG=http,mail,express:* node index.js