This commit is contained in:
pelikhan 2020-12-16 22:36:59 +01:00
Родитель 6f89b5b815
Коммит 379dfa87ba
8 изменённых файлов: 14 добавлений и 18 удалений

Просмотреть файл

@ -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) {
}
}

Просмотреть файл

@ -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()

Просмотреть файл

@ -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)