tauri-logger
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Log critical actions through your frontend like you would do with console.log and store them locally!

IMPORTANT! Don't forget to set your scopes:

If you use the default dir-name option (see below)


"tauri": {
        "allowlist": {
		"fs": {
			"createDir": true,
			"writeFile": true,
			"scope": ["$DOCUMENT/YOURAPPNAME/logs"]
			}
		}
}

Or if you use a custom dir name you will have to change the YOURAPPNAME accordingly

"scope": ["$DOCUMENT/YOURCUSTOMDIRNAME/logs"]

This can be utilized to write logs of certain specified actions:

function criticalFunction() {
	try {
		tauriLog("critical function success")
	}
	catch (e)
		tauriLog("Crashed: " e)
}

To use the logger, place the function

initializeLogger()

inside your index.js/ts file

Then use

tauriLog(action)

whenever you want to log something

Errors produced by your frontend are logged automaticly unless you set the option to false

initializeLogger({
	reportErrors: false
})

A DiagnosticReport is also included by default unless turned off (includes appName, appVersion and the used tauriVersion)

initializeLogger({
	diagnosticReport: false
})

The default directory where the logs are stored is the Document folder, inside which a directory with you app name will be created

The app name is retrieved from the config file created by tauri

Example:

"package": {
        "productName": "your-appname",
    },

You can also set a custom dir that will be created in the Document Folder

initializeLogger({
	customDirName: "yourDirName"
})

If you encounter any problems or want to contribute feel free to do so!!!

Github Repo

Readme

Keywords

Package Sidebar

Install

npm i tauri-logger

Weekly Downloads

0

Version

1.0.5

License

GPL-3.0-or-later

Unpacked Size

50.4 kB

Total Files

6

Last publish

Collaborators

  • dan0xe