Skip to content

Commit

Permalink
Merge pull request #1274 from zspitzer/improve-scope-logging
Browse files Browse the repository at this point in the history
scope logging, change sql to debug, simple to info LDEV-3084
  • Loading branch information
michaeloffner authored Apr 12, 2021
2 parents 313f192 + c26413e commit 3b750a8
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
12 changes: 6 additions & 6 deletions core/src/main/java/lucee/runtime/type/scope/ScopeContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ else if ("memory".equals(storage)) {
client.setStorage(storage);
context.put(pc.getCFID(), client);
}
else getLog().log(Log.LEVEL_DEBUG, "scope-context", "use existing client scope for " + appContext.getName() + "/" + pc.getCFID() + " from storage " + storage);
else getLog().log(Log.LEVEL_INFO, "scope-context", "use existing client scope for " + appContext.getName() + "/" + pc.getCFID() + " from storage " + storage);

client.touchBeforeRequest(pc);
return client;
Expand Down Expand Up @@ -646,7 +646,7 @@ else if ("file".equals(storage)) {
isNew.setValue(true);
}
else {
getLog().log(Log.LEVEL_DEBUG, "scope-context", "use existing session scope for " + appContext.getName() + "/" + pc.getCFID() + " from storage " + storage);
getLog().log(Log.LEVEL_INFO, "scope-context", "use existing session scope for " + appContext.getName() + "/" + pc.getCFID() + " from storage " + storage);
}
session.touchBeforeRequest(pc);
return session;
Expand Down Expand Up @@ -727,7 +727,7 @@ private Session getJSessionScope(PageContext pc, RefBoolean isNew) throws PageEx
if (jSession.isExpired()) {
jSession.touch();
}
debug(getLog(), "use existing JSession for " + appContext.getName() + "/" + pc.getCFID());
info(getLog(), "use existing JSession for " + appContext.getName() + "/" + pc.getCFID());

}
catch (ClassCastException cce) {
Expand All @@ -744,7 +744,7 @@ private Session getJSessionScope(PageContext pc, RefBoolean isNew) throws PageEx
// if there is no HTTPSession
if (httpSession == null) return getCFSessionScope(pc, isNew);

debug(getLog(), "create new JSession for " + appContext.getName() + "/" + pc.getCFID());
info(getLog(), "create new JSession for " + appContext.getName() + "/" + pc.getCFID());
jSession = new JSession();
httpSession.setAttribute(appContext.getName(), jSession);
isNew.setValue(true);
Expand Down Expand Up @@ -908,7 +908,7 @@ private void storeUnusedStorageScope(CFMLFactoryImpl cfmlFactory, int type) {
StorageScope scope = (StorageScope) o;
if (scope.lastVisit() + timespan < now && !(scope instanceof MemoryScope)) {
getLog().log(Log.LEVEL_INFO, "scope-context",
"remove from memory " + strType + " scope for " + applicationName + "/" + cfid + " from storage " + scope.getStorage());
"remove from memory [" + strType + "] scope for [" + applicationName + "/" + cfid + "] from storage [" + scope.getStorage() + "]");

fhm.remove(arrClients[y]);
count--;
Expand Down Expand Up @@ -967,7 +967,7 @@ private void clearUnusedMemoryScope(CFMLFactoryImpl cfmlFactory, int type) {
fhm.remove(cfids[y]);
scope.release(ThreadLocalPageContext.get());
getLog().log(Log.LEVEL_INFO, "scope-context",
"remove memory based " + VariableInterpreter.scopeInt2String(type) + " scope for " + applicationName + "/" + cfid);
"remove memory based " + VariableInterpreter.scopeInt2String(type) + " scope for [" + applicationName + "/" + cfid + "]");
count--;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ public IKStorageValue loadData(PageContext pc, String appName, String name, Stri
synchronized (StorageScopeCache.getToken(key)) { // sync necessary?
Object val = cache.getValue(key, null);
if (val instanceof byte[][]) {
ScopeContext.debug(log,
ScopeContext.info(log,
"load existing data from cache [" + name + "] to create " + strType + " scope for " + pc.getApplicationContext().getName() + "/" + pc.getCFID());
return new IKStorageValue((byte[][]) val);
}
else if (val instanceof IKStorageValue) {
ScopeContext.debug(log,
ScopeContext.info(log,
"load existing data from cache [" + name + "] to create " + strType + " scope for " + pc.getApplicationContext().getName() + "/" + pc.getCFID());
return (IKStorageValue) val;
}
else {
ScopeContext.debug(log, "create new " + strType + " scope for " + pc.getApplicationContext().getName() + "/" + pc.getCFID() + " in cache [" + name + "]");
ScopeContext.info(log, "create new " + strType + " scope for " + pc.getApplicationContext().getName() + "/" + pc.getCFID() + " in cache [" + name + "]");
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public IKStorageValue loadData(PageContext pc, String appName, String name, Stri

try {
IKStorageValue data = (IKStorageValue) JavaConverter.deserialize(str);
ScopeContext.debug(log, "load existing data from [" + name + "." + PREFIX + "_" + strType + "_data] to create " + strType + " scope for "
ScopeContext.info(log, "load existing data from [" + name + "." + PREFIX + "_" + strType + "_data] to create " + strType + " scope for "
+ pc.getApplicationContext().getName() + "/" + pc.getCFID());
return data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,9 @@ public static Scope getInstance(int scope, IKHandler handler, String appName, St

public static boolean hasInstance(int scope, IKHandler handler, String appName, String name, PageContext pc) {
try {
if (Scope.SCOPE_SESSION == scope) return handler.loadData(pc, appName, name, "session", Scope.SCOPE_SESSION, null) != null;
else if (Scope.SCOPE_CLIENT == scope) return handler.loadData(pc, appName, name, "client", Scope.SCOPE_CLIENT, null) != null;
Log log = ThreadLocalPageContext.getConfig(pc).getLog("scope");
if (Scope.SCOPE_SESSION == scope) return handler.loadData(pc, appName, name, "session", Scope.SCOPE_SESSION, log) != null;
else if (Scope.SCOPE_CLIENT == scope) return handler.loadData(pc, appName, name, "client", Scope.SCOPE_CLIENT, log) != null;
return false;
}
catch (PageException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ protected static StorageValue _loadData(PageContext pc, String cacheName, String
Object val = cache.getValue(key, null);

if (val instanceof StorageValue) {
ScopeContext.debug(log,
ScopeContext.info(log,
"load existing data from cache [" + cacheName + "] to create " + strType + " scope for " + pc.getApplicationContext().getName() + "/" + pc.getCFID());
return (StorageValue) val;
}
else {
ScopeContext.debug(log, "create new " + strType + " scope for " + pc.getApplicationContext().getName() + "/" + pc.getCFID() + " in cache [" + cacheName + "]");
ScopeContext.info(log, "create new " + strType + " scope for " + pc.getApplicationContext().getName() + "/" + pc.getCFID() + " in cache [" + cacheName + "]");
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected static Struct _loadData(PageContext pc, String datasourceName, String
boolean _isNew = query.getRecordcount() == 0;

if (_isNew) {
ScopeContext.debug(log,
ScopeContext.info(log,
"create new " + strType + " scope for " + pc.getApplicationContext().getName() + "/" + pc.getCFID() + " in datasource [" + datasourceName + "]");
return null;
}
Expand All @@ -128,7 +128,7 @@ protected static Struct _loadData(PageContext pc, String datasourceName, String

try {
Struct s = (Struct) pc.evaluate(str);
ScopeContext.debug(log, "load existing data from [" + datasourceName + "." + PREFIX + "_" + strType + "_data] to create " + strType + " scope for "
ScopeContext.info(log, "load existing data from [" + datasourceName + "." + PREFIX + "_" + strType + "_data] to create " + strType + " scope for "
+ pc.getApplicationContext().getName() + "/" + pc.getCFID());
return s;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public Query select(Config config, String cfid, String applicationName, Datasour
query = new QueryImpl(pc, dc, sqlSelect, -1, -1, null, scopeName + "_storage");
}

ScopeContext.info(log, sqlSelect.toString());
ScopeContext.debug(log, sqlSelect.toString());
return query;
}

Expand All @@ -158,7 +158,7 @@ private static int _update(Config config, Connection conn, String cfid, String a
throws SQLException, PageException {
SQLImpl sql = new SQLImpl(strSQL, new SQLItem[] { new SQLItemImpl(createExpires(config, timeSpan), Types.VARCHAR),
new SQLItemImpl(serialize(data, ignoreSet), Types.VARCHAR), new SQLItemImpl(cfid, Types.VARCHAR), new SQLItemImpl(applicationName, Types.VARCHAR) });
ScopeContext.info(log, sql.toString());
ScopeContext.debug(log, sql.toString());

return execute(null, conn, sql, tz);
}
Expand All @@ -181,7 +181,7 @@ public void delete(Config config, String cfid, String applicationName, Datasourc
String strSQL = "DELETE FROM " + PREFIX + "_" + strType + "_data WHERE cfid=? AND name=?";
SQLImpl sql = new SQLImpl(strSQL, new SQLItem[] { new SQLItemImpl(cfid, Types.VARCHAR), new SQLItemImpl(applicationName, Types.VARCHAR) });
execute(null, dc.getConnection(), sql, ThreadLocalPageContext.getTimeZone());
ScopeContext.info(log, sql.toString());
ScopeContext.debug(log, sql.toString());

}

Expand Down

0 comments on commit 3b750a8

Please sign in to comment.