@indra.ai/deva.log 0.0.156 → 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 -5
  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,7 +61,6 @@ const LOG = new Deva({
63
61
  'devacore:complete'(packet) {
64
62
  this.func.log_write('complete', packet);
65
63
  },
66
-
67
64
  // log all errors
68
65
  'devacore:error'(packet) {
69
66
  this.func.log_write('error', packet);
@@ -88,7 +85,7 @@ const LOG = new Deva({
88
85
  const collection = database.collection(type);
89
86
  result = await collection.insertOne(packet);
90
87
  } catch (e) {
91
- console.dir(e);
88
+ return this.err(e, packet, false);
92
89
  } finally {
93
90
  return result;
94
91
  }
@@ -111,21 +108,27 @@ const LOG = new Deva({
111
108
  const agent_license = this.info().VLA; // get agent license
112
109
  const license_check = this.license_check(personal, agent_license); // check license
113
110
  // return this.start if license_check passes otherwise stop.
111
+ this.action('return', `onInit:${data.id.uid}`);
114
112
  return license_check ? this.start(data, resolve) : this.stop(data, resolve);
115
113
  },
116
114
  onReady(data, resolve) {
117
115
  const {VLA} = this.info();
118
116
 
117
+ this.state('get', `mongo:global:${data.id.uid}`);
119
118
  const {uri,database} = this.log().global.mongo;
119
+ this.state('set', `mongo:client:${data.id.uid}`);
120
120
  this.modules.client = new MongoClient(uri);
121
+ this.state('set', `mongo:database:${data.id.uid}`);
121
122
  this.vars.database = database;
122
123
 
123
124
  this.prompt(`${this.vars.messages.ready} > VLA:${VLA.uid}`);
125
+
126
+ this.action('resolve', `onReady:${data.id.uid}`);
124
127
  return resolve(data);
125
128
  },
126
129
  onError(err, data, reject) {
127
130
  this.prompt(this.vars.messages.error);
128
- console.log(err);
131
+ this.action('reject', `onError:${data.id.uid}`);
129
132
  return reject(err);
130
133
  }
131
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.156",
4
+ "version": "0.0.157",
5
5
  "license": "VLA:46605441065773246919 LICENSE.md",
6
6
  "VLA": {
7
7
  "uid": "46605441065773246919",