@indra.ai/deva.log 0.0.155 → 0.0.157

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +8 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -49,12 +49,10 @@ const LOG = new Deva({
49
49
  this.methods.echo(agent.key, 'a', packet);
50
50
  this.func.log_write('answer', packet);
51
51
  },
52
-
53
52
  // log deva sking another deva
54
53
  'devacore:ask'(packet) {
55
54
  this.func.log_write('ask', packet);
56
55
  },
57
-
58
56
  // log the answer on finish
59
57
  'devacore:finish'(packet) {
60
58
  this.func.log_write('finish', packet);
@@ -63,8 +61,6 @@ const LOG = new Deva({
63
61
  'devacore:complete'(packet) {
64
62
  this.func.log_write('complete', packet);
65
63
  },
66
-
67
-
68
64
  // log all errors
69
65
  'devacore:error'(packet) {
70
66
  this.func.log_write('error', packet);
@@ -89,7 +85,7 @@ const LOG = new Deva({
89
85
  const collection = database.collection(type);
90
86
  result = await collection.insertOne(packet);
91
87
  } catch (e) {
92
- console.dir(e);
88
+ return this.err(e, packet, false);
93
89
  } finally {
94
90
  return result;
95
91
  }
@@ -112,21 +108,27 @@ const LOG = new Deva({
112
108
  const agent_license = this.info().VLA; // get agent license
113
109
  const license_check = this.license_check(personal, agent_license); // check license
114
110
  // return this.start if license_check passes otherwise stop.
111
+ this.action('return', `onInit:${data.id.uid}`);
115
112
  return license_check ? this.start(data, resolve) : this.stop(data, resolve);
116
113
  },
117
114
  onReady(data, resolve) {
118
115
  const {VLA} = this.info();
119
116
 
117
+ this.state('get', `mongo:global:${data.id.uid}`);
120
118
  const {uri,database} = this.log().global.mongo;
119
+ this.state('set', `mongo:client:${data.id.uid}`);
121
120
  this.modules.client = new MongoClient(uri);
121
+ this.state('set', `mongo:database:${data.id.uid}`);
122
122
  this.vars.database = database;
123
123
 
124
124
  this.prompt(`${this.vars.messages.ready} > VLA:${VLA.uid}`);
125
+
126
+ this.action('resolve', `onReady:${data.id.uid}`);
125
127
  return resolve(data);
126
128
  },
127
129
  onError(err, data, reject) {
128
130
  this.prompt(this.vars.messages.error);
129
- console.log(err);
131
+ this.action('reject', `onError:${data.id.uid}`);
130
132
  return reject(err);
131
133
  }
132
134
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "46605441065773246919",
3
3
  "name": "@indra.ai/deva.log",
4
- "version": "0.0.155",
4
+ "version": "0.0.157",
5
5
  "license": "VLA:46605441065773246919 LICENSE.md",
6
6
  "VLA": {
7
7
  "uid": "46605441065773246919",