un-cli 0.0.61 → 0.0.62

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.
package/adminlog.mjs CHANGED
@@ -13,10 +13,10 @@ export class AdminLog {
13
13
  this.token = token;
14
14
  }
15
15
 
16
- query (codes, serviceName ="*", pageSize = 100000, startTime = null, endTime = null)
16
+ query (codes, serviceName ="*", pageSize = 100000, startTime = null, endTime = null, logLevel = "DEBUG")
17
17
  {
18
18
  const url = this.adminServerUrl + "/logs/query?f=pjson"
19
- const level = "DEBUG"
19
+ const level = logLevel
20
20
  const filterType="json"
21
21
  const token = this.token
22
22
  const filter = {
package/cmd.txt CHANGED
@@ -1,4 +1 @@
1
- subnetworks
2
- arlogs --byrule --maxguid
3
- arlogs --byrule --minguid
4
- arlogs --byrule
1
+ tracelogs --m 300
package/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { AdminLog } from "./adminlog.mjs"
7
7
  import { logger } from "./logger.mjs"
8
8
  import fetch from "node-fetch"
9
9
  //update version
10
- let version = "0.0.61";
10
+ let version = "0.0.62";
11
11
  const GENERATE_TOKEN_TIME_MIN = 30;
12
12
 
13
13
  let rl = null;
@@ -178,6 +178,7 @@ const inputs = {
178
178
  "count": "Lists the number of rows in all feature layers.",
179
179
  "count --system": "Lists the number of rows in system layers.",
180
180
  "connect --service": "Connects to the another service",
181
+ "tracelogs --m <minutes>": "Lists utility network trace summary logs for the last x minutes (requires admin)",
181
182
  "arlogs": "Lists attribute rules execution logs (requires admin)",
182
183
  "arlogs --byrule [--minguid --maxguid]": "Lists attribute rules execution summary by rule (requires admin), --maxguid and --minguid show the GUID of the feature",
183
184
  "whoami": "Lists the current login info",
@@ -714,6 +715,36 @@ const inputs = {
714
715
  },
715
716
 
716
717
 
718
+
719
+
720
+ "^tracelogs --m": async input => {
721
+ const topLogCount = 1000;
722
+ const pageSize = 10000
723
+
724
+ const inputParam = input.match(/--m .*/gm)
725
+ let mins = 30; //query logs for the last 30 minutes
726
+ if (inputParam != null && inputParam.length > 0)
727
+ mins = inputParam[0].replace("--m ", "")
728
+
729
+ console.log(`Querying trace logs for ${parameters.service} for the last ${mins} minutes ...`)
730
+ const startTime = Date.now() - mins*60*1000
731
+ const endTime = Date.now();
732
+ let result= await adminLog.query([102002], [parameters.service+ ".MapServer"], topLogCount, startTime ,endTime , "VERBOSE")
733
+ let jsonRes = await result.json()
734
+ let allMessages = [].concat(jsonRes.logMessages)
735
+
736
+ while (jsonRes.hasMore && allMessages.filter(m => m.message.indexOf(" Environment -") > -1).length < topLogCount )
737
+ {
738
+ //start paging
739
+ logger.info(`Aggregating messages... total so far ${allMessages.length} debug entries but more left, pulling logs before ${new Date(jsonRes.endTime)}`)
740
+ result= await adminLog.query([102002], [parameters.service + ".MapServer"], pageSize, jsonRes.endTime)
741
+ jsonRes = await result.json()
742
+ allMessages = allMessages.concat(jsonRes.logMessages)
743
+ }
744
+
745
+ allMessages.forEach(m => console.log(m.message))
746
+
747
+ },
717
748
  "^arlogs --byrule": async input => {
718
749
  //--minguid to show min guid
719
750
  //--maxguid to show max guid
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "un-cli",
3
- "version": "0.0.61",
3
+ "version": "0.0.62",
4
4
  "description": "Command line interface for working with ArcGIS Utility Network Extension",
5
5
  "main": "index.mjs",
6
6
  "bin": {