This Repository is a demo application for the ngx-log-mode library. The ngx-log-mode library is a simple logger for Angular applications. It provides a simple API to log messages to the console, localstorage or to a customizable RestAPI. The library is easy to use and can be installed via npm.
To run this project, you need to have Node.js installed on your machine. Clone the repository and run the following commands:
npm i @christophhu/ngx-log-mode
<log-mode></log-mode>
<log-mode>
<input type="checkbox" name="log" id="log" (change)="toggleLog()" [checked]="isLogActivated()" class="cursor-pointer">
</log-mode>
import { LogDecorator, LogModeComponent, LogService } from '@christophhu/ngx-log-mode'
@Component({
...
imports: [
LogModeComponent
],
providers: [
LogService
]
})
export class TestComponent {
private _logService: LogService
constructor(@Inject(LogService) _logService: LogService) {
this._logService = _logService
}
// Log-Decorator to log the function call and the result with timestamp
@LogDecorator({ logType: 'info', input: false, output: false, timestamp: true })
toggleLog() {
this._logService.toggleLogActivate()
}
isLogActivated(): boolean {
return this._logService.isLogActivated()
}
logThis(param: string): void {
LogService.log('TemplateComponent', 'logThis()', ' param: ' + param)
}
logThis() {
LogService.debug('TemplateComponent', 'logDebug()')
LogService.info('TemplateComponent', 'logInfo()')
LogService.warn('TemplateComponent', 'logWarn()')
LogService.error('TemplateComponent', 'logError()')
LogService.fatal('TemplateComponent', 'logFatal()')
}
}