clean: cleanup backend logs

This commit is contained in:
KernelDeimos
2024-11-19 15:00:04 -05:00
parent dca7892fca
commit 0fa3be9d43
12 changed files with 33 additions and 47 deletions
-1
View File
@@ -596,7 +596,6 @@ module.exports = class APIError {
});
}
serialize () {
console.log('MESSAGE FROM ERROR: ' + `|${this.message}|`);
return {
...this.fields,
$: 'heyputer:api/APIError',
-2
View File
@@ -31,7 +31,6 @@ class DBKVStore extends Driver {
}
static METHODS = {
get: async function ({ app_uid, key }) {
console.log('THIS WAS CALLED', { key });
const actor = this.context.get('actor');
// If the actor is an app then it gets its own KV store.
@@ -67,7 +66,6 @@ class DBKVStore extends Driver {
return kv[0]?.value ?? null;
},
set: async function ({ app_uid, key, value }) {
console.log('THIS WAS CALLED (SET)', { key, value })
const actor = this.context.get('actor');
// Validate the key
+3 -1
View File
@@ -1121,7 +1121,9 @@ async function jwt_auth(req){
token: token,
};
}catch(e){
console.log('ERROR', e);
if ( ! (e instanceof APIError) ) {
console.log('ERROR', e);
}
throw(e.message);
}
}
@@ -205,7 +205,6 @@ class AppES extends BaseES {
})();
if ( ! is_owner ) {
for ( let i=0;i<20;i++ ) console.log('TYHIS IS HAPPEN');
entity.del('approved_for_listing');
entity.del('approved_for_opening_items');
entity.del('approved_for_incentive_program');
-1
View File
@@ -65,7 +65,6 @@ module.exports = eggspress('/open_item', {
const signature = await sign_file(subject.entry, action);
const suggested_apps = await suggest_app_for_fsentry(subject.entry);
console.log('suggested apps?', suggested_apps);
const apps_only_one = suggested_apps.slice(0,1);
const _app = apps_only_one[0];
if ( ! _app ) {
@@ -17,7 +17,6 @@ class FeatureFlagService extends BaseService {
async _init () {
const svc_detailProvider = this.services.get('whoami');
svc_detailProvider.register_provider(async (context, out) => {
console.log(`\x1B[36;1mCALLED\x1B[0m`);
if ( ! context.actor ) return;
out.feature_flags = await this.get_summary(context.actor);
});
@@ -105,7 +105,7 @@ class DriverService extends BaseService {
try {
return await this._call(o);
} catch ( e ) {
console.error(e);
this.log.error('Driver error response: ' + e.toString());
return this._driver_response_from_error(e);
}
}
@@ -194,7 +194,6 @@ class DriverService extends BaseService {
}
return { success: true, ...meta, result };
} catch ( e ) {
console.error(e);
let for_user = (e instanceof APIError) || (e instanceof DriverError);
if ( ! for_user ) this.errors.report(`driver:${iface}:${method}`, {
source: e,
@@ -205,6 +204,7 @@ class DriverService extends BaseService {
args,
}
});
this.log.error('Driver error response: ' + e.toString());
return this._driver_response_from_error(e, meta);
}
}
@@ -294,8 +294,12 @@ class DriverService extends BaseService {
effective_policy = effective_policy.policy;
console.log('EFFECTIVE',
JSON.stringify(effective_policy, undefined, ' '));
this.log.info('Invoking Driver Call', {
service_name,
iface,
method,
policy: effective_policy
});
const method_key = `V1:${service_name}:${iface}:${method}`;
@@ -400,12 +404,6 @@ class DriverService extends BaseService {
async _driver_response_from_error (e, meta) {
let serializable = (e instanceof APIError) || (e instanceof DriverError);
if ( serializable ) {
console.log('Serialized error test', JSON.stringify(
e.serialize(), null, 2
))
console.log('Serialized error message: ', e.serialize().message)
}
return {
success: false,
...meta,
@@ -172,7 +172,6 @@ class FileCacheService extends AdvancedBase {
}
await this._precache_make_room(size);
console.log(`precache input key: ${key}`);
this.precache.set(key, data);
tracker.phase = FileTracker.PHASE_PRECACHE;
})()
@@ -99,16 +99,16 @@ class MonthlyUsageService extends BaseService {
// months are zero-indexed by getUTCMonth, which could be confusing
const month = new Date().getUTCMonth() + 1;
console.log(
'what check query?',
'SELECT SUM(`count`) AS sum FROM `service_usage_monthly` ' +
'WHERE `year` = ? AND `month` = ? AND `user_id` = ? ' +
'AND `key` = ?',
[
year, month, actor.type.user.id,
key,
]
);
// console.log(
// 'what check query?',
// 'SELECT SUM(`count`) AS sum FROM `service_usage_monthly` ' +
// 'WHERE `year` = ? AND `month` = ? AND `user_id` = ? ' +
// 'AND `key` = ?',
// [
// year, month, actor.type.user.id,
// key,
// ]
// );
const rows = await this.db.read(
'SELECT SUM(`count`) AS sum FROM `service_usage_monthly` ' +
'WHERE `year` = ? AND `month` = ? AND `user_id` = ? ' +
@@ -119,8 +119,6 @@ class MonthlyUsageService extends BaseService {
]
);
console.log('what rows?', rows);
return rows[0]?.sum || 0;
}
@@ -63,10 +63,10 @@ class RateLimitService extends BaseService {
window_start = ts_fr_sql(row.window_start);
const count = row.count;
console.log(
'set window_start and count from DATABASE',
{ window_start, count }
);
// console.log(
// 'set window_start and count from DATABASE',
// { window_start, count }
// );
kv.set(`${kvkey}:window_start`, window_start);
kv.set(`${kvkey}:count`, count);
@@ -89,20 +89,20 @@ class RateLimitService extends BaseService {
);
}
console.log(
'DEBUGGING COMPARISON',
{ window_start, period, now: Date.now() }
);
// console.log(
// 'DEBUGGING COMPARISON',
// { window_start, period, now: Date.now() }
// );
if ( window_start + period < Date.now() ) {
window_start = Date.now();
kv.set(`${kvkey}:window_start`, window_start);
kv.set(`${kvkey}:count`, 0);
console.log(
'REFRESH window_start and count',
{ window_start, count: 0 }
);
// console.log(
// 'REFRESH window_start and count',
// { window_start, count: 0 }
// );
await this.db.write(
'UPDATE `rl_usage_fixed_window` SET `window_start` = ?, `count` = ? WHERE `key` = ?',
@@ -126,12 +126,10 @@ const PERMISSION_SCANNERS = [
const svc_group = await a.iget('services').get('group');
const groups = await svc_group.list_groups_with_member(
{ user_id: actor.type.user.id });
console.log('uh, groups?', actor.type.user.id, groups);
const group_uids = {};
for ( const group of groups ) {
group_uids[group.values.uid] = group;
}
console.log('group uids', group_uids);
for ( const issuer_username in hardcoded_user_group_permissions ) {
const issuer_actor = new Actor({
@@ -141,12 +139,10 @@ const PERMISSION_SCANNERS = [
});
const issuer_groups =
hardcoded_user_group_permissions[issuer_username];
console.log('issuer groups', issuer_groups);
for ( const group_uid in issuer_groups ) {
if ( ! group_uids[group_uid] ) continue;
const issuer_group = issuer_groups[group_uid];
for ( const permission of permission_options ) {
console.log('permission?', permission);
if ( ! issuer_group.hasOwnProperty(permission) ) continue;
const issuer_reading =
await a.icall('scan', issuer_actor, permission)
-1
View File
@@ -67,7 +67,6 @@ class RemoveFromArrayDetachable extends AlsoDetachable {
}
detach_ () {
for ( let i=0; i < 10; i++ ) console.log('THIS DOES GET CALLED');
const index = this.array.indexOf(this.element);
if ( index !== -1 ) {
this.array.splice(index, 1);