-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added functiong useServer log for get, open, and clear log
- Loading branch information
Showing
2 changed files
with
196 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { fs, joinPath, openFileExplorer, getUserSpace } from '@janhq/core' | ||
|
||
export const useServerLog = () => { | ||
const getServerLog = async () => { | ||
if (!(await fs.existsSync(await joinPath(['file://logs', 'server.log'])))) | ||
return {} | ||
const logs = await fs.readFileSync( | ||
await joinPath(['file://logs', 'server.log']), | ||
'utf-8' | ||
) | ||
|
||
return logs | ||
} | ||
const openServerLog = async () => { | ||
const userSpace = await getUserSpace() | ||
const fullPath = await joinPath([userSpace, 'logs', 'server.log']) | ||
return openFileExplorer(fullPath) | ||
} | ||
|
||
const clearServerLog = async () => { | ||
await fs.writeFileSync(await joinPath(['file://logs', 'server.log']), '') | ||
} | ||
return { getServerLog, openServerLog, clearServerLog } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters