Skip to content

Commit

Permalink
Dev (#109)
Browse files Browse the repository at this point in the history
* Updated Team target  (#108)

* Updated docs [skip ci]

* refactor Teams target
+ support additional body types for adaptive card

* syntax cleanup to better follow PnP

Co-authored-by: EsOsO <[email protected]>
Co-authored-by: Jenkins, Michael <[email protected]>

* ignore function name clashing

* unified timestamp format

* keeping raw timestamp
the target is in charge of formatting it using his format

* removed blank lines

* compiled release +semver:minor

Co-authored-by: Michael Jenkins <[email protected]>
Co-authored-by: Jenkins, Michael <[email protected]>
  • Loading branch information
3 people authored Oct 22, 2020
1 parent 9170045 commit d771d10
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 50 deletions.
3 changes: 2 additions & 1 deletion .vscode/ScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'PSAvoidUsingWriteHost',
'PSMissingModuleManifestField',
'PSUseDeclaredVarsMoreThanAssignments',
'PSUseShouldProcessForStateChangingFunctions'
'PSUseShouldProcessForStateChangingFunctions',
'PSAvoidOverwritingBuiltInCmdlets'
)
}
4 changes: 2 additions & 2 deletions Logging/Logging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ $PSModule = $ExecutionContext.SessionState.Module
$PSModuleRoot = $PSModule.ModuleBase

# Dot source public/private functions
$PublicFunctions = @(Get-ChildItem -Path "$SCriptPath\public" -Filter *.ps1 -Recurse -ErrorAction SilentlyContinue)
$PrivateFunctions = @(Get-ChildItem -Path "$SCriptPath\private" -Filter *.ps1 -Recurse -ErrorAction SilentlyContinue)
$PublicFunctions = @(Get-ChildItem -Path "$ScriptPath\public" -Filter *.ps1 -Recurse -ErrorAction SilentlyContinue)
$PrivateFunctions = @(Get-ChildItem -Path "$ScriptPath\private" -Filter *.ps1 -Recurse -ErrorAction SilentlyContinue)

$AllFunctions = $PublicFunctions + $PrivateFunctions
foreach ($Function in $AllFunctions) {
Expand Down
2 changes: 1 addition & 1 deletion Logging/private/Set-LoggingVariables.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Set-LoggingVariables {
Level = $LevelNames[$LevelNames['NOTSET']]
LevelNo = $LevelNames['NOTSET']
Format = '[%{timestamp:+%Y-%m-%d %T%Z}] [%{level:-7}] %{message}'
Timestamp = '%Y-%m-%dT%T%Z'
Timestamp = '%Y-%m-%d %T%Z'
CallerScope = 1
}

Expand Down
4 changes: 2 additions & 2 deletions Logging/public/Write-Log.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ Function Write-Log {
}

$logMessage = [hashtable] @{
timestamp = Get-Date -UFormat $Defaults.Timestamp
timestamputc = Get-Date ([datetime]::UtcNow) -UFormat $Defaults.Timestamp
timestamp = [datetime]::now
timestamputc = [datetime]::UtcNow
level = Get-LevelName -Level $levelNumber
levelno = $levelNumber
lineno = $invocationInfo.ScriptLineNumber
Expand Down
34 changes: 31 additions & 3 deletions Logging/targets/Teams.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,37 @@
$sections = @()

if ($Log.Body) {
$body = [ordered] @{}
$body.activitySubtitle = 'Body'
$body.text = $Log.Body | ConvertTo-Json -Depth 3 -Compress
$body = [ordered]@{};

if ($Log.Body.Activity) {
$body.activityTitle = @('Body', $Log.Body.Activity.title)[[bool]$Log.Body.Activity.title]
$body.activitySubTitle = $Log.Body.Activity.subtitle
$body.text = $Log.Body.Activity.text
} elseif ($Log.Body.Facts) {
$body.title = 'Facts'
if ($Log.Body.Facts -is [array]) {
$body.facts = $Log.Body.Facts
} elseif ($Log.Body.Facts -is [hashtable]) {
$body.facts = $Log.Body.Facts.Keys | %{
@{
name = $_
value = $Log.Body.Facts[$_]
}
}
} else {
$body.facts = @{
name='fact'
value = $($Log.Body.Facts | ConvertTo-Json -Depth 3 -Compress)
}
}
} elseif ($Log.Body -is [string]) {
$body.activityTitle = 'Body'
$body.text = $Log.Body
} else {
$body.activityTitle = 'Body'
$body.text = $Log.Body | ConvertTo-Json -Depth 3 -Compress
}

$sections += $body
}

Expand Down
41 changes: 0 additions & 41 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,28 @@

## 4.3.2 (2020-05-28)


- [FIX] SEQ: fix url when ApiKey is used (#96) (@gahujipo)

## 4.3.1 (2020-05-28)


- [NEW] added target for Azure Log Analytics Workspace (thx to @manualbashing)
- [NEW] added target for Webex Teams (thx to @itshorty)
- [FIX] fixed module autoload (thx to @Tadas)
- [FIX] module don't hang shell exit (thx to @Tadas) #82

## 4.2.13 (2020-02-25)



## 4.2.12 (2019-11-08)



## 4.2.11 (2019-09-23)


- [FIX] Closed issue #66 where messages are lost on Powershell ISE
- [MOD] Decreased `Wait-Logging` timeout from 5 minutes to 30 seconds

## 4.2.7 (2019-09-19)



## 4.2.6 (2019-09-13)


In this release we worked out an issue about setting default
level or formatting was not honored by the already configured
targets (#67) and one about level ignored when dispatching messages
Expand All @@ -51,8 +41,6 @@ Thanks to: @ZamElek

## 4.2.3 (2019-08-27)



## 4.2.2 (2019-08-05)

In this minor release we fixed an annoying issue about how the module loads the available targets.
Expand Down Expand Up @@ -84,7 +72,6 @@ It should improve logging performance to a new level thanks to the amazing work
- [FIX] Filename token (thx to @lookcloser)
- [MOD] Code cleanup


## 2.10.0 (2019-04-04)

- [NEW] Added support for target default config
Expand Down Expand Up @@ -168,31 +155,3 @@ It should improve logging performance to a new level thanks to the amazing work
- Moved to psake build tool
- Moved to platyps doc generation tool
- Major folder structure change




























4 changes: 4 additions & 0 deletions docs/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

- [ADD] Teams target now support additional body types for adaptive cards (@jangins101)
- [FIX] Refactored Teams target (@jangins101)
- [FIX] Removed formatting timestamp on log event creation, this caused lost of milliseconds later on

0 comments on commit d771d10

Please sign in to comment.