// ---- EXAMPLE #1 ----
console.log('%cHello..', 'font-weight: bold; color: red')
// ---- EXAMPLE #2 ----
console.log('%cHello..%cNew Color here..', 'font-weight: bold; color: red', 'font-weight: bold; color: green')
console.time("Timer")
for (let i = 0; i < 100000000; i++){
// ..
}
console.timeEnd("Timer")
console.error("You made a mistake");
console.warn("You made a mistake");
let x = 3
console.assert(x === 2, 'x is not 2..')
// ---- EXAMPLE #1 - Array ----
console.table(["apples", "oranges", "bananas"]);
// ---- EXAMPLE #2 - Object ----
function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
var me = new Person("John", "Smith");
console.table(me);
function foo() {
function bar() {
console.trace();
}
bar();
}
foo();
import { LogClass, Log } from 'class-logger'
@LogClass()
class Test {
@Log()
method1() {
return 123
}
@Log()
async methodAsync1() {
// do something asynchronous
return Symbol()
}
@Log()
methodError() {
throw new Error()
}
@Log()
property1 = () => null
@Log()
static methodStatic1(arg1) {
return {
prop1: 'test',
}
}
}
// Logs to the console before the method call:
// 'Test.methodStatic1. Args: [42].'
Test.methodStatic1(42)
// Logs to the console after the method call:
// 'Test.methodStatic1 -> done. Args: [42]. Res: {"prop1":"test"}.'
// Logs to the console before the class' construction:
// 'Test.construct. Args: [].'
const test = new Test()
// Logs to the console before the method call:
// 'Test.method1. Args: [].'
test.method1()
// Logs to the console after the method call:
// 'Test.method1 -> done. Args: []. Res: 123.'
// Logs to the console before the method call:
// 'Test.methodAsync1. Args: [].'
test.methodAsync1()
// Logs to the console after the method call (after the promise is resolved):
// 'Test.methodAsync1 -> done. Args: []. Res: Symbol().'
// Logs to the console before the method call:
// 'Test.methodError. Args: [].'
test.methodError()
// Logs to the console after the method call:
// 'Test.methodError -> error. Args: []. Res: Error {"name":"Error","message":"","stack":"some stack trace"}.'
// Logs to the console before the method call:
// 'Test.property1. Args: [].'
test.property1()
// Logs to the console after the method call:
// 'Test.property1 -> done. Args: []. Res: null.'