本文整理汇总了Java中com.couchbase.lite.util.Log类的典型用法代码示例。如果您正苦于以下问题:Java Log类的具体用法?Java Log怎么用?Java Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Log类属于com.couchbase.lite.util包,在下文中一共展示了Log类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loginAsFacebookUser
import com.couchbase.lite.util.Log; //导入依赖的package包/类
public void loginAsFacebookUser(Activity activity, String token, String userId, String name) {
setCurrentUserId(userId);
setDatabase(getUserDatabase(userId));
String profileDocID = "p:" + userId;
Document profile = mDatabase.getExistingDocument(profileDocID);
if (profile == null) {
try {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("type", "profile");
properties.put("user_id", userId);
properties.put("name", name);
profile = mDatabase.getDocument(profileDocID);
profile.putProperties(properties);
// Migrate guest data to user:
UserProfile.migrateGuestData(getUserDatabase(GUEST_DATABASE_NAME), profile);
} catch (CouchbaseLiteException e) {
Log.e(TAG, "Cannot create a new user profile", e);
}
}
startReplication(AuthenticatorFactory.createFacebookAuthenticator(token));
login(activity);
}
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:27,代码来源:Application.java
示例2: addMember
import com.couchbase.lite.util.Log; //导入依赖的package包/类
private void addMember(Document user) {
Map<String, Object> properties = new HashMap<>();
properties.putAll(mList.getProperties());
List<String> members = (List<String>) properties.get("members");
if (members == null) {
members = new ArrayList<String>();
properties.put("members", members);
}
members.add(user.getId());
try {
mList.putProperties(properties);
} catch (CouchbaseLiteException e) {
Log.e(Application.TAG, "Cannot add member to the list", e);
}
}
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:18,代码来源:ShareActivity.java
示例3: createTask
import com.couchbase.lite.util.Log; //导入依赖的package包/类
private void createTask(String title, Bitmap image, String listId) {
String currentTimeString = mDateFormatter.format(new Date());
TaskEntity task = TaskEntity.create()
.setType("task")
.setCreatedAt(currentTimeString)
.setTitle(title)
.setChecked(Boolean.FALSE)
.setListId(listId);
if (image != null) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 50, out);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
task.setImage(in);
}
try {
task.save();
} catch (CouchbaseLiteException e) {
Log.e(Application.TAG, "Cannot create new task", e);
}
}
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:24,代码来源:TaskActivity.java
示例4: attachImage
import com.couchbase.lite.util.Log; //导入依赖的package包/类
private void attachImage(TaskEntity task, Bitmap image) {
if (task == null || image == null) return;
ByteArrayOutputStream out = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 50, out);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
task.setImage(in);
try {
task.save();
} catch (CouchbaseLiteException e) {
Log.e(Application.TAG, "Cannot attach image", e);
}
}
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:17,代码来源:TaskActivity.java
示例5: dispatchTakePhotoIntent
import com.couchbase.lite.util.Log; //导入依赖的package包/类
private void dispatchTakePhotoIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(this.getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException e) {
Log.e(Application.TAG, "Cannot create a temp image file", e);
}
if (photoFile != null) {
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
}
}
}
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:17,代码来源:TaskActivity.java
示例6: startListener
import com.couchbase.lite.util.Log; //导入依赖的package包/类
@ReactMethod
public void startListener() {
if (listener == null) {
if (allowedCredentials == null) {
Log.i(TAG, "No credentials, so binding to localhost");
Properties props = new Properties();
props.put(Serve.ARG_BINDADDRESS, "localhost");
listener = new LiteListener(manager, SUGGESTED_PORT, allowedCredentials, props);
} else {
listener = new LiteListener(manager, SUGGESTED_PORT, allowedCredentials);
}
Log.i(TAG, "Starting CBL listener on port " + listener.getListenPort());
} else {
Log.i(TAG, "Restarting CBL listener on port " + listener.getListenPort());
}
listener.start();
}
开发者ID:couchbaselabs,项目名称:react-native-couchbase-lite,代码行数:20,代码来源:ReactCBLite.java
示例7: onPostExecute
import com.couchbase.lite.util.Log; //导入依赖的package包/类
@Override
protected void onPostExecute(UploadResult uploadResult) {
int responseCode = uploadResult.statusCode;
WritableMap map = Arguments.createMap();
map.putInt("statusCode", responseCode);
if (responseCode == 200 || responseCode == 202) {
try {
JSONObject jsonObject = new JSONObject(uploadResult.response);
map.putMap("resp", convertJsonToMap(jsonObject));
callback.invoke(null, map);
} catch (JSONException e) {
map.putString("error", uploadResult.response);
callback.invoke(map, null);
Log.e(TAG, "Failed to parse response from clb: " + uploadResult.response, e);
}
} else {
map.putString("error", uploadResult.response);
callback.invoke(map, null);
}
}
开发者ID:couchbaselabs,项目名称:react-native-couchbase-lite,代码行数:22,代码来源:ReactCBLite.java
示例8: onKey
import com.couchbase.lite.util.Log; //导入依赖的package包/类
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN)
&& (keyCode == KeyEvent.KEYCODE_ENTER)) {
String inputText = addItemEditText.getText().toString();
// Don't do anything until our liveQuery is initialized.
if(!inputText.equals("") && liveQuery != null) {
try {
createListItem(inputText);
Toast.makeText(getApplicationContext(), "Created new list item!", Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Error creating document, see logs for details", Toast.LENGTH_LONG).show();
Log.e(TAG, "Error creating document.", e);
}
}
addItemEditText.setText("");
return true;
}
return false;
}
开发者ID:couchbaselabs,项目名称:mini-hacks,代码行数:22,代码来源:MainActivity.java
示例9: onItemClick
import com.couchbase.lite.util.Log; //导入依赖的package包/类
/**
* Handle click on item in list
*/
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
// Step 10 code goes here
// This code handles checkbox touches. Couchbase Lite documents are like versioned-maps.
// To change a Document, add a new Revision.
QueryRow row = (QueryRow) adapterView.getItemAtPosition(position);
Document document = row.getDocument();
Map<String, Object> newProperties = new HashMap<String, Object>(document.getProperties());
boolean checked = ((Boolean) newProperties.get("check")).booleanValue();
newProperties.put("check", !checked);
try {
document.putProperties(newProperties);
kitchenSyncArrayAdapter.notifyDataSetChanged();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Error updating database, see logs for details", Toast.LENGTH_LONG).show();
Log.e(TAG, "Error updating database", e);
}
}
开发者ID:couchbaselabs,项目名称:mini-hacks,代码行数:25,代码来源:MainActivity.java
示例10: getInfo
import com.couchbase.lite.util.Log; //导入依赖的package包/类
@Override
public String getInfo(String key) {
try {
byte[][] metaNbody = forest.rawGet("info", key);
return new String(metaNbody[1]);
} catch (ForestException e) {
// KEY NOT FOUND
if (e.domain == ForestDBDomain &&
e.code == FDBErrors.FDB_RESULT_KEY_NOT_FOUND) {
Log.i(TAG, "[getInfo()] Key(\"%s\") is not found.", key);
}
// UNEXPECTED ERROR
else {
Log.e(TAG, "[getInfo()] Unexpected Error", e);
}
return null;
}
}
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:19,代码来源:ForestDBStore.java
示例11: runInTransaction
import com.couchbase.lite.util.Log; //导入依赖的package包/类
/**
* @note Throw RuntimeException if TransactionalTask throw Exception.
* Otherwise return true or false
*/
@Override
public boolean runInTransaction(TransactionalTask task) {
if (inTransaction())
return task.run();
else {
if (!beginTransaction())
return false;
boolean commit = true;
try {
commit = task.run();
} catch (Exception e) {
commit = false;
Log.e(TAG, "[ForestDBStore.runInTransaction()] Error in TransactionalTask", e);
throw new RuntimeException(e);
} finally {
if (!endTransaction(commit))
return false;
}
return commit;
}
}
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:26,代码来源:ForestDBStore.java
示例12: _getDocument
import com.couchbase.lite.util.Log; //导入依赖的package包/类
/**
* @note return value should not be null.
*/
private Document _getDocument(String docID) throws CouchbaseLiteException {
Document doc;
try {
doc = forest.getDocument(docID, true);
} catch (ForestException e) {
Log.d(TAG, "ForestDB Warning: getDocument(docID, true) docID=[%s] error=[%s]",
docID, e.toString());
throw new CouchbaseLiteException(ForestBridge.err2status(e));
}
if (!doc.exists()) {
doc.free();
throw new CouchbaseLiteException(Status.NOT_FOUND);
}
return doc;
}
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:19,代码来源:ForestDBStore.java
示例13: getDocumentWithRetry
import com.couchbase.lite.util.Log; //导入依赖的package包/类
private Document getDocumentWithRetry(String docID, boolean mustExist, int retry)
throws ForestException {
ForestException ex = null;
for (int i = 0; i < retry; i++) {
try {
Document doc = forest.getDocument(docID, mustExist);
return doc;
} catch (ForestException fe) {
ex = fe;
if (fe.domain == ForestDBDomain && fe.code == FDB_RESULT_HANDLE_BUSY) {
try {
Thread.sleep(300); // 300ms
} catch (InterruptedException e) {
}
continue;
} else {
throw fe;
}
}
}
Log.e(TAG, "Retried %s times. But keep failing ForestDB.getDocument() docID=%s", ex, retry, docID);
throw ex;
}
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:25,代码来源:ForestDBStore.java
示例14: purgeExpiredDocuments
import com.couchbase.lite.util.Log; //导入依赖的package包/类
@Override
public int purgeExpiredDocuments() {
final AtomicInteger purged = new AtomicInteger();
runInTransaction(new TransactionalTask() {
@Override
public boolean run() {
try {
String[] docIDs = forest.purgeExpiredDocuments();
for (String docID : docIDs)
notifyPurgedDocument(docID);
purged.set(docIDs.length);
return true;
} catch (ForestException e) {
Log.e(TAG, "Error: purgeExpiredDocuments()", e);
return false;
}
}
});
return purged.get();
}
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:21,代码来源:ForestDBStore.java
示例15: dump
import com.couchbase.lite.util.Log; //导入依赖的package包/类
@Override
public List<Map<String, Object>> dump() {
try {
openIndex();
} catch (ForestException e) {
Log.e(TAG, "ERROR in openIndex()", e);
return null;
}
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
try {
QueryIterator itr = forestQuery(new QueryOptions());
while (itr.next()) {
Map<String, Object> dict = new HashMap<String, Object>();
dict.put("key", new String(itr.keyJSON()));
byte[] bytes = itr.valueJSON();
dict.put("value", fromJSON(bytes, Object.class));
dict.put("seq", itr.sequence());
result.add(dict);
}
} catch (Exception ex) {
Log.e(TAG, "Error in dump()", ex);
}
return result;
}
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:27,代码来源:ForestDBViewStore.java
示例16: closeIndex
import com.couchbase.lite.util.Log; //导入依赖的package包/类
/**
* in CBL_ForestDBViewStorage.mm
* - (void) closeIndex
*/
private void closeIndex() {
// TODO
//NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(closeIndex) object: nil];
// NOTE: view could be busy for indexing. as result, view.close() could fail.
// It requires to wait till view is not busy. CBL Java/Android waits maximum 10 seconds.
for (int i = 0; i < 100 && _view != null; i++) {
try {
_view.close();
_view = null;
} catch (ForestException e) {
Log.w(TAG, "Failed to close Index: [%s] [%s]", _view, Thread.currentThread().getName());
try {
Thread.sleep(100); // 100 ms (maximum wait time: 10sec)
} catch (Exception ex) {
}
}
}
}
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:24,代码来源:ForestDBViewStore.java
示例17: remoteURL
import com.couchbase.lite.util.Log; //导入依赖的package包/类
private URL remoteURL(HttpServletRequest req) {
String addr = req.getRemoteAddr();
Log.v(Log.TAG_LISTENER, "remoteURL() addr=" + addr);
if (!"127.0.0.1".equals(addr) && !"::1".equals(addr)) {
// IPv6
if (addr.indexOf(':') >= 0)
addr = String.format("[%s]", addr);
String username = allowedCredentials != null ? allowedCredentials.getLogin() : null;
String protocol = req.isSecure() ? "https" : "http";
String spec = null;
if(username != null && username.length() > 0)
spec = String.format("%s://%[email protected]%s/", protocol, username, addr);
else
spec = String.format("%s://%s/", protocol, addr);
try {
return new URL(spec);
} catch (MalformedURLException e) {
Log.w(Log.TAG_LISTENER, "failed to create remote URL", e);
return null;
}
}
return null;
}
开发者ID:couchbase,项目名称:couchbase-lite-java-listener,代码行数:25,代码来源:LiteServlet.java
示例18: getViewID
import com.couchbase.lite.util.Log; //导入依赖的package包/类
private int getViewID() {
if (viewID < 0) {
String sql = "SELECT view_id FROM views WHERE name=?";
String[] args = {name};
Cursor cursor = null;
try {
cursor = store.getStorageEngine().rawQuery(sql, args);
if (cursor.moveToNext()) {
viewID = cursor.getInt(0);
}
} catch (SQLException e) {
Log.e(Log.TAG_VIEW, "Error getting view id", e);
} finally {
if (cursor != null) {
cursor.close();
}
}
}
return viewID;
}
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:21,代码来源:SQLiteViewStore.java
示例19: documentPropertiesFromJSON
import com.couchbase.lite.util.Log; //导入依赖的package包/类
protected Map<String, Object> documentPropertiesFromJSON(byte[] json, String docID,
String revID, boolean deleted,
long sequence) {
RevisionInternal rev = new RevisionInternal(docID, revID, deleted);
rev.setSequence(sequence);
rev.setMissing(json == null);
Map<String, Object> docProperties = null;
if (json == null || json.length == 0 || (json.length == 2 && java.util.Arrays.equals(json, EMPTY_JSON_OBJECT_CHARS))) {
docProperties = new HashMap<String, Object>();
} else {
try {
docProperties = Manager.getObjectMapper().readValue(json, Map.class);
} catch (IOException e) {
Log.e(TAG, String.format(Locale.ENGLISH, "Unparseable JSON for doc=%s, rev=%s: %s", docID, revID, new String(json)), e);
docProperties = new HashMap<String, Object>();
}
}
docProperties.put("_id", docID);
docProperties.put("_rev", revID);
if (deleted)
docProperties.put("_deleted", true);
return docProperties;
}
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:27,代码来源:SQLiteStore.java
示例20: initializeReplicationExecutor
import com.couchbase.lite.util.Log; //导入依赖的package包/类
protected ScheduledExecutorService initializeReplicationExecutor() {
return Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
String threadName = "CBLReplicationExecutor";
try {
String maskedRemote = ReplicationInternal.this.remote.toExternalForm();
maskedRemote = maskedRemote.replaceAll("://.*:.*@", "://---:[email protected]");
String type = isPull() ? "pull" : "push";
String replicationIdentifier = Utils.shortenString(remoteCheckpointDocID(), 5);
threadName = String.format(Locale.ENGLISH, "CBLReplicationExecutor-%s-%s-%s",
maskedRemote, type, replicationIdentifier);
} catch (Exception e) {
Log.e(Log.TAG_SYNC, "Error creating thread name", e);
}
return new Thread(r, threadName);
}
});
}
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:20,代码来源:ReplicationInternal.java
注:本文中的com.couchbase.lite.util.Log类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论