formatters/ccmtrace.psm1

function Format-ccmtrace
{
param(
    $Record
)

    switch ($Record.Level){
        "DEBUG"       {$level = 1;break}
        "INFO"        {$level = 1;break}
        "INFORMATION" {$level = 1;break}
        "SUCCESS"     {$level = 1;break}
        "TRACE"       {$level = 1;break}
        "VErBOSE"     {$level = 1;break}
        "WARNING"     {$level = 2;break}
        "WARN"        {$level = 2;break}
        "ERROR"       {$level = 3;break}
        "FATAL"       {$level = 3;break}
        "CRITICAL"    {$level = 3;break}
        default       {$level = 1}
    }
    return "<![LOG[{6} {0}]LOG]!><time=`"{1}`" date=`"{2}`" component=`"{3}`" context=`"`" type=`"{5}`" thread=`"`" file=`"{4}`">" `
        -f (
            ("{0}{1}" -f ("`t"*($Record.Indent - 1)), $Record.Message),
            (Get-Date -Format  "HH:mm:ss.fffzz"),
            (Get-Date -Format "MM-dd-yyyy"),
            $Record.Source, 
            (Get-Item $Record.Source).BaseName, 
            $level,
            $Record.Level
           )
}


<#
 
CCM or SCCM log file format is the following on each line:
<![LOG[<MESSAGE>]LOG]!><time="TIME" date="DATE" component="COMPONENT_NAME" context="" type="1" thread="" file="FILE_NAME">
MESSAGE = $Record.Message
TIME =
DATE =
COMPONENT_NAME = $Record.Source
FILE_NAME = $Record.Message
 
for example
<![LOG[Property LogPath is now = X:\MININT\SMSOSD\OSDLOGS]LOG]!><time="17:52:00.000+000" date="12-01-2016" component="LiteTouch" context="" type="1" thread="" file="LiteTouch">
 
#>