EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.reliability.solver.helper]

COVERAGE SUMMARY FOR SOURCE FILE [LoggingHelper.java]

nameclass, %method, %block, %line, %
LoggingHelper.java0%   (0/1)0%   (0/5)0%   (0/87)0%   (0/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class LoggingHelper0%   (0/1)0%   (0/5)0%   (0/87)0%   (0/27)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/2)
LoggingHelper (): void 0%   (0/1)0%   (0/3)0%   (0/2)
createOrReferenceMessageConsole (): MessageConsole 0%   (0/1)0%   (0/45)0%   (0/10)
getSingletonInstance (): LoggingHelper 0%   (0/1)0%   (0/8)0%   (0/3)
initializeLogging (): void 0%   (0/1)0%   (0/28)0%   (0/10)

1package de.uka.ipd.sdq.reliability.solver.helper;
2 
3import org.apache.log4j.BasicConfigurator;
4import org.apache.log4j.Level;
5import org.apache.log4j.Logger;
6import org.apache.log4j.PatternLayout;
7import org.apache.log4j.WriterAppender;
8import org.eclipse.ui.console.ConsolePlugin;
9import org.eclipse.ui.console.IConsole;
10import org.eclipse.ui.console.MessageConsole;
11import org.eclipse.ui.console.MessageConsoleStream;
12 
13public class LoggingHelper {
14 
15        /**
16         * The singleton instance.
17         */
18        private static LoggingHelper singletonInstance = null;
19 
20        /**
21         * Retrieves the singleton instance.
22         * 
23         * @return the singleton instance
24         */
25        public static LoggingHelper getSingletonInstance() {
26                if (singletonInstance == null) {
27                        singletonInstance = new LoggingHelper();
28                }
29                return singletonInstance;
30        }
31 
32        /**
33         * Private constructor.
34         * 
35         * Prohibits external object creation.
36         */
37        private LoggingHelper() {
38        }
39 
40        /**
41         * Creates a new message console for the SimuService, or references an
42         * existing one.
43         * 
44         * @return the message console for the SimuService
45         */
46        private MessageConsole createOrReferenceMessageConsole() {
47 
48                // The name of the console:
49                String SimuServiceConsoleName = "PCM Reliability Solver: Markov Comparison";
50 
51                // If the console already exists, return a reference to the existing
52                // console:
53                for (IConsole console : ConsolePlugin.getDefault().getConsoleManager()
54                                .getConsoles()) {
55                        if (console.getName().equals(SimuServiceConsoleName)) {
56                                return (MessageConsole) console;
57                        }
58                }
59 
60                // Create a new console:
61                MessageConsole console = new MessageConsole(SimuServiceConsoleName,
62                                null);
63                ConsolePlugin.getDefault().getConsoleManager().addConsoles(
64                                new IConsole[] { console });
65                return console;
66        }
67 
68        /**
69         * Initializes the logging functionality.
70         * 
71         */
72        public void initializeLogging() {
73 
74                // Retrieve a message console for the logging:
75                MessageConsole console = createOrReferenceMessageConsole();
76                console.activate();
77                console.clearConsole();
78                MessageConsoleStream stream = console.newMessageStream();
79 
80                // Configure log4j:
81                PatternLayout myLayout = new PatternLayout("[%-10t] %-5p: %m%n");
82                WriterAppender writerAppender = new WriterAppender(myLayout, stream);
83                BasicConfigurator.resetConfiguration();
84                BasicConfigurator.configure(writerAppender);
85                Logger.getRootLogger().setLevel(Level.INFO);
86        }
87}

[all classes][de.uka.ipd.sdq.reliability.solver.helper]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov