DGP - Fix to non-bulk densities
[debian/openrocket] / src / net / sf / openrocket / logging / StandardOutputLogger.java
1 package net.sf.openrocket.logging;
2
3 import java.io.PrintStream;
4
5 public class StandardOutputLogger extends LogHelper {
6
7         private static final PrintStream[] output;
8         static {
9                 LogLevel[] levels = LogLevel.values();
10                 
11                 output = new PrintStream[levels.length];
12                 for (int i=0; i<levels.length; i++) {
13                         if (levels[i].atLeast(LogLevel.WARN))
14                                 output[i] = System.err;
15                         else
16                                 output[i] = System.out;
17                 }
18         }
19         
20         
21         @Override
22         public void log(LogLine line) {
23                 PrintStream stream = output[line.getLevel().ordinal()];
24                 if (stream != null) {
25                         stream.println(line.toString());
26                 }
27         }
28
29         
30         public void setOutput(LogLevel level, PrintStream stream) {
31                 if (level == null || stream == null) {
32                         throw new IllegalArgumentException("level="+level+" stream="+stream);
33                 }
34                 output[level.ordinal()] = stream;
35         }
36         
37 }