Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IKC-378 Frontend logger #420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import {ServersService} from '@app/common-servers';
import {AbstractTableComponent, TableColumn} from '@app/common-components';
import {MatSort} from '@angular/material/sort';
import {AuthService, SystemFunctionName} from '@app/common-auth';
import {LoggerFactory} from '@consdata/logger-api';

const CONSUMER_GROUP_FAVOURITE_KEY = 'kouncil-consumer-groups-favourites';
const log = LoggerFactory.getLogger('ConsumerGroupsComponent');

@Component({
selector: 'app-kafka-consumer-groups',
Expand Down Expand Up @@ -211,7 +213,7 @@ export class ConsumerGroupsComponent extends AbstractTableComponent implements O
duration: 3000
});
}, error => {
console.error(error);
log.error(error);
this.snackbar.openFromComponent(SnackBarComponent, {
data: new SnackBarData(`Consumer group ${value} couldn't be deleted`, 'snackbar-error', ''),
panelClass: ['snackbar'],
Expand Down
5 changes: 4 additions & 1 deletion kouncil-frontend/apps/kouncil/src/app/rx-stomp.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import {environment} from '../environments/environment';
import {RxStompConfig} from '@stomp/rx-stomp';
import {LoggerFactory} from '@consdata/logger-api';

const log = LoggerFactory.getLogger('RxStompConfig');

export const RX_STOMP_CONFIG: RxStompConfig = {
brokerURL: `${environment.websocketUrl}`,
heartbeatIncoming: 0,
heartbeatOutgoing: 20000,
reconnectDelay: 2000,
debug: (msg: string): void => {
console.log('RxStompConfig.debug: msg={}', msg);
log.debug('RxStompConfig.debug: msg={}', msg);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {TopicsService} from '@app/feat-topics';
import {Topics} from '@app/common-model';
import {Router} from '@angular/router';
import {AuthService, SystemFunctionName} from '@app/common-auth';
import {LoggerFactory} from '@consdata/logger-api';

const log = LoggerFactory.getLogger('SchemasComponent');

@Component({
selector: 'app-schemas',
Expand Down Expand Up @@ -214,7 +217,7 @@ export class SchemasComponent extends AbstractTableComponent implements OnInit {
duration: 3000
});
}, error => {
console.error(error);
log.error(error);
this.snackbar.openFromComponent(SnackBarComponent, {
data: new SnackBarData(`Schema version ${version} for subject ${subject} couldn't be deleted`, 'snackbar-error', ''),
panelClass: ['snackbar'],
Expand Down
8 changes: 7 additions & 1 deletion kouncil-frontend/apps/kouncil/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ import {environment} from './environments/environment';
import {AppModule} from './app/app.module';
import {APP_BASE_HREF} from '@angular/common';
import {Backend} from '@app/common-model';
import {LoggerFactory, LogLevel} from '@consdata/logger-api';
import {ConsoleLogAppender} from '@consdata/logger-console';

LoggerFactory.addAppender(ConsoleLogAppender.instance);
LoggerFactory.setRootLogLevel(LogLevel.INFO);
const log = LoggerFactory.getLogger('Main');

function bootstrap(extraProviders?: StaticProvider[] | undefined) {
platformBrowserDynamic(extraProviders)
.bootstrapModule(AppModule)
.catch((err) => console.error(err));
.catch((err) => log.error(err));
}

if (environment.production) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import {ProgressBarService} from './progress-bar.service';
import {Router} from '@angular/router';
import {SnackBarComponent} from './snack-bar.component';
import {SnackBarData} from './snack-bar-data';
import {LoggerFactory} from '@consdata/logger-api';

const log = LoggerFactory.getLogger('HttpClientInterceptor');

@Injectable({
providedIn: 'root'
Expand All @@ -32,7 +35,7 @@ export class HttpClientInterceptor implements HttpInterceptor {
this.router.navigate(['/login']);
return null;
} else {
console.log(JSON.stringify(error));
log.error(JSON.stringify(error));
const consoleErrorMessage = `Error Code: ${error.status}<br>Message: ${error.message}\nError message: ${error.error}`;
this.snackBar.openFromComponent(SnackBarComponent, {
data: new SnackBarData(error.error, 'snackbar-error', 'Close'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import {
import {ServersService} from '@app/common-servers';
import {EditorComponent, MonacoEditorService} from '@app/common-components';
import {SnackBarComponent, SnackBarData} from '@app/common-utils';
import {LoggerFactory} from '@consdata/logger-api';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare let monaco: any;
const log = LoggerFactory.getLogger('SendComponent');

@Component({
selector: 'app-send',
Expand Down Expand Up @@ -224,7 +226,7 @@ export class SendComponent implements OnDestroy {
duration: 3000
});
}, error => {
console.error(error);
log.error(error);
this.snackbar.openFromComponent(SnackBarComponent, {
data: new SnackBarData(`Error occurred while sending events to ${messageData.topicName}`, 'snackbar-error', ''),
panelClass: ['snackbar'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {ProtobufUtilsService} from '../protobuf/protobuf-utils.service';
import {JSONSchemaFaker} from 'json-schema-faker';
import {SchemaRegistryService} from './schema-registry.service';
import {AvroUtilsService} from '../avro/avro-utils.service';
import {LoggerFactory} from '@consdata/logger-api';

const log = LoggerFactory.getLogger('SchemaFacadeService');

@Injectable({
providedIn: 'root'
Expand All @@ -32,18 +35,18 @@ export class SchemaFacadeService {
switch (messageFormat) {
case MessageFormat.PROTOBUF:
example = this.protobufUtilsService.fillProtobufSchemaWithData(plainTextSchema);
console.log(`Found schema, isKey=[${isKey}]`);
log.info(`Found schema, isKey=[${isKey}]`);
break;
case MessageFormat.JSON:
example = JSONSchemaFaker.generate(JSON.parse(plainTextSchema));
console.log(`Found schema, isKey=[${isKey}]`);
log.info(`Found schema, isKey=[${isKey}]`);
break;
case MessageFormat.AVRO:
example = this.avroUtilsService.fillAvroSchemaWithData(plainTextSchema);
console.log(`Found schema, isKey=[${isKey}]`);
log.info(`Found schema, isKey=[${isKey}]`);
break;
default:
console.log(`No schema, isKey=[${isKey}]`);
log.info(`No schema, isKey=[${isKey}]`);
break;
}
return example;
Expand Down
2 changes: 2 additions & 0 deletions kouncil-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"@angular/platform-browser": "15.0.1",
"@angular/platform-browser-dynamic": "15.0.1",
"@angular/router": "15.0.1",
"@consdata/logger-api": "0.15.0",
"@consdata/logger-console": "0.15.0",
"@nrwl/angular": "15.2.1",
"@stomp/rx-stomp": "1.1.4",
"@swimlane/ngx-datatable": "20.1.0",
Expand Down
10 changes: 10 additions & 0 deletions kouncil-frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,16 @@
resolved "https://registry.yarnpkg.com/@consdata/eslint-config/-/eslint-config-0.21.0.tgz#67610384af577860477f8403e4a939c745e1958f"
integrity sha512-Kc0oUL9HjKloDyZSbXuHJmtvKGtg+Y1StrXlplZvWIeBgbH2u6ir8MsXR1Ymn/CL+BX9wM58Ny99j2p+GQP4Yg==

"@consdata/[email protected]":
version "0.15.0"
resolved "https://registry.yarnpkg.com/@consdata/logger-api/-/logger-api-0.15.0.tgz#f3c28f484ebe7b199c87a988c1ebfd6fa42282f1"
integrity sha512-CzurbRYuxNViKUawrKDVHAa+EfK/Cyd8W/nWhL9BTT75A0gu+gL+gB8pNc9eVbmUAHxc0QkUrZGbpXYyeSrbKg==

"@consdata/[email protected]":
version "0.15.0"
resolved "https://registry.yarnpkg.com/@consdata/logger-console/-/logger-console-0.15.0.tgz#2b7ea2933e7b31ac28c959f3d3177f742fe1312e"
integrity sha512-UDytdadGhDei8flysjr9sLf/YZDY3MmNDcFPwLpoBNckCT/13nBmSP+RLixNnG1hFOZNQLdAYpfQSbX4YvkjSQ==

"@cspotcode/source-map-support@^0.8.0":
version "0.8.1"
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1"
Expand Down
Loading