more cleanup
This commit is contained in:
Родитель
6f89b5b815
Коммит
379dfa87ba
|
@ -1,7 +1,4 @@
|
|||
namespace jacdac {
|
||||
// common logging level for jacdac services
|
||||
export let consolePriority = ConsolePriority.Debug;
|
||||
|
||||
export const BUTTON_EVENTS: number[] = [
|
||||
DAL.DEVICE_BUTTON_EVT_CLICK,
|
||||
DAL.DEVICE_BUTTON_EVT_LONG_CLICK,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
namespace jacdac {
|
||||
export class LoggerHost extends Host {
|
||||
private _lastListenerTime: number = 0;
|
||||
minPriority = LoggerPriority.Error + 1;
|
||||
minPriority = LoggerPriority.Silent;
|
||||
|
||||
constructor() {
|
||||
super("conh", SRV_LOGGER);
|
||||
|
@ -44,7 +44,8 @@ namespace jacdac {
|
|||
}
|
||||
|
||||
add(priority: LoggerPriority, message: string): void {
|
||||
if (!message || !message.length || priority < this.minPriority || !this._lastListenerTime)
|
||||
if (!message || !message.length || priority < this.minPriority
|
||||
|| !this._lastListenerTime)
|
||||
return;
|
||||
|
||||
// no one listening?
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace jacdac {
|
||||
export class LoggerClient extends Client {
|
||||
minPriority = LoggerPriority.Error + 1; // drop all packets by default
|
||||
minPriority = LoggerPriority.Silent; // drop all packets by default
|
||||
|
||||
onMessageReceived: (priority: number, dev: Device, message: string) => void;
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace jacdac {
|
|||
onAnnounce(() => {
|
||||
// on every announce, if we're listening to anything, tell
|
||||
// everyone to log
|
||||
if (this.minPriority <= LoggerPriority.Error) {
|
||||
if (this.minPriority < LoggerPriority.Silent) {
|
||||
const SetMinPriority = 0x2000 | LoggerReg.MinPriority
|
||||
JDPacket.jdpacked(SetMinPriority, "i32", [this.minPriority])
|
||||
.sendAsMultiCommand(this.serviceClass)
|
||||
|
|
|
@ -7,7 +7,4 @@ namespace modules {
|
|||
export function start() {
|
||||
jacdac.start();
|
||||
}
|
||||
|
||||
export function setLoggerVerbosity(verbosity: jacdac.LoggerPriority) {
|
||||
}
|
||||
}
|
13
routing.ts
13
routing.ts
|
@ -9,6 +9,8 @@ identification service - led blinking
|
|||
|
||||
namespace jacdac {
|
||||
const devNameSettingPrefix = "#jddev:"
|
||||
// common logging level for jacdac services
|
||||
export let consolePriority = ConsolePriority.Debug;
|
||||
|
||||
let _hostServices: Host[]
|
||||
let _unattachedClients: Client[]
|
||||
|
@ -23,7 +25,7 @@ namespace jacdac {
|
|||
let restartCounter = 0
|
||||
|
||||
function log(msg: string) {
|
||||
console.add(jacdac.consolePriority, msg);
|
||||
console.add(consolePriority, msg);
|
||||
}
|
||||
|
||||
//% fixedInstances
|
||||
|
@ -220,10 +222,10 @@ namespace jacdac {
|
|||
}
|
||||
|
||||
protected log(text: string) {
|
||||
if (this.supressLog || jacdac.consolePriority < console.minPriority)
|
||||
if (this.supressLog || consolePriority < console.minPriority)
|
||||
return
|
||||
let dev = selfDevice().toString()
|
||||
console.add(jacdac.consolePriority, `${dev}:${this.serviceClass}>${this.name}>${text}`);
|
||||
console.add(consolePriority, `${dev}:${this.serviceClass}>${this.name}>${text}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,11 +405,11 @@ namespace jacdac {
|
|||
}
|
||||
|
||||
protected log(text: string) {
|
||||
if (this.supressLog || jacdac.consolePriority < console.minPriority)
|
||||
if (this.supressLog || consolePriority < console.minPriority)
|
||||
return
|
||||
let dev = selfDevice().toString()
|
||||
let other = this.device ? this.device.toString() : "<unbound>"
|
||||
console.add(jacdac.consolePriority, `${dev}/${other}:${this.serviceClass}>${this.name}>${text}`);
|
||||
console.add(consolePriority, `${dev}/${other}:${this.serviceClass}>${this.name}>${text}`);
|
||||
}
|
||||
|
||||
start() {
|
||||
|
@ -896,6 +898,7 @@ namespace jacdac {
|
|||
loggerHost.add(pri as number, msg);
|
||||
});
|
||||
loggerHost.start()
|
||||
log("jacdac started")
|
||||
}
|
||||
|
||||
export function autoBind() {
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
jacdac.consolePriority = ConsolePriority.Log;
|
||||
jacdac.settingsHost.start()
|
||||
jacdac.start()
|
||||
|
|
2
test.ts
2
test.ts
|
@ -35,7 +35,7 @@ function jdpackTest() {
|
|||
}
|
||||
|
||||
// pins.A9.digitalWrite(false)
|
||||
jacdac.consolePriority = ConsolePriority.Warning;
|
||||
jacdac.consolePriority = ConsolePriority.Log;
|
||||
jacdac.roleManagerHost.start()
|
||||
jacdac.protoTestHost.start()
|
||||
jacdac.start()
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
jacdac.consolePriority = ConsolePriority.Log;
|
||||
jacdac.start()
|
||||
modules.thermometer.temperature(TemperatureUnit.Celsius)
|
Загрузка…
Ссылка в новой задаче