0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

test

Last updated at Posted at 2024-11-17
#Set-ExecutionPolicy RemoteSigned -Scope Process
$ErrorActionPreference = "stop"
Set-PSDebug -Strict
#Set-PSDebug -off
Set-StrictMode -Version Latest

$rootPath="_"
$pattern = "*.log"

$OutputPath="_"




$has_Threads = @{}

function Fn_GetFileName([string]$FileName,[string]$ExtName){
    Get-Date -Format ("yyyyMMddHHmmss")
    return $FileName+"_"+(Get-Date -Format ("yyyyMMddHHmmss"))+"."+$ExtName
}



Function Rn_HashAdd($ThreadID){
    $ThreadID
    $has_Threads.Add($ThreadID,$null)
    
    $has_Threads[$ThreadID] =
        $has_DiffFiles = 
        @{
            DiffFileName =$null
            FetchStart_TS =$null
            FetchEnd_TS =$null
            WorkDelCount =$null
        }
}


$line = $null

#出力
function Fn_StreamOpen($InFile){
        $fs = [System.IO.File]::Open(
            $_,
            [System.IO.FileMode]::Open,
            [System.IO.FileAccess]::Read,
            [System.IO.FileShare]::ReadWrite + [System.IO.FileShare]::Delete
            
            )
        $sr = [System.IO.StreamReader]::new($fs,[System.Text.Encoding]::GetEncoding("sjis"))

        return $sr
}

#MainProc

#ファイル一覧生成
$InputFileList=@(robocopy $rootPath NULL $pattern /L /NP /FP /NS /NC /NJH /NJS /NDL )
#$InputFileList=@(robocopy $rootPath NULL $pattern /L /E /NP /FP /NS /NC /NJH /NJS /NDL ) #サブディレクトリあり
$InputFileList = $InputFileList -ne ""
$InputFileList = $InputFileList.trim()

#ファイルリスト全体を実行

#$sw = [System.IO.StreamWriter]::new($fs,$false,[System.Text.Encoding]::GetEncoding("sjis"))

$InputFileList | &{
    Process {$_
        #ファイルオープン
        $sr = Fn_StreamOpen($_)

        while (($line = $sr.ReadLine()) -ne $null) {
            #ログフォーマット
            $line    
            $lineReg = [regex]::Matches($line,"^\[(?<TimeStmp>[^\]\[]+)\]\t<(?<ThreadID>[^><]+)>\t(?<Comment>.*)$")
            if ($lineReg.count -ne 0){
                "Hit:"+$line
                $ThreadID = $lineReg[0].groups['ThreadID'].value
                Rn_HashAdd($ThreadID)
             }else
             {
                "not:"+$line
             }
        }

            
            #ログ分析
        
            ##スレッドレベル情報の取得
        
            ##ファイル毎情報の取得

    #ファイルクローズ
    $sr.Close() 
    $has_Threads
    }
}     

#スレッドの開始と終了


#スレッドxファイル名の開始と終了
# +連続して表示される削除記号
# スレッド番号内で順にログが出現しない場合はエラーとして空のまま出力し情報を捨てる

    



#Set-ExecutionPolicy RemoteSigned -Scope Process
$ErrorActionPreference = "stop"
[string]$ThreadID="Thread=1"

[string]$FileName1 = "F1.txt"
[string]$FileName2 = "F2.txt"

$Roop = @{}
$Roop.Add($ThreadID,@{
    ThreadStart = 1
    ThreadEnd = $null
    WorkDel = $null
})


$Roop.$ThreadID.Add($FileName1,@{
    FetchStart = 2
    FetchEnd = 3
})


$Roop.$ThreadID.Add($FileName2,@{
    FetchStart = 4
    FetchEnd = 5
})

$Roop.$ThreadID.ThreadEnd = 6
$Roop.$ThreadID.WorkDel = 100

$Roop.$ThreadID.Keys





<#

$Roop = @{
    $ThreadID = @{
        ThreadStart = 1
        ThreadEnd = 10
        WorkDelCount = 100
        $FileName1 =@{
            start = 2
            end = 3
        }
    }
}

$Roop.$ThreadID.$FileName1.start
$Roop.$ThreadID.$FileName1.end


#>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?