Skip to content

Commit

Permalink
consolidating log calls inside code
Browse files Browse the repository at this point in the history
  • Loading branch information
urz9999 committed Oct 19, 2020
1 parent ab955a8 commit 807cdec
Show file tree
Hide file tree
Showing 27 changed files with 738 additions and 286 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -40,6 +40,14 @@ Get [here](https://github.com/Noovolari/leapp/releases/latest) the latest releas

To install the compiled version, choose the one for your **OS** and simply **double-click** on the executable.

# Logs

By default, Leapp writes logs to the following locations:

- on Linux: ~/.config/{app name}/logs/{process type}.log
- on macOS: ~/Library/Logs/{app name}/{process type}.log
- on Windows: %USERPROFILE%\AppData\Roaming\{app name}\logs\{process type}.log

# Tutorials

[Here](.github/tutorials/TUTORIALS.md) is a list of curated **tutorials** to **help you setup** your environment for Leapp.
Expand Down
544 changes: 504 additions & 40 deletions package-lock.json

Large diffs are not rendered by default.

113 changes: 59 additions & 54 deletions package.json
Expand Up @@ -22,12 +22,16 @@
{
"name": "Andrea Cavagna",
"email": "andrea.cavagna@noovolari.com"
},
{
"name": "Nicolò Marchesi",
"email": "nicolo@noovolari.com"
}
],
"repository": "https://github.com/Noovolari/leapp",
"private": true,
"category": "public.app-category.developer-tools",
"homepage": "https://www.noovolari.com",
"homepage": "https://leapp.cloud",
"main": "electron/dist/electron/main.js",
"scripts": {
"postinstall": "electron-builder install-app-deps",
Expand Down Expand Up @@ -113,7 +117,7 @@
"Icon": "/usr/share/icons/hicolor/0x0/apps/leapp.png"
},
"target": [
"deb"
"deb", "AppImage"
]
},
"win": {
Expand Down Expand Up @@ -148,72 +152,73 @@
"@angular/platform-browser": "~8.1.0",
"@angular/platform-browser-dynamic": "~8.1.0",
"@angular/router": "~8.1.0",
"@ng-select/ng-select": "^3.7.3",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"@sebgroup/ng-magic-iframe": "^1.0.2",
"@types/jest": "^25.2.3",
"aws-sdk": "^2.713.0",
"bootstrap": "^4.5.0",
"@ng-select/ng-select": "~3.7.3",
"@ngx-translate/core": "~11.0.1",
"@ngx-translate/http-loader": "~4.0.0",
"@sebgroup/ng-magic-iframe": "~1.0.2",
"@types/jest": "~25.2.3",
"aws-sdk": "~2.713.0",
"bootstrap": "~4.5.0",
"chdir": "0.0.0",
"copy-dir": "^1.3.0",
"crypto-js": "^3.3.0",
"electron-default-menu": "^1.0.2",
"electron-log": "^3.0.6",
"electron-notarize": "^0.1.1",
"electron-osx-sign": "^0.4.17",
"electron-reload": "^1.5.0",
"electron-updater": "^4.3.1",
"extract-zip": "^1.7.0",
"fix-path": "^3.0.0",
"fs-extra": "^8.1.0",
"global-tunnel": "^1.2.0",
"ini": "^1.3.5",
"jwt-decode": "^2.2.0",
"keytar": "^6.0.1",
"md5-file": "^4.0.0",
"menubar": "^6.0.3",
"mousetrap": "^1.6.5",
"ngx-bootstrap": "^4.2.0",
"ngx-json-viewer": "^2.4.0",
"ngx-toastr": "^10.0.4",
"node-machine-id": "^1.1.12",
"rimraf": "^3.0.2",
"copy-dir": "~1.3.0",
"crypto-js": "~3.3.0",
"electron-default-menu": "~1.0.2",
"electron-log": "~3.0.6",
"electron-notarize": "~0.1.1",
"electron-osx-sign": "~0.4.17",
"electron-reload": "~1.5.0",
"electron-updater": "~4.3.1",
"extract-zip": "~1.7.0",
"fix-path": "~3.0.0",
"fs-extra": "~8.1.0",
"global-tunnel": "~1.2.0",
"ini": "~1.3.5",
"jwt-decode": "~2.2.0",
"keytar": "~6.0.1",
"md5-file": "~4.0.0",
"menubar": "~6.0.3",
"mousetrap": "~1.6.5",
"ngx-bootstrap": "~4.2.0",
"ngx-json-viewer": "~2.4.0",
"ngx-toastr": "~10.0.4",
"node-log-rotate": "~0.1.5",
"node-machine-id": "~1.1.12",
"rimraf": "~3.0.2",
"rxjs": "~6.4.0",
"saml-encoder-decoder-js": "^1.0.1",
"semver": "^6.3.0",
"sudo-prompt": "^9.2.1",
"tslib": "^1.13.0",
"update-electron-app": "^2.0.1",
"uuid": "^8.3.0",
"v8-compile-cache": "^2.1.1",
"zlib": "^1.0.5",
"saml-encoder-decoder-js": "~1.0.1",
"semver": "~6.3.0",
"sudo-prompt": "~9.2.1",
"tslib": "~1.13.0",
"update-electron-app": "~2.0.1",
"uuid": "~8.3.0",
"v8-compile-cache": "~2.1.1",
"zlib": "~1.0.5",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.24",
"@angular-devkit/build-angular": "~0.803.24",
"@angular/cli": "~8.1.0",
"@angular/compiler-cli": "~8.1.0",
"@angular/language-service": "~8.1.0",
"@biesbjerg/ngx-translate-extract": "^2.3.4",
"@types/jasmine": "^3.5.11",
"@biesbjerg/ngx-translate-extract": "~2.3.4",
"@types/jasmine": "~3.5.11",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^10.17.27",
"codelyzer": "^5.2.2",
"electron": "^8.5.2",
"electron-builder": "^22.7.0",
"electron-builder-squirrel-windows": "^21.1.3",
"electron-installer-dmg": "^3.0.0",
"electron-packager": "^14.2.1",
"electron-rebuild": "^2.0.3",
"@types/node": "~10.17.27",
"codelyzer": "~5.2.2",
"electron": "~8.5.2",
"electron-builder": "~22.7.0",
"electron-builder-squirrel-windows": "~21.1.3",
"electron-installer-dmg": "~3.0.0",
"electron-packager": "~14.2.1",
"electron-rebuild": "~2.0.3",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.4.1",
"karma": "~4.4.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.5.4",
"protractor": "^5.4.4",
"karma-jasmine-html-reporter": "~1.5.4",
"protractor": "~5.4.4",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.4.3"
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.component.ts
Expand Up @@ -49,13 +49,15 @@ export class AppComponent implements OnInit {
// Prevent Dev Tool to show on production mode
this.app.currentBrowserWindow().webContents.on('devtools-opened', () => {
if (environment.production) {
this.app.logger('Closing Web tools in production mode', LoggerLevel.INFO, this);
this.app.currentBrowserWindow().webContents.closeDevTools();
}
});

// We get the right moment to set an hook to app close
const ipc = this.app.getIpcRenderer();
ipc.on('app-close', () => {
this.app.logger('Preparing for closing instruction...', LoggerLevel.INFO, this);
this.beforeCloseInstructions();
});

Expand Down
7 changes: 6 additions & 1 deletion src/app/managing/create-account/create-account.component.ts
@@ -1,7 +1,7 @@
import {Component, ElementRef, Input, NgZone, OnInit, ViewChild} from '@angular/core';
import {FormControl, FormGroup, Validators} from '@angular/forms';
import {ConfigurationService} from '../../services-system/configuration.service';
import {AppService} from '../../services-system/app.service';
import {AppService, LoggerLevel} from '../../services-system/app.service';
import {ActivatedRoute, Router} from '@angular/router';
import {CredentialsService} from '../../services/credentials.service';
import {SessionService} from '../../services/session.service';
Expand Down Expand Up @@ -137,6 +137,8 @@ export class CreateAccountComponent implements OnInit {
* Save the first account in the workspace
*/
saveAccount() {
this.appService.logger(`Saving account...`, LoggerLevel.INFO, this);

if (this.firstTime) {
this.providerManagerService.saveFirstAccount(
this.accountId,
Expand Down Expand Up @@ -180,6 +182,8 @@ export class CreateAccountComponent implements OnInit {
goBack() {
this.workspace = this.configurationService.getDefaultWorkspaceSync();

this.appService.logger(`Going back (this.workspace && this.workspace.sessions && this.workspace.sessions.length > 0): ${this.workspace && this.workspace.sessions && this.workspace.sessions.length > 0}`, LoggerLevel.INFO, this);

if (this.workspace && this.workspace.sessions && this.workspace.sessions.length > 0) {
this.router.navigate(['/sessions', 'session-selected']);
} else {
Expand All @@ -197,6 +201,7 @@ export class CreateAccountComponent implements OnInit {
this.accountType = strategy;
this.provider = strategy;
this.typeSelection = false;
this.appService.logger(`Setting an access strategy we want to create`, LoggerLevel.INFO, this, JSON.stringify({ strategy }, null, 3));
}

openAccessStrategyDocumentation() {
Expand Down
16 changes: 7 additions & 9 deletions src/app/models/strategies/awsStrategy.ts
Expand Up @@ -37,7 +37,7 @@ export class AwsStrategy extends RefreshCredentialsStrategy {
});

console.log('active aws sessions', activeSessions);

this.appService.logger('Aws Active sessions', LoggerLevel.INFO, this, JSON.stringify(activeSessions, null, 3));
return activeSessions;
}

Expand Down Expand Up @@ -74,6 +74,7 @@ export class AwsStrategy extends RefreshCredentialsStrategy {
this.configurationService.disableLoadingWhenReady(workspace, session);
},
(err) => {
this.appService.logger('Error in Aws Credential process', LoggerLevel.ERROR, this, err.stack);
throw new Error(err);
});
}
Expand All @@ -96,6 +97,7 @@ export class AwsStrategy extends RefreshCredentialsStrategy {
observable.next(data);
observable.complete();
} else {
this.appService.logger('Error in get session token', LoggerLevel.ERROR, this, err.stack);
observable.error(err);
observable.complete();
}
Expand Down Expand Up @@ -127,7 +129,7 @@ export class AwsStrategy extends RefreshCredentialsStrategy {
this.doubleJumpFromFixedCredential(session);
}
} catch (e) {
this.appService.logger(e, LoggerLevel.ERROR);
this.appService.logger('Error in Aws Credential Federated Process', LoggerLevel.ERROR, this, e.stack);
this.credentialsService.refreshReturnStatusEmit.emit(false);
}

Expand Down Expand Up @@ -171,8 +173,6 @@ export class AwsStrategy extends RefreshCredentialsStrategy {
const secretKey = await this.keychainService.getSecret(environment.appName, this.appService.keychainGenerateSecretString(parentSession.account.accountName, (parentSession.account as AwsPlainAccount).user));
const credentials = {default: {aws_access_key_id: accessKey, aws_secret_access_key: secretKey}};

console.log('credentials from tt:', credentials);

// Update AWS sdk with new credentials
AWS.config.update({
accessKeyId: credentials.default.aws_access_key_id,
Expand All @@ -188,7 +188,7 @@ export class AwsStrategy extends RefreshCredentialsStrategy {
}, (err, data: any) => {
if (err) {
// Something went wrong save it to the logger file
this.appService.logger(err.stack, LoggerLevel.ERROR);
this.appService.logger('Error in assume role from plain to truster in get session token', LoggerLevel.ERROR, this, err.stack);
this.appService.toast('There was a problem assuming role, please retry', ToastLevel.WARN);

// Emit ko for double jump
Expand All @@ -197,13 +197,9 @@ export class AwsStrategy extends RefreshCredentialsStrategy {
// Finished double jump
this.configurationService.disableLoadingWhenReady(workspace, session);
} else {
console.log('dentro truster');

// we set the new credentials after the first jump
const trusterCredentials: AwsCredentials = this.workspaceService.constructCredentialObjectFromStsResponse(data, workspace, session.account.region);

console.log('truster credentials:', trusterCredentials);

this.fileService.iniWriteSync(this.appService.awsCredentialPath(), trusterCredentials);

this.configurationService.updateWorkspaceSync(workspace);
Expand All @@ -214,6 +210,8 @@ export class AwsStrategy extends RefreshCredentialsStrategy {

// Finished double jump
this.configurationService.disableLoadingWhenReady(workspace, session);

this.appService.logger('Made it through Double jump from plain', LoggerLevel.INFO, this);
}
});
}
Expand Down
10 changes: 7 additions & 3 deletions src/app/models/strategies/azureStrategy.ts
Expand Up @@ -5,7 +5,7 @@ import {Session} from '../session';
import {ConfigurationService} from '../../services-system/configuration.service';
import {ExecuteServiceService} from '../../services-system/execute-service.service';
import {AzureAccount} from '../azure-account';
import {AppService, ToastLevel} from '../../services-system/app.service';
import {AppService, LoggerLevel, ToastLevel} from '../../services-system/app.service';
import {TimerService} from '../../services/timer-service';
import {CredentialsService} from '../../services/credentials.service';

Expand All @@ -25,8 +25,7 @@ export class AzureStrategy extends RefreshCredentialsStrategy {
return sess.account.type === AccountType.AZURE && sess.active;
});

console.log('active azure sessions', activeSessions);

this.appService.logger('active azure sessions', LoggerLevel.INFO, this, JSON.stringify(activeSessions, null, 3));
return activeSessions;
}

Expand Down Expand Up @@ -62,6 +61,7 @@ export class AzureStrategy extends RefreshCredentialsStrategy {

this.azureSetSubscription(session);
}, err => {
this.appService.logger('Error in command by Azure Cli', LoggerLevel.ERROR, this, err.stack);
console.log('Error in command by Azure CLi', err);
});
}
Expand All @@ -71,6 +71,7 @@ export class AzureStrategy extends RefreshCredentialsStrategy {

this.azureSetSubscription(session);
}, err => {
this.appService.logger('Error in command by Azure Cli', LoggerLevel.ERROR, this, err.stack);
console.log('Error in command by Azure CLi', err);
});
}
Expand Down Expand Up @@ -108,13 +109,16 @@ export class AzureStrategy extends RefreshCredentialsStrategy {
// Emit return credentials
this.credentialsService.refreshReturnStatusEmit.emit(true);
}, err2 => {
this.appService.logger('Error in command: set subscription by Azure Cli', LoggerLevel.ERROR, this, err2.stack);

workspace.sessions.forEach(sess => {
if (sess.id === session.id) {
sess.active = false;
sess.loading = false;
sess.lastStopDate = new Date().toISOString();
}
});

this.configurationService.updateWorkspaceSync(workspace);
this.credentialsService.refreshReturnStatusEmit.emit(false);
this.appService.redrawList.emit();
Expand Down

0 comments on commit 807cdec

Please sign in to comment.