Feature: clearLogs,
A boolean flag to enable clearing of the log(s) file(s). This will clear the content inside of the log file(s).
This commit is contained in:
parent
5682e85f6e
commit
d6512495b6
3 changed files with 29 additions and 11 deletions
|
@ -38,6 +38,20 @@ if (-not $amazonworkspacelogFileFormat) {
|
|||
|
||||
$amazonworkspacelogFileNameFormat = $amazonworkspacelogFileName+"."+$amazonworkspacelogFileFormat
|
||||
|
||||
if ($config.chrome.logging.clearLogs) {
|
||||
# Construct the full path to the log file
|
||||
$logFilePathchrome = Join-Path -Path $PSScriptRoot -ChildPath $chromelogFileNameFormat
|
||||
# Clear the contents of the log file
|
||||
Set-Content -Path $logFilePathchrome -Value ''
|
||||
}
|
||||
|
||||
if ($config.amazonWorkspace.logging.clearLogs) {
|
||||
# Construct the full path to the log file
|
||||
$logFilePathworkspaces = Join-Path -Path $PSScriptRoot -ChildPath $amazonworkspacelogFileNameFormat
|
||||
# Clear the contents of the log file
|
||||
Set-Content -Path $logFilePathworkspaces -Value ''
|
||||
}
|
||||
|
||||
function chrome-Log-Message {
|
||||
param (
|
||||
[string]$message
|
||||
|
@ -93,9 +107,9 @@ if ($config.chrome.options.checkExist) {
|
|||
Remove-Item $testPath -Recurse -Force
|
||||
}
|
||||
|
||||
# Output the subfolders
|
||||
# Output the folders
|
||||
foreach ($subfolder in $subfolders) {
|
||||
chrome-Log-Message "Info: The subfolder '$subfolder\' has been deleted."
|
||||
chrome-Log-Message "Info: The folder '$subfolder\' has been deleted."
|
||||
}
|
||||
}
|
||||
if ($config.amazonWorkspace.options.checkExist) {
|
||||
|
@ -111,10 +125,10 @@ if ($config.amazonWorkspace.options.checkExist) {
|
|||
Remove-Item $amazonworkspacetestPath -Recurse -Force
|
||||
}
|
||||
|
||||
# Output the subfolders
|
||||
# Output the folders
|
||||
foreach ($amazonworkspacesubfolder in $amazonworkspacesubfolders) {
|
||||
try {
|
||||
amazonworkspace-Log-Message "Info: The subfolder '$amazonworkspacesubfolder\' has been deleted."
|
||||
amazonworkspace-Log-Message "Info: The folder '$amazonworkspacesubfolder\' has been deleted."
|
||||
} catch {
|
||||
Write-Host "Error logging message: $_"
|
||||
}
|
||||
|
|
12
README.md
12
README.md
|
@ -22,7 +22,8 @@ The `config.json` file should be structured as follows:
|
|||
"logging": {
|
||||
"fileName": "google_chrome",
|
||||
"fileFormat": "log",
|
||||
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss"
|
||||
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss",
|
||||
"clearLogs": false
|
||||
}
|
||||
},
|
||||
"amazonWorkspace":{
|
||||
|
@ -34,7 +35,8 @@ The `config.json` file should be structured as follows:
|
|||
"logging": {
|
||||
"fileName": "amazon_workspace",
|
||||
"fileFormat": "log",
|
||||
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss"
|
||||
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss",
|
||||
"clearLogs": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,10 +47,10 @@ The `config.json` file should be structured as follows:
|
|||
- `download`: A boolean flag to enable downloading and installing Amazon Workspaces.
|
||||
- `folderNumberedVersion`: A boolean flag to enable the automatic renaming of the folder to the newest version of Chrome. ⚠️ **This option requires administrative privileges when executing the script!** ⚠️
|
||||
- `checkExist`: A boolean flag to delete old Chrome folders when the script is executed. ⚠️ **This action will delete your Chrome folders, so ensure you have backups if you wish to retain them.** ⚠️
|
||||
- `fileName`: A string defining the name of the log file. The default name is `google_chrome` and `amazon_workspace`.
|
||||
- `fileFormat`: A string defining the format of the log file. The default format is `log`.
|
||||
- `fileName`: A string defining the name of the log(s) file(s). The default name is `google_chrome` and `amazon_workspace`.
|
||||
- `fileFormat`: A string defining the format of the log(s) file(s). The default format is `log`.
|
||||
- `logDateFormat`: A string defining the format of timestamps in logs. The default format is `dd/MM/yyyy HH:mm:ss`.
|
||||
|
||||
- `clearLogs`: A boolean flag to enable clearing of the log(s) file(s). This will clear the content inside of the log file(s).
|
||||
|
||||
### Date Configuration
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
"logging": {
|
||||
"fileName": "google_chrome",
|
||||
"fileFormat": "log",
|
||||
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss"
|
||||
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss",
|
||||
"clearLogs": false
|
||||
}
|
||||
},
|
||||
"amazonWorkspace":{
|
||||
|
@ -21,7 +22,8 @@
|
|||
"logging": {
|
||||
"fileName": "amazon_workspace",
|
||||
"fileFormat": "log",
|
||||
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss"
|
||||
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss",
|
||||
"clearLogs": false
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue