Skip to content

Commit

Permalink
improve info command
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed May 20, 2021
1 parent e6be578 commit 97c2da0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
32 changes: 30 additions & 2 deletions examples/simple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,36 @@ const broker = new ServiceBroker({
transporter: "TCP",
logger: console,
cacher: true,
metrics: true,
tracing: false,
metrics: {
enabled: true,
reporter: [
{
type: "Event",
options: {
// Prints only changed metrics, not the full list.
onlyChanges: true
}
}, "Prometheus"
]
},
tracing: {
enabled: true,
exporter: {
type: "Console",
options: {
// Using colors
colors: true,
// Width of row
width: 100,
// Gauge width in the row
gaugeWidth: 40
}
}
},

metadata: {
region: "west-eu"
},

middlewares: [
"Bulkhead",
Expand Down
14 changes: 10 additions & 4 deletions src/commands/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ module.exports = function(vorpal, broker) {
else if (_.isBoolean(val)) {
print(pad + key, kleur.magenta(val));
}
else if (_.isBoolean(val)) {
print(pad + key, kleur.magenta(val));
}
else if (_.isFunction(val)) {
print(pad + key, kleur.blue(`[Function ${val.name}]`));
}
Expand All @@ -51,11 +48,20 @@ module.exports = function(vorpal, broker) {
if (_.isString(v)) return kleur.green(`"${v}"`);
if (_.isPlainObject(v) || _.isFunction) return kleur.green(`"${v.name}"`);
}).join(", "));
} else if (key == "replCommands") {
print(pad + key, val.map(v => {
if (_.isPlainObject(v)) return kleur.green(`"${v.command}"`);
}).join(", "));
} else if (key == "reporter" || key == "exporter") {
print(pad + key, val.map(v => {
if (_.isString(v)) return kleur.green(`"${v}"`);
if (_.isPlainObject(v)) return kleur.green(`"${v.type}"`);
}).join(", "));
} else {
print(pad + key, kleur.blue("[" + val.join(", ") + "]"));
}
}
else if (_.isPlainObject(val) && level < 1) {
else if (_.isPlainObject(val) && level < 2) {
print(pad + key);
printObject(val, level + 1);
}
Expand Down

0 comments on commit 97c2da0

Please sign in to comment.