MCPcopy Index your code
hub / github.com/benfry/processing4 / startup

Method startup

app/src/processing/app/Console.java:71–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69
70
71 static public void startup() {
72 if (systemOut != null) {
73 // TODO fix this dreadful style choice in how the Console is initialized
74 // (This is not good code.. startup() should gracefully deal with this.
75 // It's just a low priority relative to the likelihood of trouble.)
76 new Exception("startup() called more than once").printStackTrace(systemErr);
77 return;
78 }
79 systemOut = System.out;
80 systemErr = System.err;
81
82 // placing everything inside a try block because this can be a dangerous
83 // time for the lights to blink out and crash for and obscure reason.
84 try {
85 SimpleDateFormat formatter = new SimpleDateFormat("yyMMdd_HHmmss");
86 // Moving away from a random string in 0256 (and adding hms) because
87 // the random digits looked like times anyway, causing confusion.
88 final String stamp = formatter.format(new Date());
89
90 File consoleDir = Base.getSettingsFile("console");
91 if (!consoleDir.exists()) {
92 consoleDir.mkdirs();
93 consoleDir.setWritable(true, false);
94 }
95
96 File outFile = new File(consoleDir, stamp + ".out");
97 outFile.setWritable(true, false);
98 stdoutFile = new FileOutputStream(outFile);
99 File errFile = new File(consoleDir, stamp + ".err");
100 errFile.setWritable(true, false);
101 stderrFile = new FileOutputStream(errFile);
102
103 consoleOut = new PrintStream(new ConsoleStream(false));
104 consoleErr = new PrintStream(new ConsoleStream(true));
105
106 System.setOut(consoleOut);
107 System.setErr(consoleErr);
108
109 } catch (Exception e) {
110 stdoutFile = null;
111 stderrFile = null;
112
113 consoleOut = null;
114 consoleErr = null;
115
116 System.setOut(systemOut);
117 System.setErr(systemErr);
118
119 e.printStackTrace();
120 }
121 }
122
123
124 static public void cleanTempFiles() {

Callers 1

createAndShowGUIMethod · 0.95

Calls 3

getSettingsFileMethod · 0.95
formatMethod · 0.65
printStackTraceMethod · 0.45

Tested by

no test coverage detected