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

1  
svoid vmBus_snoopToPrint(IPred<S> shouldPrintMsg) {
2  
  assertNotNull(shouldPrintMsg);
3  
  
4  
  vmBus_snoopToPrint((msg, arg) -> shouldPrintMsg.get(msg));
5  
}
6  
7  
svoid vmBus_snoopToPrint(IF2<S, O, Bool> shouldPrintMsgWithArgs) {
8  
  assertNotNull(shouldPrintMsgWithArgs);
9  
  
10  
  ownResource(vmBus_onAnyMessage(voidfunc(S msg, O _arg) pcall {
11  
    O arg = _arg;
12  
    if (!shouldPrintMsgWithArgs.get(msg, arg)) ret;
13  
    if (arg instanceof O[]) arg = joinWithComma(allToString((O[]) arg));
14  
    S s = msg + (arg == null ? "" : " | " + arg);
15  
    print(localTimeWithSeconds() + " " + shorten(s, 200));
16  
  }));
17  
}

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: 153 / 233
Version history: 2 change(s)
Referenced in: [show references]