Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
export class LoggerFormComponent implements OnInit {
@Output() logToConsole: EventEmitter = new EventEmitter();
loggerForm = this.fb.group({
logMessage: ['', Validators.required],
logType: ['', Validators.required]
});
/* Used in the mat-select on the form */
logTypes: LoggerSelectionOption[] = [
{value: NgxLoggerLevel.TRACE, viewValue: 'Trace'},
{value: NgxLoggerLevel.DEBUG, viewValue: 'Debug'},
{value: NgxLoggerLevel.INFO, viewValue: 'Info'},
{value: NgxLoggerLevel.LOG, viewValue: 'Log'},
{value: NgxLoggerLevel.WARN, viewValue: 'Warn'},
{value: NgxLoggerLevel.ERROR, viewValue: 'Error'}
];
constructor(private fb: FormBuilder) {
}
ngOnInit() {
}
/**
* Take the message and type of logging to be performed and emits it to the parent component.
*/
handleFormSubmission() {
this.logToConsole.emit(this.loggerForm.value);
}
}
import { config } from '../docspa.config';
import { environment } from '../environments/environment';
import { BuilderModule } from './builder/builder.module';
@NgModule({
declarations: [
AppComponent
],
imports: [
CommonModule,
BrowserModule,
BuilderModule,
LoadingBarModule.forRoot(),
LoadingBarHttpClientModule,
LoggerModule.forRoot({ level: NgxLoggerLevel.WARN }),
DocspaCoreModule.forRoot(config, environment),
MarkdownModule.forRoot(preset),
NgxDnDModule.forRoot(),
MarkdownElementsModule.forRoot(),
RuntimeContentModule.forRoot({
imports: [
CommonModule,
NgxDnDModule,
BuilderModule
]
}),
DocsifyPluginsModule.forRoot({
plugins: []
})
],
providers: [
get loggerColor(): string {
switch (this.currentLogLevel) {
case NgxLoggerLevel.TRACE:
case NgxLoggerLevel.DEBUG:
return 'primary';
case NgxLoggerLevel.INFO:
case NgxLoggerLevel.LOG:
return 'accent';
case NgxLoggerLevel.WARN:
case NgxLoggerLevel.ERROR:
case NgxLoggerLevel.FATAL:
return 'warn';
default:
return '';
}
}
import { DemoModule } from 'src/docs/demos/demo.module';
import { NgxGraphModule } from '@swimlane/ngx-graph';
import { NgxChartsModule } from '@swimlane/ngx-charts';
import { preset } from '@swimlane/docspa-remark-preset';
import { LoggerModule, NgxLoggerLevel } from 'ngx-logger';
import { environment } from 'src/environments/environment';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
DocspaCoreModule.forRoot(config, environment),
DemoModule,
MarkdownModule.forRoot(preset),
MarkdownElementsModule.forRoot(),
LoggerModule.forRoot({ level: NgxLoggerLevel.WARN }),
RuntimeContentModule.forRoot({
imports: [
NgxGraphModule,
NgxChartsModule,
DemoModule
]
}),
DocsifyPluginsModule,
DocspaStackblitzModule
],
providers: [Location, { provide: LocationStrategy, useClass: HashLocationStrategy }],
bootstrap: [AppComponent]
})
export class AppModule {}
handleLog(log: LogEvent) {
switch (log.logType) {
case NgxLoggerLevel.TRACE:
this.logger.trace(log.logMessage);
break;
case NgxLoggerLevel.DEBUG:
this.logger.debug(log.logMessage);
break;
case NgxLoggerLevel.INFO:
this.logger.info(log.logMessage);
break;
case NgxLoggerLevel.LOG:
this.logger.log(log.logMessage);
break;
case NgxLoggerLevel.WARN:
this.logger.warn(log.logMessage);
break;
case NgxLoggerLevel.ERROR:
this.logger.error(log.logMessage);
break;
case NgxLoggerLevel.FATAL:
this.logger.fatal(log.logMessage);
break;
}
}
}