Kahla.App icon indicating copy to clipboard operation
Kahla.App copied to clipboard

Console.log debug on staging env

Open Anduin2017 opened this issue 4 years ago • 0 comments

What do you suggest us to do?

Since @hv0905 mentioned that console.log is really a nice way for developers to diagnostic issues. I suggest that we can write it more to allow debugging in our staging env.

While when we are doing this approach, I don't suggest to write the following code everywhere:

if (isStaging) {
    console.log('some debug details');
}

But instead, we gonna create a log service.

interface LoggerService {
    log(Logging: any): void; 
}

And implement it with different ways. Like:

class ConsoleLogger : LoggerService {
}

class DummyLogger : LoggerService {
}

And use ConsoleLogger in staging env and DummyLogger in prod env.

if (isStaging) {
    services.Add<ConsoleLogger, LoggerService>();
} else {
    services.Add<DummyLogger, LoggerService>(); // I don't know if Angular dependency injection framework supports that...
}

Anduin2017 avatar Oct 03 '20 12:10 Anduin2017