mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 13:39:01 +01:00 
			
		
		
		
	refactor(backend_log): print error to the log
This commit is contained in:
		
							parent
							
								
									eb4b5a44df
								
							
						
					
					
						commit
						c4ad84ab06
					
				@ -4,6 +4,8 @@ import { readFile  } from "fs/promises";
 | 
				
			|||||||
import { join } from "path";
 | 
					import { join } from "path";
 | 
				
			||||||
import dateUtils from "../../services/date_utils.js";
 | 
					import dateUtils from "../../services/date_utils.js";
 | 
				
			||||||
import dataDir from "../../services/data_dir.js";
 | 
					import dataDir from "../../services/data_dir.js";
 | 
				
			||||||
 | 
					import log from "../../services/log.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const { LOG_DIR } = dataDir;
 | 
					const { LOG_DIR } = dataDir;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function getBackendLog() {
 | 
					async function getBackendLog() {
 | 
				
			||||||
@ -11,6 +13,8 @@ async function getBackendLog() {
 | 
				
			|||||||
        const file = join(LOG_DIR, `trilium-${dateUtils.localNowDate()}.log`);
 | 
					        const file = join(LOG_DIR, `trilium-${dateUtils.localNowDate()}.log`);
 | 
				
			||||||
        return await readFile(file, "utf8");
 | 
					        return await readFile(file, "utf8");
 | 
				
			||||||
    } catch (e) {
 | 
					    } catch (e) {
 | 
				
			||||||
 | 
					        log.error((e instanceof Error) ? e : "Reading the Backend Log failed with an unknown error.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // most probably the log file does not exist yet - https://github.com/zadam/trilium/issues/1977
 | 
					        // most probably the log file does not exist yet - https://github.com/zadam/trilium/issues/1977
 | 
				
			||||||
        return "";
 | 
					        return "";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user