Skip to content

Commit

Permalink
Remove logger service and action history (#4538)
Browse files Browse the repository at this point in the history
* Remove logger service

* Missed a few and removed action history as it was not being used

* Remove action history

* A few more

* Fix for removed method
  • Loading branch information
nwmac authored Aug 25, 2020
1 parent a0b338a commit 0ea6632
Show file tree
Hide file tree
Showing 34 changed files with 36 additions and 323 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { EffectsModule } from '@ngrx/effects';

import { generateASEntities } from '../../cf-autoscaler/src/store/autoscaler-entity-generator';
import { getGitHubAPIURL, GITHUB_API_URL } from '../../core/src/core/github.helpers';
import { LoggerService } from '../../core/src/core/logger.service';
import { CATALOGUE_ENTITIES, EntityCatalogFeatureModule } from '../../store/src/entity-catalog.module';
import { entityCatalog, TestEntityCatalog } from '../../store/src/entity-catalog/entity-catalog';
import { generateStratosEntities } from '../../store/src/stratos-entity-generator';
Expand Down Expand Up @@ -42,7 +41,6 @@ import { CloudFoundryStoreModule } from './store/cloud-foundry.store.module';
providers: [
{ provide: GITHUB_API_URL, useFactory: getGitHubAPIURL },
GitSCMService,
LoggerService,
LongRunningCfOperationsService,
CfUserService,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import { Store } from '@ngrx/store';
import * as moment from 'moment';
import { NEVER, Observable, Subject } from 'rxjs';
import makeWebSocketObservable, { GetWebSocketResponses } from 'rxjs-websockets';
import { catchError, share, switchMap, map, first, startWith, debounceTime } from 'rxjs/operators';
import { catchError, debounceTime, first, map, share, startWith, switchMap } from 'rxjs/operators';

import { CFAppState } from '../../../../../../../../cloud-foundry/src/cf-app-state';
import { LoggerService } from '../../../../../../../../core/src/core/logger.service';
import { AnsiColorizer } from '../../../../../../../../core/src/shared/components/log-viewer/ansi-colorizer';
import { ApplicationService } from '../../../../application.service';

Expand Down Expand Up @@ -39,7 +38,6 @@ export class LogStreamTabComponent implements OnInit {
constructor(
private applicationService: ApplicationService,
private store: Store<CFAppState>,
private logService: LoggerService
) {
this.filter = this.jsonFilter.bind(this);
}
Expand All @@ -55,7 +53,7 @@ export class LogStreamTabComponent implements OnInit {
}/apps/${this.applicationService.appGuid}/stream`;

const socket$ = makeWebSocketObservable(streamUrl).pipe(catchError(e => {
this.logService.error(
console.error(
'Error while connecting to socket: ' + JSON.stringify(e)
);
return [];
Expand Down Expand Up @@ -110,7 +108,7 @@ export class LogStreamTabComponent implements OnInit {
const messageString = this.colorizer.colorize(atob(messageObj.message), msgColour, bold) + '\n';
return timeStamp + ': ' + messageSource + ' ' + messageString;
} catch (error) {
this.logService.error('Failed to filter jsonMessage from WebSocket: ' + JSON.stringify(error));
console.error('Failed to filter jsonMessage from WebSocket: ' + JSON.stringify(error));
return jsonString;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { CFAppState } from '../../../../../../../../cloud-foundry/src/cf-app-state';
import { LoggerService } from '../../../../../../../../core/src/core/logger.service';
import {
ListDataSource,
} from '../../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source';
import { ListConfig } from '../../../../../../../../core/src/shared/components/list/list.component.types';
import { stratosEndpointGuidKey } from '../../../../../../../../store/src/entity-request-pipeline/pipeline.types';
import {
ListAppEnvVar,
} from '../../../../../../shared/components/list/list-types/app-variables/cf-app-variables-data-source';
import {
CfAppVariablesListConfigService,
} from '../../../../../../shared/components/list/list-types/app-variables/cf-app-variables-list-config.service';
import { ListConfig } from '../../../../../../../../core/src/shared/components/list/list.component.types';
import { ApplicationService } from '../../../../application.service';
import { stratosEndpointGuidKey } from '../../../../../../../../store/src/entity-request-pipeline/pipeline.types';

export interface VariableTabAllEnvVarType {
name: string;
Expand All @@ -39,7 +38,6 @@ export class VariablesTabComponent implements OnInit {
private store: Store<CFAppState>,
private appService: ApplicationService,
private listConfig: ListConfig<ListAppEnvVar>,
private loggerService: LoggerService
) {
this.envVarsDataSource = listConfig.getDataSource();
}
Expand Down Expand Up @@ -96,7 +94,7 @@ export class VariablesTabComponent implements OnInit {
try {
return JSON.parse(value);
} catch (err) {
this.loggerService.debug('Failed to parse STRATOS_PROJECT env var', err);
console.warn('Failed to parse STRATOS_PROJECT env var', err);
}
return '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import * as moment from 'moment';

import { LoggerService } from '../../../../../../core/src/core/logger.service';
import { UtilsService } from '../../../../../../core/src/core/utils.service';
import { AnsiColorizer } from '../../../../../../core/src/shared/components/log-viewer/ansi-colorizer';
import { FireHoseItem, HTTP_METHODS } from './cloud-foundry-firehose.types';
Expand All @@ -29,7 +28,7 @@ export class CloudFoundryFirehoseFormatter {

private colorizer = new AnsiColorizer();

constructor(private logService: LoggerService, private utils: UtilsService) { }
constructor(private utils: UtilsService) { }

// Enable or disable all filters
public showAll(all: boolean) {
Expand Down Expand Up @@ -66,7 +65,7 @@ export class CloudFoundryFirehoseFormatter {
filtered = this.handleOtherEvent(cfEvent);
}
} catch (error) {
this.logService.error('Failed to filter jsonMessage from WebSocket: ' + jsonString);
console.error('Failed to filter jsonMessage from WebSocket: ' + jsonString);
filtered = jsonString;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import websocketConnect from 'rxjs-websockets';
import { catchError, filter, share, map, switchMap } from 'rxjs/operators';
import { catchError, filter, map, share, switchMap } from 'rxjs/operators';

import { LoggerService } from '../../../../../../core/src/core/logger.service';
import { UtilsService } from '../../../../../../core/src/core/utils.service';
import { environment } from '../../../../../../core/src/environments/environment.prod';
import { CloudFoundryEndpointService } from '../../services/cloud-foundry-endpoint.service';
Expand All @@ -25,7 +24,6 @@ export class CloudFoundryFirehoseComponent implements OnInit {

constructor(
private cfEndpointService: CloudFoundryEndpointService,
private logService: LoggerService,
private utilsService: UtilsService
) { }

Expand All @@ -36,7 +34,7 @@ export class CloudFoundryFirehoseComponent implements OnInit {
}/firehose`;

this.setupFirehoseStream(streamUrl);
this.formatter = new CloudFoundryFirehoseFormatter(this.logService, this.utilsService);
this.formatter = new CloudFoundryFirehoseFormatter(this.utilsService);
this.filter = this.formatter.jsonFilter.bind(this.formatter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Store } from '@ngrx/store';
import { combineLatest as obsCombineLatest, Observable, of as observableOf } from 'rxjs';
import { combineLatest, filter, first, map, startWith } from 'rxjs/operators';

import { LoggerService } from '../../../../../../core/src/core/logger.service';
import { CurrentUserPermissionsService } from '../../../../../../core/src/core/permissions/current-user-permissions.service';
import { StepOnNextFunction } from '../../../../../../core/src/shared/components/stepper/step/step.component';
import { AppState } from '../../../../../../store/src/app-state';
Expand Down Expand Up @@ -49,7 +48,6 @@ export class RemoveUserComponent implements OnDestroy {
private activeRouteCfOrgSpace: ActiveRouteCfOrgSpace,
private cfUserService: CfUserService,
private cfRolesService: CfRolesService,
private logService: LoggerService,
private route: ActivatedRoute,
private userPerms: CurrentUserPermissionsService
) {
Expand All @@ -67,7 +65,7 @@ export class RemoveUserComponent implements OnDestroy {
first()
);
} else {
this.logService.error('User param not defined');
console.error('User param not defined');
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Store } from '@ngrx/store';
import { of as observableOf } from 'rxjs';
import { catchError, filter, map, mergeMap, switchMap, withLatestFrom } from 'rxjs/operators';

import { LoggerService } from '../../../../core/src/core/logger.service';
import { entityCatalog } from '../../../../store/src/entity-catalog/entity-catalog';
import { NormalizedResponse } from '../../../../store/src/types/api.types';
import { PaginatedAction } from '../../../../store/src/types/pagination.types';
Expand Down Expand Up @@ -36,20 +35,20 @@ import { CF_ENDPOINT_TYPE } from '../../cf-types';
import { selectDeployAppState } from '../selectors/deploy-application.selector';
import { GitCommit } from '../types/git.types';

function parseHttpPipeError(res: any, logger: LoggerService): { message?: string } {
function parseHttpPipeError(res: any): { message?: string } {
if (!res.status) {
return res;
}
try {
return res.json ? res.json() : res;
} catch (e) {
logger.warn('Failed to parse response body', e);
console.warn('Failed to parse response body', e);
}
return {};
}

export function createFailedGithubRequestMessage(error: any, logger: LoggerService) {
const response = parseHttpPipeError(error, logger);
export function createFailedGithubRequestMessage(error: any) {
const response = parseHttpPipeError(error);
const message = response.message || '';
return error.status === 403 && message.startsWith('API rate limit exceeded for') ?
'Git ' + message.substring(0, message.indexOf('(')) :
Expand All @@ -61,7 +60,6 @@ export class DeployAppEffects {
constructor(
private actions$: Actions,
private store: Store<CFAppState>,
private logger: LoggerService,
private httpClient: HttpClient
) { }

Expand All @@ -77,7 +75,7 @@ export class DeployAppEffects {
map(res => new ProjectExists(action.projectName, res)),
catchError(err => observableOf(err.status === 404 ?
new ProjectDoesntExist(action.projectName) :
new ProjectFetchFail(action.projectName, createFailedGithubRequestMessage(err, this.logger))
new ProjectFetchFail(action.projectName, createFailedGithubRequestMessage(err))
))
);
})
Expand Down Expand Up @@ -120,7 +118,7 @@ export class DeployAppEffects {
];
}),
catchError(err => [
new WrapperRequestActionFailed(createFailedGithubRequestMessage(err, this.logger), apiAction, actionType)
new WrapperRequestActionFailed(createFailedGithubRequestMessage(err), apiAction, actionType)
]));
}));

Expand Down Expand Up @@ -152,7 +150,7 @@ export class DeployAppEffects {
];
}),
catchError(err => [
new WrapperRequestActionFailed(createFailedGithubRequestMessage(err, this.logger), apiAction, actionType)
new WrapperRequestActionFailed(createFailedGithubRequestMessage(err), apiAction, actionType)
]));
}));

Expand Down Expand Up @@ -180,7 +178,7 @@ export class DeployAppEffects {
];
}),
catchError(err => [
new WrapperRequestActionFailed(createFailedGithubRequestMessage(err, this.logger), apiAction, actionType)
new WrapperRequestActionFailed(createFailedGithubRequestMessage(err), apiAction, actionType)
]));
}));

Expand Down Expand Up @@ -211,7 +209,7 @@ export class DeployAppEffects {
];
}),
catchError(err => [
new WrapperRequestActionFailed(createFailedGithubRequestMessage(err, this.logger), apiAction, actionType)
new WrapperRequestActionFailed(createFailedGithubRequestMessage(err), apiAction, actionType)
]));
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Actions, Effect, ofType } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { catchError, mergeMap } from 'rxjs/operators';

import { LoggerService } from '../../../../core/src/core/logger.service';
import { NormalizedResponse } from '../../../../store/src/types/api.types';
import {
StartRequestAction,
Expand All @@ -29,7 +28,6 @@ export class GithubEffects {
private actions$: Actions,
private store: Store<CFAppState>,
private scmService: GitSCMService,
private logger: LoggerService,
private httpClient: HttpClient
) { }
@Effect()
Expand Down Expand Up @@ -57,7 +55,7 @@ export class GithubEffects {
];
}),
catchError(err => [
new WrapperRequestActionFailed(createFailedGithubRequestMessage(err, this.logger), apiAction, actionType)
new WrapperRequestActionFailed(createFailedGithubRequestMessage(err), apiAction, actionType)
]
));
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Actions, Effect, ofType } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { catchError, first, map, mergeMap, withLatestFrom } from 'rxjs/operators';

import { LoggerService } from '../../../../core/src/core/logger.service';
import { SET_PAGE_BUSY } from '../../../../store/src/actions/pagination.actions';
import { rootUpdatingKey } from '../../../../store/src/reducers/api-request-reducer/types';
import { getAPIRequestDataState } from '../../../../store/src/selectors/api.selectors';
Expand All @@ -26,7 +25,6 @@ export class CfValidateEffects {
constructor(
private actions$: Actions,
private store: Store<CFAppState>,
private logger: LoggerService,
) { }

/**
Expand Down Expand Up @@ -89,7 +87,7 @@ export class CfValidateEffects {
})
)
.pipe(catchError(error => {
this.logger.warn(`Entity validation process failed`, error);
console.warn(`Entity validation process failed`, error);
this.update(apiAction, false, error.message);
return [];
}));
Expand Down
2 changes: 0 additions & 2 deletions src/frontend/packages/core/src/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { EntityFavoriteStarComponent } from './entity-favorite-star/entity-favor
import { EventWatcherService } from './event-watcher/event-watcher.service';
import { InfinityPipe } from './infinity.pipe';
import { LogOutDialogComponent } from './log-out-dialog/log-out-dialog.component';
import { LoggerService } from './logger.service';
import { MDAppModule } from './md.module';
import { NotSetupGuardService } from './not-setup-guard.service';
import { PageHeaderService } from './page-header-service/page-header.service';
Expand Down Expand Up @@ -75,7 +74,6 @@ import { WindowRef } from './window-ref/window-ref.service';
EventWatcherService,
WindowRef,
UtilsService,
LoggerService,
EndpointsService,
UserService,
EntityServiceFactory,
Expand Down
24 changes: 0 additions & 24 deletions src/frontend/packages/core/src/core/logger.service.spec.ts

This file was deleted.

Loading

0 comments on commit 0ea6632

Please sign in to comment.