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
|
$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 {
|
function chrome-Log-Message {
|
||||||
param (
|
param (
|
||||||
[string]$message
|
[string]$message
|
||||||
|
@ -93,9 +107,9 @@ if ($config.chrome.options.checkExist) {
|
||||||
Remove-Item $testPath -Recurse -Force
|
Remove-Item $testPath -Recurse -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
# Output the subfolders
|
# Output the folders
|
||||||
foreach ($subfolder in $subfolders) {
|
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) {
|
if ($config.amazonWorkspace.options.checkExist) {
|
||||||
|
@ -111,10 +125,10 @@ if ($config.amazonWorkspace.options.checkExist) {
|
||||||
Remove-Item $amazonworkspacetestPath -Recurse -Force
|
Remove-Item $amazonworkspacetestPath -Recurse -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
# Output the subfolders
|
# Output the folders
|
||||||
foreach ($amazonworkspacesubfolder in $amazonworkspacesubfolders) {
|
foreach ($amazonworkspacesubfolder in $amazonworkspacesubfolders) {
|
||||||
try {
|
try {
|
||||||
amazonworkspace-Log-Message "Info: The subfolder '$amazonworkspacesubfolder\' has been deleted."
|
amazonworkspace-Log-Message "Info: The folder '$amazonworkspacesubfolder\' has been deleted."
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "Error logging message: $_"
|
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": {
|
"logging": {
|
||||||
"fileName": "google_chrome",
|
"fileName": "google_chrome",
|
||||||
"fileFormat": "log",
|
"fileFormat": "log",
|
||||||
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss"
|
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss",
|
||||||
|
"clearLogs": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"amazonWorkspace":{
|
"amazonWorkspace":{
|
||||||
|
@ -34,7 +35,8 @@ The `config.json` file should be structured as follows:
|
||||||
"logging": {
|
"logging": {
|
||||||
"fileName": "amazon_workspace",
|
"fileName": "amazon_workspace",
|
||||||
"fileFormat": "log",
|
"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.
|
- `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!** ⚠️
|
- `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.** ⚠️
|
- `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`.
|
- `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 file. The default format is `log`.
|
- `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`.
|
- `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
|
### Date Configuration
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
"logging": {
|
"logging": {
|
||||||
"fileName": "google_chrome",
|
"fileName": "google_chrome",
|
||||||
"fileFormat": "log",
|
"fileFormat": "log",
|
||||||
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss"
|
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss",
|
||||||
|
"clearLogs": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"amazonWorkspace":{
|
"amazonWorkspace":{
|
||||||
|
@ -21,7 +22,8 @@
|
||||||
"logging": {
|
"logging": {
|
||||||
"fileName": "amazon_workspace",
|
"fileName": "amazon_workspace",
|
||||||
"fileFormat": "log",
|
"fileFormat": "log",
|
||||||
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss"
|
"logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss",
|
||||||
|
"clearLogs": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue