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

Remove console logs except error logging #158

Merged
Merged
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
2 changes: 1 addition & 1 deletion common/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import bcrypt from 'bcryptjs';

import * as U from '@common/utilities';
import * as C from '@common/constants';
import * as U from '@common/utilities';

export async function attemptHash(password) {
if (U.isEmpty(password)) {
Expand Down
8 changes: 1 addition & 7 deletions common/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as C from '@common/constants';
export const get = async (route, host = C.api.host): Promise<any> => {
try {
const token = Cookies.get(C.auth);

let r = await fetch(`${host}${route}`, {
method: 'GET',
headers: {
Expand All @@ -28,7 +27,7 @@ export const get = async (route, host = C.api.host): Promise<any> => {
return { error: j.error };
}

console.log(route, j);

return j;
} catch (e) {
console.log(route, e);
Expand All @@ -38,7 +37,6 @@ export const get = async (route, host = C.api.host): Promise<any> => {

export const post = async (route, payload, host = C.api.host): Promise<any> => {
try {

const token = Cookies.get(C.auth);

let r = await fetch(`${host}${route}`, {
Expand All @@ -56,7 +54,6 @@ export const post = async (route, payload, host = C.api.host): Promise<any> => {
}

const j = await r.json();

if (!j) {
return { error: 'No response from the server.' };
}
Expand All @@ -67,7 +64,6 @@ export const post = async (route, payload, host = C.api.host): Promise<any> => {

return j;
} catch (e) {
console.log(e);
console.log(route, e);
return { error: 'Something went wrong on our end' };
}
Expand Down Expand Up @@ -100,7 +96,6 @@ export const put = async (route, payload, host = C.api.host): Promise<any> => {
return { error: j.error };
}

console.log(route, j);
return j;
} catch (e) {
console.log(route, e);
Expand Down Expand Up @@ -135,7 +130,6 @@ export const del = async (route: string, payload?: object, host = C.api.host): P
return { error: j.error };
}

console.log(route, j);
return j;
} catch (e) {
console.log(route, e);
Expand Down
14 changes: 5 additions & 9 deletions common/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FilecoinNumber, Converter } from '@glif/filecoin-number';
import { FilecoinNumber } from '@glif/filecoin-number';

import * as Cookies from '@vendor/cookie-cutter';
import * as C from '@common/constants';
import * as R from '@common/requests';
import * as Cookies from '@vendor/cookie-cutter';

export const formatEstuaryRetrievalUrl = (cid: string) => {
return `${C.api.host}/gw/ipfs/${cid}`
Expand Down Expand Up @@ -33,7 +33,6 @@ export const pad = (num: number, size: number): any => {

export const toDateSinceEpoch = (epoch) => {
const d = new Date(1000 * (epoch * 30 + 1598306400));

return toDate(d);
};

Expand Down Expand Up @@ -103,7 +102,6 @@ export function inUSDPrice(number = 0, price = 0) {
}

export const getViewerFromFission = async ({ fs, path }) => {
console.log({ path });
const maybePathExists = await fs.exists(path);

if (!maybePathExists) {
Expand All @@ -114,12 +112,11 @@ export const getViewerFromFission = async ({ fs, path }) => {

const token = await fs.read(path);
if (!token) {
console.log('Failed to authenticate with Fission.');
return null;
}

const viewer = await getViewerFromToken(token);
console.log({ fissionSourcedViewer: viewer });

return viewer;
};

Expand All @@ -133,7 +130,7 @@ export const getViewerFromToken = async (token) => {
});

const json = await response.json();
console.log(json);

if (!json) {
return null;
}
Expand All @@ -160,7 +157,7 @@ export const getViewerFromHeader = async (headers) => {
});

const json = await response.json();
console.log(json);

if (!json) {
return null;
}
Expand All @@ -171,7 +168,6 @@ export const getViewerFromHeader = async (headers) => {

return json;
} catch (e) {
console.log(e);
return null;
}
};
Expand Down
15 changes: 5 additions & 10 deletions components/UploadFileContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import styles from '@components/UploadFileContainer.module.scss';

import * as React from 'react';
import * as U from '@common/utilities';
import * as C from '@common/constants';
import * as R from '@common/requests';
import * as U from '@common/utilities';
import * as React from 'react';

import LoaderSpinner from '@components/LoaderSpinner';
import Button from '@components/Button';
import ActionRow from '@components/ActionRow';
import Button from '@components/Button';
import LoaderSpinner from '@components/LoaderSpinner';
import Cookies from 'js-cookie';

export default class UploadFileContainer extends React.Component<any> {
Expand Down Expand Up @@ -74,8 +74,6 @@ export default class UploadFileContainer extends React.Component<any> {

formData.append('data', this.state.data.file, this.state.data.filename);

console.log(formData);

this.setState({ mode: 4 });
this.props.onUploadFile({ staging: this.state.staging });

Expand Down Expand Up @@ -119,7 +117,6 @@ export default class UploadFileContainer extends React.Component<any> {
};

xhr.onloadend = (event: any) => {
console.log(event);
if (event.target && event.target.status === 200 && event.target.response) {
let json = {};
try {
Expand All @@ -140,7 +137,7 @@ export default class UploadFileContainer extends React.Component<any> {

handleSelectFile = (e) => {
e.persist();
console.log('select file: ', e.target);

if (e.target.files.length == 0) {
return;
}
Expand All @@ -153,7 +150,6 @@ export default class UploadFileContainer extends React.Component<any> {
handleDrop = (e) => {
e.preventDefault();
e.stopPropagation();
console.log('dropped a thing: ', e.dataTransfer.files);

if (this.state.mode !== 3) {
return;
Expand All @@ -171,7 +167,6 @@ export default class UploadFileContainer extends React.Component<any> {
const file = e.dataTransfer.files[0];

this.setState({ loading: true });

this.doFileUpload(file, file.name);
};

Expand Down
13 changes: 5 additions & 8 deletions components/UploadItem.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import styles from '@components/UploadItem.module.scss';

import * as React from 'react';
import * as U from '@common/utilities';
import * as C from '@common/constants';
import * as R from '@common/requests';
import * as U from '@common/utilities';
import * as React from 'react';

import Cookies from 'js-cookie';
import ProgressBlock from '@components/ProgressBlock';
import ActionRow from '@components/ActionRow';
import LoaderSpinner from '@components/LoaderSpinner';
import ProgressBlock from '@components/ProgressBlock';
import Cookies from 'js-cookie';

export class PinStatusElement extends React.Component<any> {
state = { pinned: false, delegates: ['none'] };
Expand All @@ -17,10 +17,8 @@ export class PinStatusElement extends React.Component<any> {
const checkPinStatus = () => {
window.setTimeout(async () => {
const response = await R.get(`/pinning/pins/${this.props.id}`, this.props.host);
console.log(response);

if (response.status === 'pinned') {
console.log('stop loop');
this.setState({ pinned: true, ...response });
this.forceUpdate();
return;
Expand All @@ -38,7 +36,7 @@ export class PinStatusElement extends React.Component<any> {
return (
<React.Fragment>
<ActionRow>This CID is pinned.</ActionRow>
<ActionRow>Delegate {this.state.delegates && this.state.delegates.length > 0 ? this.state.delegates[0] : ""}</ActionRow>
<ActionRow>Delegate {this.state.delegates && this.state.delegates.length > 0 ? this.state.delegates[0] : ''}</ActionRow>
</React.Fragment>
);
}
Expand All @@ -64,7 +62,6 @@ export default class UploadItem extends React.Component<any> {

upload = async () => {
if (this.state.loaded > 0) {
console.log('already attempted', this.props.file.id);
return;
}

Expand Down
5 changes: 1 addition & 4 deletions components/UploadZone.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import styles from '@components/UploadZone.module.scss';

import * as React from 'react';
import * as U from '@common/utilities';
import * as C from '@common/constants';

import LoaderSpinner from '@components/LoaderSpinner';
import Button from '@components/Button';
import LoaderSpinner from '@components/LoaderSpinner';

const MODES = {
1: 'WAITING',
Expand Down Expand Up @@ -100,7 +98,6 @@ export default class UploadZone extends React.Component<any> {
handlePushFiles = async (files) => {
for await (const file of files) {
if (!file.type && file.size % 4096 == 0) {
console.log('folder', file);
window.alert(`Estuary does not support folder upload at the moment, skipping "${file.name}"`);
continue;
}
Expand Down
3 changes: 0 additions & 3 deletions pages/admin/analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ function AdminAnalyticsPage(props: any) {
console.log(response.error);
return;
}

console.log(response);
};

run();
}, []);

Expand Down
2 changes: 1 addition & 1 deletion pages/admin/balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const sendEscrow = async (state, setState, host) => {
}

const response = await R.post(`/admin/add-escrow/${state.amount}`, {}, host);
console.log(response);

if (response.error) {
console.log(response.error);
alert('Something went wrong, please try again.');
setState({ ...state, amount: 0, loading: false });
return;
Expand Down
1 change: 0 additions & 1 deletion pages/admin/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function AdminContentPage(props: any) {
React.useEffect(() => {
const run = async () => {
const response = await R.get('/admin/cm/offload/candidates', props.api);
console.log(response);

if (response && response.error) {
return;
Expand Down
1 change: 0 additions & 1 deletion pages/admin/impersonate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const onSubmit = async (event, state, setState) => {
return null;
}

console.log('Impersonating...');
Cookies.set(C.auth, state.key);
window.location.reload();
};
Expand Down
8 changes: 4 additions & 4 deletions pages/admin/invites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function AdminInvitesPage(props: any) {
React.useEffect(() => {
const run = async () => {
const response = await R.get('/admin/invites', props.api);
console.log(response);

setState({ ...state, invites: response && response.length ? response.reverse() : [] });
};

Expand All @@ -75,7 +75,7 @@ function AdminInvitesPage(props: any) {
setState({ ...state, loading: true });
await R.post(`/admin/invite/${state.key}`, {}, props.api);
const response = await R.get('/admin/invites', props.api);
console.log(response);

setState({
...state,
loading: false,
Expand All @@ -94,7 +94,7 @@ function AdminInvitesPage(props: any) {
setState({ ...state, loading: true });
await R.post(`/admin/invite/${generatedKey}`, {}, props.api);
const response = await R.get('/admin/invites', props.api);
console.log(response);

return setState({
...state,
loading: false,
Expand All @@ -106,7 +106,7 @@ function AdminInvitesPage(props: any) {
setState({ ...state, loading: true });
await R.post(`/admin/invite/${state.key}`, {}, props.api);
const response = await R.get('/admin/invites', props.api);
console.log(response);

setState({
...state,
loading: false,
Expand Down
2 changes: 0 additions & 2 deletions pages/admin/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ const refresh = async (state, setState, host) => {
map[m.miner] = m;
}

console.log(map);

const list = await R.get('/public/miners', host);

const miners = list.map((each) => {
Expand Down
4 changes: 2 additions & 2 deletions pages/admin/shuttle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function AdminShuttlePage(props: any) {
React.useEffect(() => {
const run = async () => {
const response = await R.get('/admin/shuttle/list', props.api);
console.log(response);

setState({ ...state, shuttles: response && response.length ? response : [] });
};

Expand All @@ -69,7 +69,7 @@ function AdminShuttlePage(props: any) {
setState({ ...state, loading: true });
await R.post(`/admin/shuttle/init`, {}, props.api);
const response = await R.get('/admin/shuttle/list', props.api);
console.log(response);

setState({ ...state, loading: false, shuttles: response && response.length ? response : [] });
}}
>
Expand Down
2 changes: 0 additions & 2 deletions pages/admin/stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ function AdminStatsPage(props) {

const sidebarElement = <AuthenticatedSidebar active="ADMIN_STATS" viewer={props.viewer} />;

console.log(props.viewer);

return (
<Page title="Estuary: Admin: Stats" description="Estuary node performance and behavior." url={`${props.hostname}/stats`}>
<AuthenticatedLayout navigation={<Navigation isAuthenticated isRenderingSidebar={!!sidebarElement} />} sidebar={sidebarElement}>
Expand Down
4 changes: 1 addition & 3 deletions pages/api-admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ const REDACTED_TOKEN_STRING = '•'.repeat(42);

function APIPage(props: any) {
const viewerToken = Cookie.get(C.auth);
console.log(viewerToken);

const [state, setState] = React.useState({ keys: [], loading: false });
const [showCreateKeyModal, setShowCreateKeyModal] = React.useState(false);
const [showCreatePermanentKeyModal, setShowCreatePermanentKeyModal] = React.useState(false);

React.useEffect(() => {
const run = async () => {
const response = await R.get('/user/api-keys', props.api);
console.log(response);

if (response && !response.error) {
setState({ ...state, keys: response });
}
Expand Down
1 change: 0 additions & 1 deletion pages/api/fil-usd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default async function getPrice(req: any, res: any) {
'https://cloud.iexapis.com/stable/crypto/filusdt/price?token=pk_aa330a89a4724944ae1a525879a19f2d'
);
json = await response.json();
console.log(json);
} catch (e) {
console.log(e);
return res.status(500).json({ error: 'Network price issue.' });
Expand Down
Loading