Tumblr
V2EX  ›  中州韻

Windows 下清理小狼毫(Weasel)的日志文件

  •  1
     
  •   Tumblr · Jun 25, 2019 · 8752 views
    This topic created in 2516 days ago, the information mentioned may be changed or developed.

    初用小狼毫的时候,你需要进行各种配置、调试,以达到最合适你的使用习惯。
    当然,调试的时候要看日志,但是呢,Weasel 产生的日志并不是那么容易识别,并不太容易知道我要看哪个。

    于是乎……先清理一下,再来调试吧。
    Weasel 的日志是保存在系统的临时目录中的,都是以 rime 开头的文本文件。在 Windows 下,如果直接删除,会提示文件被占用,有部分文件无法删除。
    那么,我们就先把小狼毫的进程停掉,再来删除。

    function Remove-WeaselLogs {
        $rime_exec = (Get-Process -Name WeaselServer).Path
        Write-Host -ForegroundColor DarkYellow "Stopping IME service..."
        Stop-Process -Name WeaselServer
        Start-Sleep -Seconds 1
        Remove-Item $env:TEMP\rime* -Force -Confirm:$false
        Write-Host -ForegroundColor Green "Weasel logs have been purged."
        Start-Process $rime_exec
    }
    

    运行函数 Remove-WeaselLogs ,即可清理 Weasel 的已有日志,调试的时候就方便找到对应的日志文件了。

    Supplement 1  ·  Jun 25, 2019

    之前有个问题没考虑到,就是本来这个进程没有运行,就会报错了,且重新启动不成功,稍微做了下优化:

    function Remove-WeaselLogs {
        Write-Host -ForegroundColor DarkYellow "Stopping IME service..."
        $rime_proc = Get-Process -Name WeaselServer -ErrorAction SilentlyContinue -ErrorVariable Proc_Check
        if ( $Proc_Check ) {
            $rime_exec = (Get-ChildItem -Path 'C:\Program Files\Rime\' -Recurse -Include WeaselServer.exe).FullName
        }
        else {
            $rime_exec = $rime_proc.Path
            Stop-Process -Name WeaselServer
        }
        Start-Sleep -Seconds 1
        Remove-Item $env:TEMP\rime* -Force -Confirm:$false
        Write-Host -ForegroundColor Green "Weasel logs have been purged."
        Start-Process $rime_exec
    }
    
    2 replies    2019-06-25 13:43:18 +08:00
    runze
        1
    runze  
       Jun 25, 2019
    pwsh 虽然用着蛋疼,但是看起来真舒服
    Tumblr
        2
    Tumblr  
    OP
       Jun 25, 2019
    @runze #1 是啊,pwsh 的易读性没得说。
    很多人吐槽 pwsh 的函数太长了,其实……没几个人会完整写的吧。。。都是 tab 自动补全了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   901 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 20:30 · PVG 04:30 · LAX 13:30 · JFK 16:30
    ♥ Do have faith in what you're doing.