Javolution 6.0.0 java
LogContext.java
Go to the documentation of this file.
1 /*
2  * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
3  * Copyright (C) 2012 - Javolution (http://javolution.org/)
4  * All rights reserved.
5  *
6  * Permission to use, copy, modify, and distribute this software is
7  * freely granted, provided that this notice is preserved.
8  */
9 package javolution.context;
10 
14 
56 public abstract class LogContext extends AbstractContext {
57 
61  public enum Level {
62 
63  DEBUG, INFO, WARNING, ERROR, FATAL
64 
65  }
66 
73  public static final Configurable<Level> LEVEL = new Configurable<Level>() {
74  @Override
75  protected Level getDefault() {
76  return Level.DEBUG;
77  }
78  @Override
79  public Level parse(String str) {
80  return Level.valueOf(str);
81  }
82  };
83 
87  public static void debug(Object... message) {
88  currentLogContext().log(Level.DEBUG, message);
89  }
90 
94  public static LogContext enter() {
96  }
97 
102  public static void error(Object... message) {
103  currentLogContext().log(Level.ERROR, message);
104  }
105 
109  public static void info(Object... message) {
110  currentLogContext().log(Level.INFO, message);
111  }
112 
116  public static void warning(Object... message) {
117  currentLogContext().log(Level.WARNING, message);
118  }
119 
120  private static LogContext currentLogContext() {
121  LogContext ctx = current(LogContext.class);
122  if (ctx != null)
123  return ctx;
124  return OSGiServices.getLogContext();
125  }
126 
130  protected LogContext() {}
131 
136  public abstract void prefix(Object... prefixes);
137 
141  public abstract void setLevel(Level level);
142 
147  public abstract void suffix(Object... suffixes);
148 
152  protected abstract void log(Level level, Object... message);
153 
154 }
javolution.context.LogContext.currentLogContext
static LogContext currentLogContext()
Definition: LogContext.java:120
javolution.context.LogContext
Definition: LogContext.java:56
javolution
javolution.lang.Configurable
Definition: Configurable.java:78
javolution.context.LogContext.log
abstract void log(Level level, Object... message)
javolution.context.LogContext.info
static void info(Object... message)
Definition: LogContext.java:109
javolution.context.LogContext.Level.ERROR
ERROR
Definition: LogContext.java:63
javolution.osgi.internal.OSGiServices.getLogContext
static LogContext getLogContext()
Definition: OSGiServices.java:89
javolution.context.LogContext.debug
static void debug(Object... message)
Definition: LogContext.java:87
javolution.context.LogContext.LEVEL
static final Configurable< Level > LEVEL
Definition: LogContext.java:73
javolution.context.LogContext.LogContext
LogContext()
Definition: LogContext.java:130
javolution.context.LogContext.warning
static void warning(Object... message)
Definition: LogContext.java:116
javolution.lang
Definition: Configurable.java:9
javolution.text
Definition: CharArray.java:9
javolution.context.AbstractContext
Definition: AbstractContext.java:40
javolution.context.LogContext.suffix
abstract void suffix(Object... suffixes)
javolution.context.LogContext.Level
Definition: LogContext.java:61
javolution.context.AbstractContext.current
static AbstractContext current()
Definition: AbstractContext.java:61
javolution.context.LogContext.error
static void error(Object... message)
Definition: LogContext.java:102
javolution.context.LogContext.Level.INFO
INFO
Definition: LogContext.java:63
javolution.context.AbstractContext.enterInner
AbstractContext enterInner()
Definition: AbstractContext.java:141
javolution.context.LogContext.prefix
abstract void prefix(Object... prefixes)
javolution.osgi.internal
Definition: ConfigurableListenerImpl.java:9
javolution.context.LogContext.Level.DEBUG
DEBUG
Definition: LogContext.java:63
javolution.osgi.internal.OSGiServices
Definition: OSGiServices.java:50
javolution.osgi
javolution.context.LogContext.setLevel
abstract void setLevel(Level level)
javolution.context.LogContext.enter
static LogContext enter()
Definition: LogContext.java:94
javolution.text.TextContext
Definition: TextContext.java:49
javolution.context.LogContext.Level.WARNING
WARNING
Definition: LogContext.java:63