Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 2 issues of New-PodeLoggingMethod -File #1507

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

nightroman
Copy link

This PR fixes two issues described below.

Given this file logger

	$logging = New-PodeLoggingMethod -File -Path C:\TEMP -Name pode -MaxDays 1
	Enable-PodeRequestLogging $logging
	Enable-PodeErrorLogging $logging

Issue 1: -MaxDays may not work

Pode does not remove old files if the server restarts daily or more frequently (I think this is a typical local scenario).

Why. On starting NextClearDown is set to [DateTime]::Now.Date and then it is checked as NextClearDown -lt [DateTime]::Now.Date. This condition is always false on daily restarts and removal of old logs never happens.

Issue 2: Pode may remove wrong logs

This original code is supposed to remove all "old" *.log files in C:\TEMP, not necessarily related to the specific file logger "pode"

	$null = Get-ChildItem -Path $options.Path -Filter '*.log' -Force |
		Where-Object { $_.CreationTime -lt $date } |
		Remove-Item -Force

I think the filter should be "$($options.Name)_*.log" in order to remove relevant files only.

mdaneri added a commit to mdaneri/Pode that referenced this pull request Mar 2, 2025
mdaneri added a commit to mdaneri/Pode that referenced this pull request Mar 2, 2025
@mdaneri mdaneri mentioned this pull request Mar 2, 2025
mdaneri added a commit to mdaneri/Pode that referenced this pull request Mar 3, 2025
@mdaneri mdaneri mentioned this pull request Mar 3, 2025
mdaneri added a commit to mdaneri/Pode that referenced this pull request Mar 3, 2025
mdaneri added a commit to mdaneri/Pode that referenced this pull request Mar 3, 2025
mdaneri added a commit to mdaneri/Pode that referenced this pull request Mar 3, 2025
commit d845c13
Author: mdaneri <[email protected]>
Date:   Sun Mar 2 08:10:13 2025 -0800

    fix sample

commit a2e6474
Author: mdaneri <[email protected]>
Date:   Sun Mar 2 08:00:28 2025 -0800

    Ensure ErrorLoggingLevels is only set when ErrorLoggingEnabled is true in Pode listener configuration.

    Include Badgerati#1507 fixes

commit 79461e8
Author: mdaneri <[email protected]>
Date:   Sun Mar 2 07:22:24 2025 -0800

    remove a    $_ | Write-PodeErrorLog when log doesn't exist

commit c4b8ec2
Author: mdaneri <[email protected]>
Date:   Sat Mar 1 19:06:45 2025 -0800

    update test

commit 87e42b9
Merge: a19e5d3 67505f5
Author: mdaneri <[email protected]>
Date:   Sun Feb 23 07:31:25 2025 -0800

    Merge branch 'develop' into Log-rest-syslog

commit a19e5d3
Author: mdaneri <[email protected]>
Date:   Sat Feb 22 09:25:49 2025 -0800

    merged

commit 228e84b
Merge: 282875e cbdc62f
Author: mdaneri <[email protected]>
Date:   Sat Feb 22 09:25:41 2025 -0800

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 282875e
Author: mdaneri <[email protected]>
Date:   Sat Feb 22 07:56:15 2025 -0800

    Update OpenApi.Tests.ps1

commit e60b039
Merge: 534fe56 fbf6ecf
Author: mdaneri <[email protected]>
Date:   Sat Feb 22 06:33:21 2025 -0800

    Merge branch 'develop' into Log-rest-syslog

commit 534fe56
Merge: 3a83ea8 a76741b
Author: mdaneri <[email protected]>
Date:   Sun Feb 16 07:09:03 2025 -0800

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 3a83ea8
Merge: ad896c6 a236a1a
Author: mdaneri <[email protected]>
Date:   Tue Feb 11 18:51:53 2025 -0800

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit ad896c6
Merge: 115515b 75e2962
Author: mdaneri <[email protected]>
Date:   Sun Feb 9 07:25:15 2025 -0800

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 115515b
Author: mdaneri <[email protected]>
Date:   Fri Feb 7 08:05:03 2025 -0800

    .

commit 01e5f16
Author: mdaneri <[email protected]>
Date:   Fri Feb 7 04:07:35 2025 -0800

    Update Server.Tests.ps1

commit 99e7b43
Author: mdaneri <[email protected]>
Date:   Thu Feb 6 06:31:33 2025 -0800

    minor changes

commit 64ab1c9
Author: mdaneri <[email protected]>
Date:   Thu Feb 6 06:13:17 2025 -0800

    Update Pode.psd1

commit 545b5f1
Merge: bf25899 6b23fc3
Author: mdaneri <[email protected]>
Date:   Wed Feb 5 14:56:38 2025 -0800

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit bf25899
Author: mdaneri <[email protected]>
Date:   Tue Feb 4 09:10:47 2025 -0800

    fixes post merge

commit f047cb6
Author: mdaneri <[email protected]>
Date:   Tue Feb 4 08:12:42 2025 -0800

    Update Logging.ps1

commit 1dde713
Author: mdaneri <[email protected]>
Date:   Sun Jan 26 11:57:24 2025 -0800

    Update Pode.psd1

commit 70683a0
Merge: 0de73eb f4db4b6
Author: mdaneri <[email protected]>
Date:   Sun Jan 26 11:57:21 2025 -0800

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 0de73eb
Merge: a9926dd 391bdff
Author: mdaneri <[email protected]>
Date:   Sun Nov 24 17:06:09 2024 -0800

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit a9926dd
Merge: 6d9e798 7a2cf53
Author: mdaneri <[email protected]>
Date:   Sat Nov 23 08:02:23 2024 -0800

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 6d9e798
Author: mdaneri <[email protected]>
Date:   Fri Nov 22 06:19:56 2024 -0800

    Update pode.build.ps1

commit 1ea0a7f
Merge: 09fd277 5a0bee1
Author: mdaneri <[email protected]>
Date:   Wed Nov 6 05:49:47 2024 -0800

    Merge branch 'develop' into Log-rest-syslog

commit 09fd277
Merge: a9f6855 62bc705
Author: mdaneri <[email protected]>
Date:   Sun Nov 3 15:50:49 2024 -0800

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit a9f6855
Merge: 6c9aa80 312654b
Author: mdaneri <[email protected]>
Date:   Sun Nov 3 12:41:33 2024 -0800

    Merge branch 'develop' into Log-rest-syslog

commit 6c9aa80
Author: mdaneri <[email protected]>
Date:   Sat Nov 2 14:08:59 2024 -0700

    fix merge

commit 1d10e20
Merge: a530fc5 a37f33b
Author: mdaneri <[email protected]>
Date:   Sat Nov 2 14:08:50 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit a530fc5
Author: mdaneri <[email protected]>
Date:   Sat Nov 2 10:19:05 2024 -0700

    remove get-Pode<name>loggingName

commit 6119380
Author: mdaneri <[email protected]>
Date:   Sat Nov 2 09:44:23 2024 -0700

    Syslog format in C#

commit b529180
Author: mdaneri <[email protected]>
Date:   Sat Nov 2 08:28:47 2024 -0700

    FIx extended format

commit 4877db0
Author: mdaneri <[email protected]>
Date:   Sat Nov 2 07:57:17 2024 -0700

    moving some log formatting to C#

commit 7ffef30
Author: mdaneri <[email protected]>
Date:   Sat Nov 2 07:25:47 2024 -0700

    rename WriteError to LogMessagen and WriteException to LogException

commit 4de99c1
Author: mdaneri <[email protected]>
Date:   Sat Nov 2 07:19:41 2024 -0700

    Add support multiple restful syslog

commit d489460
Author: mdaneri <[email protected]>
Date:   Fri Nov 1 10:06:42 2024 -0700

    add try catch

commit 83b6f5a
Author: mdaneri <[email protected]>
Date:   Fri Nov 1 10:00:20 2024 -0700

    improvements

commit af60232
Author: mdaneri <[email protected]>
Date:   Fri Nov 1 09:04:03 2024 -0700

    merging  tag with source

commit 6c26f67
Merge: da1c605 308035d
Author: mdaneri <[email protected]>
Date:   Wed Oct 30 07:24:49 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit da1c605
Author: mdaneri <[email protected]>
Date:   Mon Oct 28 09:31:18 2024 -0700

    fix servless test

commit f9ab920
Author: mdaneri <[email protected]>
Date:   Mon Oct 28 09:18:10 2024 -0700

    fix test and file logging

commit 1efbc89
Author: mdaneri <[email protected]>
Date:   Mon Oct 28 08:59:41 2024 -0700

    File service fixes

commit fe20cfb
Author: mdaneri <[email protected]>
Date:   Mon Oct 28 07:35:57 2024 -0700

    Fix tests + bugs post merge

commit 0504b1b
Merge: 1be9163 c47ad6f
Author: mdaneri <[email protected]>
Date:   Mon Oct 28 07:15:31 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 1be9163
Author: mdaneri <[email protected]>
Date:   Sun Oct 27 20:04:52 2024 -0700

    functions change

commit e4ebc2a
Merge: 4859585 09d9ad0
Author: mdaneri <[email protected]>
Date:   Sun Oct 27 16:56:39 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 4859585
Author: mdaneri <[email protected]>
Date:   Fri Oct 25 17:59:07 2024 -0700

    Fix Levels and cleanup

commit 5a77d59
Author: mdaneri <[email protected]>
Date:   Fri Oct 25 17:18:13 2024 -0700

    revert PodetraceLog

commit 34eecb6
Merge: 9e48241 c8e23fb
Author: mdaneri <[email protected]>
Date:   Wed Oct 23 12:59:20 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 9e48241
Merge: 078737a 0b08d67
Author: mdaneri <[email protected]>
Date:   Wed Oct 23 07:42:13 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 078737a
Author: mdaneri <[email protected]>
Date:   Mon Oct 21 18:53:36 2024 -0700

    Update Context.ps1

commit 58e1d58
Author: mdaneri <[email protected]>
Date:   Mon Oct 21 08:28:37 2024 -0700

    changed New-PodeCustomLoggingMethod to support only runspace

commit 7e0514a
Author: mdaneri <[email protected]>
Date:   Mon Oct 21 08:07:53 2024 -0700

    Update Pode.psd1

commit b021e7e
Merge: 94da198 79ec468
Author: mdaneri <[email protected]>
Date:   Mon Oct 21 08:07:49 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 94da198
Author: mdaneri <[email protected]>
Date:   Sun Oct 20 21:32:22 2024 -0700

    function headers

commit a0b4673
Author: mdaneri <[email protected]>
Date:   Sun Oct 20 20:46:05 2024 -0700

    New-PodeLoggingMethod deprecation

commit bd92d53
Author: mdaneri <[email protected]>
Date:   Sun Oct 20 18:08:07 2024 -0700

    fix test

commit 7858e47
Author: mdaneri <[email protected]>
Date:   Sun Oct 20 09:34:08 2024 -0700

    removed redundant sg function

commit 155b7d9
Merge: ce3ebcf 0411580
Author: mdaneri <[email protected]>
Date:   Sun Oct 20 09:24:56 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit ce3ebcf
Author: mdaneri <[email protected]>
Date:   Sun Oct 20 09:24:39 2024 -0700

    fix an PodeContext.cs created by a merge

    Performance improvement

commit d16456f
Author: mdaneri <[email protected]>
Date:   Sat Oct 19 13:24:32 2024 -0700

    minor changes

commit 4d22cc3
Merge: e838173 a181172
Author: mdaneri <[email protected]>
Date:   Fri Oct 18 20:30:09 2024 -0400

    Merge branch 'develop' into Log-rest-syslog

commit e838173
Merge: 51e1ed9 696cc43
Author: mdaneri <[email protected]>
Date:   Wed Oct 16 07:55:33 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 51e1ed9
Merge: b0720cc 21c76a1
Author: mdaneri <[email protected]>
Date:   Sun Sep 29 08:06:56 2024 -0700

    Merge branch 'develop' into Log-rest-syslog

commit b0720cc
Author: mdaneri <[email protected]>
Date:   Sat Sep 28 11:00:14 2024 -0700

    Update Logging.ps1

commit 7de7e69
Merge: 3df186a 2e9d252
Author: mdaneri <[email protected]>
Date:   Sat Sep 28 10:59:51 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 3df186a
Merge: 984822e 3ba7228
Author: mdaneri <[email protected]>
Date:   Sat Sep 28 10:14:16 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 984822e
Author: mdaneri <[email protected]>
Date:   Sat Sep 28 09:03:17 2024 -0700

    fix Locales duplicated key

commit a7892ac
Merge: 8005ef8 af57434
Author: mdaneri <[email protected]>
Date:   Sat Sep 28 08:32:31 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 8005ef8
Merge: c284d8c 38f2f07
Author: mdaneri <[email protected]>
Date:   Fri Sep 27 07:50:27 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit c284d8c
Author: mdaneri <[email protected]>
Date:   Mon Sep 23 08:23:59 2024 -0700

    Fix runspace naming

commit 60f8601
Author: mdaneri <[email protected]>
Date:   Sun Sep 22 08:44:12 2024 -0700

    fix en_us language

commit 811cbd6
Author: mdaneri <[email protected]>
Date:   Sun Sep 22 08:24:09 2024 -0700

    	modified:   src/Private/Context.ps1

commit 992c87f
Merge: 50a222e 473c9be
Author: mdaneri <[email protected]>
Date:   Sun Sep 22 08:24:06 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 50a222e
Merge: d7fa9f7 d51eda6
Author: mdaneri <[email protected]>
Date:   Sun Sep 22 06:24:08 2024 -0700

    Merge branch 'develop' into Log-rest-syslog

commit d7fa9f7
Author: mdaneri <[email protected]>
Date:   Sat Sep 21 14:29:53 2024 -0700

    fix tests

commit 1deeffc
Merge: d775128 93df876
Author: mdaneri <[email protected]>
Date:   Sat Sep 21 10:16:02 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit d775128
Merge: 25120b0 9a99c96
Author: mdaneri <[email protected]>
Date:   Sun Sep 15 15:18:21 2024 -0700

    Merge remote-tracking branch 'upstream/develop' into Log-rest-syslog

commit 25120b0
Author: mdaneri <[email protected]>
Date:   Sat Sep 7 20:56:17 2024 -0700

    recovered from Add New Logging Features: Syslog and Restful Support Badgerati#1335
This was referenced Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant