@christophhu/ngx-log-mode
TypeScript icon, indicating that this package has built-in type declarations

19.2.0 • Public • Published

Ngx-Log-Mode

Frameworks and Languages

Static Badge
Static Badge
Static Badge

Demo

image

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-mode

Use

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()')
  }
}

Package Sidebar

Install

npm i @christophhu/ngx-log-mode

Weekly Downloads

4

Version

19.2.0

License

MIT

Unpacked Size

52.7 kB

Total Files

22

Last publish

Collaborators

  • christophhu