[fdb] add db path info for logs
This commit is contained in:
parent
8608140d88
commit
4e56774082
|
@ -57,6 +57,7 @@ uint32_t _fdb_continue_ff_addr(fdb_db_t db, uint32_t start, uint32_t end);
|
|||
fdb_err_t _fdb_init_ex(fdb_db_t db, const char *name, const char *part_name, fdb_db_type type, void *user_data);
|
||||
void _fdb_init_finish(fdb_db_t db, fdb_err_t result);
|
||||
void _fdb_deinit(fdb_db_t db);
|
||||
const char *_fdb_db_path(fdb_db_t db);
|
||||
fdb_err_t _fdb_write_status(fdb_db_t db, uint32_t addr, uint8_t status_table[], size_t status_num, size_t status_index, bool sync);
|
||||
size_t _fdb_read_status(fdb_db_t db, uint32_t addr, uint8_t status_table[], size_t total_num);
|
||||
fdb_err_t _fdb_flash_read(fdb_db_t db, uint32_t addr, void *buf, size_t size);
|
||||
|
|
22
src/fdb.c
22
src/fdb.c
|
@ -103,8 +103,8 @@ void _fdb_init_finish(fdb_db_t db, fdb_err_t result)
|
|||
log_is_show = true;
|
||||
}
|
||||
} else if (!db->not_formatable) {
|
||||
FDB_INFO("Error: %s (%s) is initialize fail (%d).\n", db->type == FDB_DB_TYPE_KV ? "KVDB" : "TSDB",
|
||||
db->name, (int)result);
|
||||
FDB_INFO("Error: %s (%s@%s) is initialize fail (%d).\n", db->type == FDB_DB_TYPE_KV ? "KVDB" : "TSDB",
|
||||
db->name, _fdb_db_path(db), (int)result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,3 +131,21 @@ void _fdb_deinit(fdb_db_t db)
|
|||
|
||||
db->init_ok = false;
|
||||
}
|
||||
|
||||
const char *_fdb_db_path(fdb_db_t db)
|
||||
{
|
||||
if (db->file_mode) {
|
||||
#ifdef FDB_USING_FILE_MODE
|
||||
return db->storage.dir;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#ifdef FDB_USING_FAL_MODE
|
||||
return db->storage.part->name;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@
|
|||
#define FDB_LOG_TAG "[kv]"
|
||||
/* rewrite log prefix */
|
||||
#undef FDB_LOG_PREFIX2
|
||||
#define FDB_LOG_PREFIX2() FDB_PRINT("[%s] ", db_name(db))
|
||||
#define FDB_LOG_PREFIX2() FDB_PRINT("[%s][%s] ", db_name(db), _fdb_db_path((fdb_db_t)db))
|
||||
|
||||
#if defined(FDB_USING_KVDB)
|
||||
|
||||
|
@ -276,7 +276,8 @@ static uint32_t find_next_kv_addr(fdb_kvdb_t db, uint32_t start, uint32_t end)
|
|||
#endif /* FDB_KV_USING_CACHE */
|
||||
|
||||
for (; start < end && start + sizeof(buf) < end; start += (sizeof(buf) - sizeof(uint32_t))) {
|
||||
_fdb_flash_read((fdb_db_t)db, start, (uint32_t *) buf, sizeof(buf));
|
||||
if (_fdb_flash_read((fdb_db_t)db, start, (uint32_t *) buf, sizeof(buf)) != FDB_NO_ERR)
|
||||
return FAILED_ADDR;
|
||||
for (i = 0; i < sizeof(buf) - sizeof(uint32_t) && start + i < end; i++) {
|
||||
#ifndef FDB_BIG_ENDIAN /* Little Endian Order */
|
||||
magic = buf[i] + (buf[i + 1] << 8) + (buf[i + 2] << 16) + (buf[i + 3] << 24);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define FDB_LOG_TAG "[tsl]"
|
||||
/* rewrite log prefix */
|
||||
#undef FDB_LOG_PREFIX2
|
||||
#define FDB_LOG_PREFIX2() FDB_PRINT("[%s] ", db_name(db))
|
||||
#define FDB_LOG_PREFIX2() FDB_PRINT("[%s][%s] ", db_name(db), _fdb_db_path((fdb_db_t)db))
|
||||
|
||||
#if defined(FDB_USING_TSDB)
|
||||
|
||||
|
|
Loading…
Reference in New Issue