Kahla.App
Kahla.App copied to clipboard
Console.log debug on staging env
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...
}