ch.qos.logback.classic.db.names.ColumnName Java Examples
The following examples show how to use
ch.qos.logback.classic.db.names.ColumnName.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DBLogReader.java From background-geolocation-android with Apache License 2.0 | 6 votes |
private Collection<String> getStackTrace(int logEntryId) throws SQLException { Collection<String> stackTrace = new ArrayList(); SQLiteDatabase db = openDatabase(); Cursor cursor = null; try { DefaultDBNameResolver dbNameResolver = getDbNameResolver(); QueryBuilder qb = new QueryBuilder(dbNameResolver); cursor = mDatabase.rawQuery(qb.buildStackTraceQuery(logEntryId), new String[] {}); while (cursor.moveToNext()) { stackTrace.add(cursor.getString(cursor.getColumnIndex(dbNameResolver.getColumnName(ColumnName.TRACE_LINE)))); } } catch (SQLiteException e) { throw new SQLException("Cannot retrieve log entries", e); } finally { if (cursor != null) { cursor.close(); } } return stackTrace; }
Example #2
Source File: DBLogReader.java From background-geolocation-android with Apache License 2.0 | 5 votes |
public String buildStackTraceQuery(int eventId) { SqlSelectStatement builder = new SqlSelectStatement(); builder.column(mDbNameResolver.getColumnName(ColumnName.TRACE_LINE)); builder.from(mDbNameResolver.getTableName(TableName.LOGGING_EVENT_EXCEPTION)); builder.where(mDbNameResolver.getColumnName(ColumnName.I), SqlExpression.SqlOperatorEqualTo, Integer.valueOf(eventId)); builder.orderBy(mDbNameResolver.getColumnName(ColumnName.I)); return builder.statement(); }
Example #3
Source File: DBLogReader.java From background-geolocation-android with Apache License 2.0 | 5 votes |
public String buildQuery(int limit, int fromLogEntryId, Level minLevel) { SqlSelectStatement builder = new SqlSelectStatement(); builder.columns(new String[]{ mDbNameResolver.getColumnName(ColumnName.EVENT_ID), mDbNameResolver.getColumnName(ColumnName.TIMESTMP), mDbNameResolver.getColumnName(ColumnName.FORMATTED_MESSAGE), mDbNameResolver.getColumnName(ColumnName.LOGGER_NAME), mDbNameResolver.getColumnName(ColumnName.LEVEL_STRING), }); builder.from(mDbNameResolver.getTableName(TableName.LOGGING_EVENT)); builder.where(mDbNameResolver.getColumnName(ColumnName.LEVEL_STRING), SqlExpression.SqlOperatorIn, aboveLevel(minLevel)); if (fromLogEntryId > 0) { if (limit >= 0) { builder.where(mDbNameResolver.getColumnName(ColumnName.EVENT_ID), SqlExpression.SqlOperatorLessThan, fromLogEntryId); } else { builder.where(mDbNameResolver.getColumnName(ColumnName.EVENT_ID), SqlExpression.SqlOperatorGreaterThan, fromLogEntryId); } } if (limit < 0) { builder.orderBy(mDbNameResolver.getColumnName(ColumnName.TIMESTMP)); builder.orderBy(mDbNameResolver.getColumnName(ColumnName.EVENT_ID)); } else { builder.orderBy(mDbNameResolver.getColumnName(ColumnName.TIMESTMP), true); builder.orderBy(mDbNameResolver.getColumnName(ColumnName.EVENT_ID), true); } builder.limit(limit); return builder.statement(); }
Example #4
Source File: DBLogReader.java From background-geolocation-android with Apache License 2.0 | 5 votes |
private Collection<LogEntry> getDbEntries(int limit, int fromLogEntryId, Level minLevel) throws SQLException { Collection<LogEntry> entries = new ArrayList<LogEntry>(); SQLiteDatabase db = openDatabase(); Cursor cursor = null; try { DefaultDBNameResolver dbNameResolver = getDbNameResolver(); QueryBuilder qb = new QueryBuilder(dbNameResolver); cursor = db.rawQuery(qb.buildQuery(limit, fromLogEntryId, minLevel), new String[] {}); while (cursor.moveToNext()) { LogEntry entry = new LogEntry(); entry.setContext(0); entry.setId(cursor.getInt(cursor.getColumnIndex(mDbNameResolver.getColumnName(ColumnName.EVENT_ID)))); entry.setLevel(cursor.getString(cursor.getColumnIndex(dbNameResolver.getColumnName(ColumnName.LEVEL_STRING)))); entry.setMessage(cursor.getString(cursor.getColumnIndex(dbNameResolver.getColumnName(ColumnName.FORMATTED_MESSAGE)))); entry.setTimestamp(cursor.getLong(cursor.getColumnIndex(dbNameResolver.getColumnName(ColumnName.TIMESTMP)))); entry.setLoggerName(cursor.getString(cursor.getColumnIndex(dbNameResolver.getColumnName(ColumnName.LOGGER_NAME)))); if ("ERROR".equals(entry.getLevel())) { entry.setStackTrace(getStackTrace(entry.getId())); } entries.add(entry); } } catch (SQLiteException e) { throw new SQLException("Cannot retrieve log entries", e); } finally { if (cursor != null) { cursor.close(); } if (db != null) { db.close(); } } return entries; }
Example #5
Source File: JDBCSettingsDBNameResolverTest.java From qpid-broker-j with Apache License 2.0 | 4 votes |
@Test public void getColumnName() { assertEquals(ColumnName.LOGGER_NAME.name().toLowerCase(), _dbNameResolver.getColumnName(ColumnName.LOGGER_NAME)); }