Javolution 6.0.0 java
javolution.osgi.internal.LogServiceImpl Class Reference
Inheritance diagram for javolution.osgi.internal.LogServiceImpl:
[legend]
Collaboration diagram for javolution.osgi.internal.LogServiceImpl:
[legend]

Classes

class  LogEvent
 

Public Member Functions

 LogServiceImpl ()
 
void log (int level, String message)
 
void log (int level, String message, Throwable exception)
 
void log (ServiceReference sr, int level, String message)
 
void log (ServiceReference sr, int level, String message, Throwable exception)
 
void run ()
 

Private Attributes

final FastTable< LogEventeventQueue = new FastTable<LogEvent>()
 

Detailed Description

Holds the default implementation of LogService to be used when running outside OSGi or when the Javolution bundle is not started.

Definition at line 20 of file LogServiceImpl.java.

Constructor & Destructor Documentation

◆ LogServiceImpl()

javolution.osgi.internal.LogServiceImpl.LogServiceImpl ( )

Definition at line 30 of file LogServiceImpl.java.

30  {
31  super("Logging-Thread");
32  setDaemon(true);
33  this.start();
34  Thread hook = new Thread(new Runnable() {
35  @Override
36  public void run() { // Maintains the VM alive until the event queue is flushed
37  synchronized (eventQueue) {
38  try {
39  while (!eventQueue.isEmpty())
40  eventQueue.wait();
41  } catch (InterruptedException e) {}
42  }
43  }
44  });
45  Runtime.getRuntime().addShutdownHook(hook);
46  }

References javolution.osgi.internal.LogServiceImpl.eventQueue, and javolution.osgi.internal.LogServiceImpl.run().

Here is the call graph for this function:

Member Function Documentation

◆ log() [1/4]

void javolution.osgi.internal.LogServiceImpl.log ( int  level,
String  message 
)

Definition at line 49 of file LogServiceImpl.java.

49  {
50  log(level, message, null);
51  }

◆ log() [2/4]

void javolution.osgi.internal.LogServiceImpl.log ( int  level,
String  message,
Throwable  exception 
)

Definition at line 54 of file LogServiceImpl.java.

54  {
55  LogEvent event = new LogEvent();
56  event.level = level;
57  event.message = message;
58  event.exception = exception;
59  synchronized (eventQueue) {
60  eventQueue.addFirst(event);
61  eventQueue.notify();
62  }
63  }

References javolution.osgi.internal.LogServiceImpl.eventQueue.

◆ log() [3/4]

void javolution.osgi.internal.LogServiceImpl.log ( ServiceReference  sr,
int  level,
String  message 
)

Definition at line 67 of file LogServiceImpl.java.

67  {
68  throw new UnsupportedOperationException();
69  }

◆ log() [4/4]

void javolution.osgi.internal.LogServiceImpl.log ( ServiceReference  sr,
int  level,
String  message,
Throwable  exception 
)

Definition at line 73 of file LogServiceImpl.java.

74  {
75  throw new UnsupportedOperationException();
76  }

◆ run()

void javolution.osgi.internal.LogServiceImpl.run ( )

Definition at line 79 of file LogServiceImpl.java.

79  {
80  while (true) {
81  try {
82  LogEvent event;
83  synchronized (eventQueue) {
84  while (eventQueue.isEmpty())
85  eventQueue.wait();
86  event = eventQueue.pollLast();
87  eventQueue.notify();
88  }
89  switch (event.level) {
90  case LogService.LOG_DEBUG:
91  System.out.println("[DEBUG] " + event.message);
92  break;
93  case LogService.LOG_INFO:
94  System.out.println("[INFO] " + event.message);
95  break;
96  case LogService.LOG_WARNING:
97  System.out.println("[WARNING] " + event.message);
98  break;
99  case LogService.LOG_ERROR:
100  System.out.println("[ERROR] " + event.message);
101  break;
102  default:
103  System.out.println("[UNKNOWN] " + event.message);
104  break;
105  }
106  if (event.exception != null) {
107  event.exception.printStackTrace(System.out);
108  }
109  } catch (InterruptedException error) {
110  error.printStackTrace(System.err);
111  }
112  }
113  }

References javolution.osgi.internal.LogServiceImpl.eventQueue, javolution.osgi.internal.LogServiceImpl.LogEvent.exception, javolution.osgi.internal.LogServiceImpl.LogEvent.level, and javolution.osgi.internal.LogServiceImpl.LogEvent.message.

Referenced by javolution.osgi.internal.LogServiceImpl.LogServiceImpl().

Here is the caller graph for this function:

Member Data Documentation

◆ eventQueue

final FastTable<LogEvent> javolution.osgi.internal.LogServiceImpl.eventQueue = new FastTable<LogEvent>()
private

The documentation for this class was generated from the following file:
javolution.osgi.internal.LogServiceImpl.eventQueue
final FastTable< LogEvent > eventQueue
Definition: LogServiceImpl.java:28
javolution.osgi.internal.LogServiceImpl.run
void run()
Definition: LogServiceImpl.java:79
javolution.osgi.internal.LogServiceImpl.log
void log(int level, String message)
Definition: LogServiceImpl.java:49
Thread