Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1031160 // vmBus_snoopToPrint

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2911L/17K).

svoid vmBus_snoopToPrint(IPred<S> shouldPrintMsg) {
  assertNotNull(shouldPrintMsg);
  
  vmBus_snoopToPrint((msg, arg) -> shouldPrintMsg.get(msg));
}

svoid vmBus_snoopToPrint(IF2<S, O, Bool> shouldPrintMsgWithArgs) {
  assertNotNull(shouldPrintMsgWithArgs);
  
  ownResource(vmBus_onAnyMessage(voidfunc(S msg, O _arg) pcall {
    O arg = _arg;
    if (!shouldPrintMsgWithArgs.get(msg, arg)) ret;
    if (arg instanceof O[]) arg = joinWithComma(allToString((O[]) arg));
    S s = msg + (arg == null ? "" : " | " + arg);
    print(localTimeWithSeconds() + " " + shorten(s, 200));
  }));
}

Author comment

Began life as a copy of #1019633

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031160
Snippet name: vmBus_snoopToPrint
Eternal ID of this version: #1031160/3
Text MD5: f4e0cb8feb674e0dee91a5c7cf0c5f15
Transpilation MD5: 9e3f1b82dc586b36b0fbad5c7ff8c049
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-14 16:37:55
Source code size: 604 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 95 / 149
Version history: 2 change(s)
Referenced in: [show references]