Skip to content

Commit e1a09d5

Browse files
committed
turn down logging abit
1 parent 37b873b commit e1a09d5

2 files changed

Lines changed: 16 additions & 21 deletions

File tree

OpenFlow/src/DatabaseConnection.ts

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class DatabaseConnection {
128128
}
129129
for (var i: number = 0; i < arr.length; i++) { arr[i] = this.decryptentity(arr[i]); }
130130
this.traversejsondecode(arr);
131-
this._logger.debug("[" + user.username + "] query gave " + arr.length + " results " + JSON.stringify(query));
131+
this._logger.debug("[" + user.username + "][" + collectionname + "] query gave " + arr.length + " results " + JSON.stringify(query));
132132
return arr;
133133
}
134134
/**
@@ -252,10 +252,9 @@ export class DatabaseConnection {
252252
item._modified = item._created;
253253
var hasUser: Ace = item._acl.find(e => e._id === user._id);
254254
if ((hasUser === null || hasUser === undefined)) {
255-
if (collectionname != "audit") { this._logger.debug("[" + user.username + "] Adding self " + user.username + " to object " + (item.name || item._name)); }
256255
item.addRight(user._id, user.name, [Rights.full_control]);
257256
}
258-
if (collectionname != "audit") { this._logger.debug("[" + user.username + "] Adding " + (item.name || item._name) + " to database"); }
257+
if (collectionname != "audit") { this._logger.debug("[" + user.username + "][" + collectionname + "] Adding " + item._type + " " + (item.name || item._name) + " to database"); }
259258

260259
item = this.encryptentity<T>(item);
261260
if (!item._id) { item._id = new ObjectID().toHexString(); }
@@ -274,9 +273,6 @@ export class DatabaseConnection {
274273
//var options: CollectionInsertOneOptions = { w: "majority" };
275274
var result: InsertOneWriteOpResult = await this.db.collection(collectionname).insertOne(item, options);
276275
item = result.ops[0];
277-
if (item !== null && item !== undefined) {
278-
this._logger.debug("[" + user.username + "] Inserted " + (item.name || item._name) + " with id " + item._id);
279-
}
280276
if (collectionname === "users" && item._type === "user") {
281277
var users: Role = await Role.FindByNameOrId("users", jwt);
282278
users.AddMember(item);
@@ -360,7 +356,6 @@ export class DatabaseConnection {
360356
q.item = this.encryptentity<T>(q.item);
361357
var hasUser: Ace = q.item._acl.find(e => e._id === user._id);
362358
if ((hasUser === null || hasUser === undefined) && q.item._acl.length == 0) {
363-
if (q.collectionname != "audit") { this._logger.debug("[" + user.username + "] Adding self " + user.username + " to object " + (q.item.name || q.item._name)); }
364359
q.item.addRight(user._id, user.name, [Rights.full_control]);
365360
}
366361
q.item._version = await this.SaveDiff(q.collectionname, original, q.item);
@@ -376,7 +371,7 @@ export class DatabaseConnection {
376371
(q.item as any).passwordhash = await Crypt.hash((q.item as any).newpassword);
377372
delete (q.item as any).newpassword;
378373
}
379-
this._logger.debug("[" + user.username + "] Updating " + (q.item.name || q.item._name) + " in database");
374+
this._logger.debug("[" + user.username + "][" + q.collectionname + "] Updating " + (q.item.name || q.item._name) + " in database");
380375
// await this.db.collection(collectionname).replaceOne({ _id: item._id }, item, options);
381376

382377
if (q.query === null || q.query === undefined) {
@@ -467,7 +462,7 @@ export class DatabaseConnection {
467462
(q.item["$set"])._modified = new Date(new Date().toISOString());
468463

469464

470-
this._logger.debug("[" + user.username + "] UpdateMany " + (q.item.name || q.item._name) + " in database");
465+
this._logger.debug("[" + user.username + "][" + q.collectionname + "] UpdateMany " + (q.item.name || q.item._name) + " in database");
471466

472467
q.j = ((q.j as any) === 'true' || q.j === true);
473468
if ((q.w as any) !== "majority") q.w = parseInt((q.w as any));
@@ -528,15 +523,15 @@ export class DatabaseConnection {
528523
if (!this.hasAuthorization(user, q.item, "update")) { throw new Error("Access denied"); }
529524
// if (q.item._id !== null && q.item._id !== undefined && q.item._id !== "") {
530525
if (exists.length == 1) {
531-
this._logger.debug("[" + user.username + "] InsertOrUpdateOne, Updating found one in database");
526+
this._logger.debug("[" + user.username + "][" + q.collectionname + "] InsertOrUpdateOne, Updating found one in database");
532527
var uq = new UpdateOneMessage<T>();
533528
// uq.query = query;
534529
uq.item = q.item; uq.collectionname = q.collectionname; uq.w = q.w; uq.j; uq.jwt = q.jwt;
535530
uq = await this.UpdateOne(uq);
536531
q.opresult = uq.opresult;
537532
q.result = uq.result;
538533
} else {
539-
this._logger.debug("[" + user.username + "] InsertOrUpdateOne, Inserting as new in database");
534+
this._logger.debug("[" + user.username + "][" + q.collectionname + "] InsertOrUpdateOne, Inserting as new in database");
540535
q.result = await this.InsertOne(q.item, q.collectionname, q.w, q.j, q.jwt);
541536
}
542537
return q;
@@ -566,7 +561,7 @@ export class DatabaseConnection {
566561

567562
// var arr = await this.db.collection(collectionname).find(_query).toArray();
568563

569-
this._logger.debug("[" + user.username + "] Deleting " + id + " in database");
564+
this._logger.debug("[" + user.username + "][" + collectionname + "] Deleting " + id + " in database");
570565
var res: DeleteWriteOpResultObject = await this.db.collection(collectionname).deleteOne(_query);
571566

572567
// var res:DeleteWriteOpResultObject = await this.db.collection(collectionname).deleteOne({_id:id});
@@ -668,14 +663,14 @@ export class DatabaseConnection {
668663
finalor.push(q2);
669664
}
670665
//
671-
if (bits.length > 0 && (bits[0] + 1) == Rights.read) {
672-
this._logger.debug("[" + user.username + "] Include isme in base query");
673-
return { $or: finalor.concat(isme) };
674-
} else if (bits.length > 0) {
675-
this._logger.debug("[" + user.username + "] Skip isme in base query, not read (" + bits[0] + ")");
676-
} else {
677-
this._logger.debug("[" + user.username + "] Skip isme in base query, bits missing!");
678-
}
666+
// if (bits.length > 0 && (bits[0] + 1) == Rights.read) {
667+
// this._logger.debug("[" + user.username + "] Include isme in base query");
668+
// return { $or: finalor.concat(isme) };
669+
// } else if (bits.length > 0) {
670+
// this._logger.debug("[" + user.username + "] Skip isme in base query, not read (" + bits[0] + ")");
671+
// } else {
672+
// this._logger.debug("[" + user.username + "] Skip isme in base query, bits missing!");
673+
// }
679674
return { $or: finalor.concat() };
680675
}
681676
/**

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.281
1+
0.0.282

0 commit comments

Comments
 (0)