use of lucee.runtime.db.ClassDefinition in project Lucee by lucee.
the class ApplicationContextSupport method initLog.
public static Map<Collection.Key, Pair<Log, Struct>> initLog(Struct sct) {
Map<Collection.Key, Pair<Log, Struct>> rtn = new ConcurrentHashMap<Collection.Key, Pair<Log, Struct>>();
if (sct == null)
return rtn;
Iterator<Entry<Key, Object>> it = sct.entryIterator();
Entry<Key, Object> e;
Struct v;
int k;
Collection.Key name;
LoggerAndSourceData las;
while (it.hasNext()) {
e = it.next();
name = e.getKey();
v = Caster.toStruct(e.getValue(), null);
if (v == null)
continue;
// raw way
Struct sctApp = Caster.toStruct(v.get("appender", null), null);
ClassDefinition cdApp = toClassDefinition(sctApp, null, true, false);
Struct sctLay = Caster.toStruct(v.get("layout", null), null);
ClassDefinition cdLay = toClassDefinition(sctLay, null, false, true);
if (cdApp != null && cdApp.hasClass()) {
// level
String strLevel = Caster.toString(v.get("level", null), null);
if (StringUtil.isEmpty(strLevel, true))
Caster.toString(v.get("loglevel", null), null);
Level level = Log4jUtil.toLevel(StringUtil.trim(strLevel, ""), Level.ERROR);
Struct sctAppArgs = Caster.toStruct(sctApp.get("arguments", null), null);
Struct sctLayArgs = Caster.toStruct(sctLay.get("arguments", null), null);
boolean readOnly = Caster.toBooleanValue(v.get("readonly", null), false);
// ignore when no appender/name is defined
if (!StringUtil.isEmpty(name)) {
Map<String, String> appArgs = toMap(sctAppArgs);
if (cdLay != null && cdLay.hasClass()) {
Map<String, String> layArgs = toMap(sctLayArgs);
las = addLogger(name, level, cdApp, appArgs, cdLay, layArgs, readOnly);
} else
las = addLogger(name, level, cdApp, appArgs, null, null, readOnly);
rtn.put(name, new Pair<Log, Struct>(las.getLog(), v));
}
}
}
return rtn;
}
Aggregations