@christophhu/ngx-log-mode
v19.2.0
Published
Angular log mode toggle library for toggling the log of console.log-messages, logs in the localstorage or in a WebAPI.
Downloads
5
Maintainers
Readme
Ngx-Log-Mode
Frameworks and Languages
Demo
Description
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.
Installation
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-modeUse
With default toggle
<log-mode></log-mode>With custom toggle
<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()')
}
}