250x250
Rainbow🌈Coder
My dev NoteπŸ“’
Rainbow🌈Coder
전체 방문자
였늘
μ–΄μ œ
  • λΆ„λ₯˜ 전체보기 (411)
    • 곡지사항 (0)
    • Debugger (10)
      • Visual Studio Debugger (1)
      • Chrome DevTools (3)
      • Visual Studio Code Debugger (4)
      • eclipse (1)
      • intelliJ (1)
    • OOP (2)
      • OOP (2)
    • TypeScript (54)
      • νƒ€μž…μŠ€ν¬λ¦½νŠΈ TypeScript (54)
    • Javascript (87)
      • Javascript (45)
      • Node.js (19)
      • React (5)
      • FE κ°œλ°œν™˜κ²½μ„€μ • (3)
      • React와 Node 같이 λ•Œλ €μž‘κΈ° (6)
      • next.js (2)
      • pixi.js (7)
    • λ§ˆν¬μ—… (23)
      • Html & Css (23)
    • C# (80)
      • C# (12)
      • 이것이 C#이닀 (68)
    • C++ (30)
      • c++ (27)
      • win api (3)
    • Unity (18)
      • Unity(기초) (8)
      • Unity(C#쀑급) (5)
      • μœ λ‹ˆν‹° 포톀(λ„€νŠΈμ›Œν¬) (4)
      • unity c# MyCode (1)
    • Java & Spring (29)
      • Java (11)
      • μŠ€ν”„λ§ (8)
      • Java Algorithm (9)
      • Javs Data Structures (1)
    • μžλ£Œκ΅¬μ‘°μ™€ μ•Œκ³ λ¦¬μ¦˜ (15)
      • 자료ꡬ쑰 (5)
      • μ•Œκ³ λ¦¬μ¦˜ (10)
    • ν˜•μƒκ΄€λ¦¬ (15)
      • Git (11)
      • μ†ŒμŠ€νŠΈλ¦¬ (3)
    • κ·Έλž˜ν”½μŠ€ (7)
      • WebGl (7)
    • AWS (3)
      • aws (3)
    • λ¦¬λˆ…μŠ€ (5)
      • λ¦¬λˆ…μŠ€ (5)
    • μ±… 리뷰 (13)
      • ν΄λ¦°μ½”λ“œ(책리뷰) (3)
      • μœ μ§€λ³΄μˆ˜κ°€λŠ₯ν•œμ½”λ”©μ˜κΈ°μˆ C#편(책리뷰) (1)
      • λ¦¬νŒ©ν† λ§(μžλ°”μŠ€ν¬λ¦½νŠΈνŒ) (9)
    • Server (2)
      • κ²Œμž„ μ„œλ²„(λ„€νŠΈμ›Œν¬, λ©€ν‹°μ“°λ ˆλ“œ,OS) (2)
    • 섀계, 아킀텍쳐 (4)
    • 파이썬 (5)
    • λ””μžμΈνŒ¨ν„΄ (2)
    • mocha (2)
    • Jest (1)
    • Spine (1)
    • 인곡지λŠ₯ (1)
      • ν˜Όμžκ³΅λΆ€ν•˜λŠ”λ¨Έμ‹ λŸ¬λ‹+λ”₯λŸ¬λ‹ (1)

λΈ”λ‘œκ·Έ 메뉴

  • ν™ˆ
  • νƒœκ·Έ
  • λ°©λͺ…둝

곡지사항

인기 κΈ€

νƒœκ·Έ

  • μ»΄ν¬μ§€μ…˜
  • γ…£γ„·
  • MySQL
  • μœ„μž„

졜근 λŒ“κΈ€

졜근 κΈ€

ν‹°μŠ€ν† λ¦¬

hELLO Β· Designed By μ •μƒμš°.
Rainbow🌈Coder

My dev NoteπŸ“’

Javascript/Node.js

[Node.js] console.log

2022. 5. 14. 09:53
728x90

1. console.clear();


console.log("logging.....");
console.clear();

 

μ½˜μ†”μ°½μ„ μ§€μ›Œμ€€λ‹€.



2. log level : μ„œλ²„μ—μ„œ λ°œμƒν•˜λŠ” μ—¬λŸ¬ μ΄λ²€νŠΈμ— λŒ€ν•΄μ„œ(μ—λŸ¬μ˜ μƒνƒœμ— λ”°λΌμ„œ)


console.log("log"); //개발
console.info("info"); //개발
console.warn("warn"); //경보
console.error("error"); //μ—λŸ¬, μ‚¬μš©μž μ—λŸ¬, μ‹œμŠ€ν…œ μ—λŸ¬


3. assert : 첫번째 μΈμžκ°€ false μΌλ•Œλ§Œ 좜λ ₯

console.assert(2 === 3, "not same!");  //Assertion failed: not same!
console.assert(2 === 2, "same!");       //무응닡


4. print object : 보기 μ’‹κ²Œ 좜λ ₯ 


const student = { name: "홍길동", age: 20, company: { name: "AC" } };
console.log(student);
console.table(student); //더 λ³΄κΈ° μ’‹κ²Œ ν…Œμ΄λΈ” ν˜•νƒœλ‘œ μΆœλ ₯ κ°€λŠ₯
console.dir(student, { showHidden: true, colors: false, depth: 2 }); //depth둜 μ€‘μ²©λœ μ˜€λΈŒμ νŠΈλ₯Ό μ–΄λА κΉŠμ΄ κΉŒμ§€ λ³΄μ—¬μ€„ κ±΄μ§€ μ‘°μ ˆ κ°€λŠ₯
console.dir(student, { showHidden: true, colors: false, depth: 0 });

{ name: '홍길동', age: 20, company: { name: 'AC' } }
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚ name β”‚  Values  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  name   β”‚      β”‚ '홍길동' β”‚
β”‚   age   β”‚      β”‚    20    β”‚
β”‚ company β”‚ 'AC' β”‚          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
{ name: '홍길동', age: 20, company: { name: 'AC' } }
{ name: '홍길동', age: 20, company: [Object] }


4. μ„±λŠ₯확인 : νŠΉμ • μ½”λ“œ μˆ˜ν–‰μ‹œκ°„ 확인

//measuring time
console.time("for loop");
for (let i = 0; i < 10; i++) {
  i++;
}
console.timeEnd("for loop"); //for loop: 0.129ms



5. counting(ν•¨μˆ˜ 호좜 횟수)


function a() {
  console.count("a function");
}

a();
a();

console.countReset("a function"); 
a();

a function: 1
a function: 2
a function: 1



6. trace : λ””λ²„κΉ…μ‹œ μ•„μ£Ό μœ λ¦¬ν•¨!!!


function f1() {
  f2();
}

function f2() {
  f3();
}

function f3() {
  console.log("f3");
  console.trace(); //이 ν•¨μˆ˜κ°€ μ–΄λ””μ„œλΆ€ν„° μ–΄λ–»κ²Œ λˆ„κ°€ ν˜ΈμΆœν–ˆλŠ”μ§€λ₯Ό λ³Ό μˆ˜ μžˆμŒ
}

f1();

Trace
    at f3 (C:\Users\User\gitprogect\NodeJs\1-global\app.js:53:11)
    at f2 (C:\Users\User\gitprogect\NodeJs\1-global\app.js:48:3)
    at f1 (C:\Users\User\gitprogect\NodeJs\1-global\app.js:44:3)
    at Object.<anonymous> (C:\Users\User\gitprogect\NodeJs\1-global\app.js:56:1)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

 

 

ν’€μ½”λ“œ

const fs = require("fs");

console.log("logging.....");
console.clear();

// log level : μ„œλ²„μ—μ„œ λ°œμƒν•˜λŠ” μ—¬λŸ¬ μ΄λ²€νŠΈμ— λŒ€ν•΄μ„œ(μ—λŸ¬μ˜ μƒνƒœμ— λ”°λΌμ„œ)
console.log("log"); //개발
console.info("info"); //개발
console.warn("warn"); //경보
console.error("error"); //μ—λŸ¬, μ‚¬μš©μž μ—λŸ¬, μ‹œμŠ€ν…œ μ—λŸ¬

//assert : 첫번째 μΈμžκ°€ false μΌλ•Œλ§Œ 좜λ ₯
console.assert(2 === 3, "not same!");
console.assert(2 === 2, "same!");

//print object : 보기 μ’‹κ²Œ 좜λ ₯ 
const student = { name: "홍길동", age: 20, company: { name: "AC" } };
console.log(student);
console.table(student); //더 보기 μ’‹κ²Œ ν…Œμ΄λΈ” ν˜•νƒœλ‘œ 좜λ ₯ κ°€λŠ₯
console.dir(student, { showHidden: true, colors: false, depth: 2 }); //depth둜 μ€‘μ²©λœ 였브젝트λ₯Ό μ–΄λŠ 깊이 κΉŒμ§€ 보여쀄 건지 쑰절 κ°€λŠ₯
console.dir(student, { showHidden: true, colors: false, depth: 0 });

//μ„±λŠ₯확인 : νŠΉμ • μ½”λ“œ μˆ˜ν–‰μ‹œκ°„ 확인
//measuring time
console.time("for loop");
for (let i = 0; i < 10; i++) {
  i++;
}
console.timeEnd("for loop");

//counting(ν•¨μˆ˜ 호좜 횟수)
function a() {
  console.count("a function");
}

a();
a();

console.countReset("a function");
a();

//trace : λ””λ²„κΉ…μ‹œ μ•„μ£Ό μœ λ¦¬ν•¨!!!
function f1() {
  f2();
}

function f2() {
  f3();
}

function f3() {
  console.log("f3");
  console.trace(); //이 ν•¨μˆ˜κ°€ μ–΄λ””μ„œλΆ€ν„° μ–΄λ–»κ²Œ λˆ„κ°€ ν˜ΈμΆœν–ˆλŠ”μ§€λ₯Ό λ³Ό 수 있음
}

f1();

 

둜그

log
info
warn
error
Assertion failed: not same!
{ name: '홍길동', age: 20, company: { name: 'AC' } }
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚ name β”‚  Values  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  name   β”‚      β”‚ '홍길동' β”‚
β”‚   age   β”‚      β”‚    20    β”‚
β”‚ company β”‚ 'AC' β”‚          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
{ name: '홍길동', age: 20, company: { name: 'AC' } }
{ name: '홍길동', age: 20, company: [Object] }
for loop: 0.129ms
a function: 1
a function: 2
a function: 1
f3
Trace
    at f3 (C:\Users\User\gitprogect\NodeJs\1-global\app.js:53:11)
    at f2 (C:\Users\User\gitprogect\NodeJs\1-global\app.js:48:3)
    at f1 (C:\Users\User\gitprogect\NodeJs\1-global\app.js:44:3)
    at Object.<anonymous> (C:\Users\User\gitprogect\NodeJs\1-global\app.js:56:1)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

 

728x90

'Javascript > Node.js' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

[Node.js] ν΄λΌμ΄μ–ΈνŠΈμ™€ μ„œλ²„μ˜ κ°œλ…, AWS ν΄λΌμš°λ“œ μ„œλ²„ ν™˜κ²½ ꡬ좕 μ‹€μŠ΅  (0) 2022.05.14
[Node.js] λ°±μ—”λ“œ κ°œλ… 기초 μ˜μƒλͺ¨μŒ  (0) 2022.05.14
[node.js] μ΄ˆκ°„λ‹¨ μ„œλ²„ λ§Œλ“€κΈ° (2) Node + Express μ›Ήμ„œλ²„ κΈ°λ³Έμ„ΈνŒ…  (0) 2022.05.14
[Node.js] global  (0) 2022.05.14
node.js μ΄ˆκ°„λ‹¨ μ„œλ²„ λ§Œλ“€κΈ° (1) express 라이브러리 μ„€μΉ˜  (0) 2022.03.18
    'Javascript/Node.js' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€
    • [Node.js] λ°±μ—”λ“œ κ°œλ… 기초 μ˜μƒλͺ¨μŒ
    • [node.js] μ΄ˆκ°„λ‹¨ μ„œλ²„ λ§Œλ“€κΈ° (2) Node + Express μ›Ήμ„œλ²„ κΈ°λ³Έμ„ΈνŒ…
    • [Node.js] global
    • node.js μ΄ˆκ°„λ‹¨ μ„œλ²„ λ§Œλ“€κΈ° (1) express 라이브러리 μ„€μΉ˜
    Rainbow🌈Coder
    Rainbow🌈Coder
    λͺ°λΌλ„ 결ꡭ은 μ•„λŠ” 개발자, 그런 μ‚¬λžŒμ΄ 되기 μœ„ν•œ 맀일의 ν•œκ±ΈμŒ

    ν‹°μŠ€ν† λ¦¬νˆ΄λ°”