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

19
LINES

< > BotCompany Repo | #1006461 // logOutput2 - logs all program output to disk in a text file per session

JavaX fragment (include)

static void logOutput2() {
  File _logFile = null;
  while licensed {
    _logFile = getProgramFile(ymd() + "-" + hms() + ".txt");
    if (_logFile.exists()) sleep(50); else break;
  }
  final File logFile = _logFile;
  
  set(getJavaX(), "customSystemOut", new Appendable() {
    // only using this one
    public Appendable append(CharSequence cs) {
      appendToTextFile(logFile, cs.toString());
      return this;
    }

    public Appendable append(char c) { return this; }
    public Appendable append(CharSequence s, int start, int end) { return this; }
  });
}

Author comment

Began life as a copy of #1002226

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006461
Snippet name: logOutput2 - logs all program output to disk in a text file per session
Eternal ID of this version: #1006461/1
Text MD5: 1c351c2857221298ff18a4cf0226bd41
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-01-05 15:23:39
Source code size: 587 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 646 / 557
Referenced in: [show references]