/usr/share/doc/libghc-fast-logger-doc/html/src/System-Log-FastLogger-File.html is in libghc-fast-logger-doc 2.4.1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
<title>System/Log/FastLogger/File.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>{-# LANGUAGE Safe #-}</span>
<a name="line-2"></a>
<a name="line-3"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Log</span><span class='hs-varop'>.</span><span class='hs-conid'>FastLogger</span><span class='hs-varop'>.</span><span class='hs-conid'>File</span> <span class='hs-keyword'>where</span>
<a name="line-4"></a>
<a name="line-5"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span> <span class='hs-layout'>(</span><span class='hs-varid'>unless</span><span class='hs-layout'>,</span> <span class='hs-varid'>when</span><span class='hs-layout'>)</span>
<a name="line-6"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span> <span class='hs-layout'>(</span><span class='hs-varid'>doesFileExist</span><span class='hs-layout'>,</span> <span class='hs-varid'>doesDirectoryExist</span><span class='hs-layout'>,</span> <span class='hs-varid'>getPermissions</span><span class='hs-layout'>,</span> <span class='hs-varid'>writable</span><span class='hs-layout'>,</span> <span class='hs-varid'>renameFile</span><span class='hs-layout'>)</span>
<a name="line-7"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>FilePath</span> <span class='hs-layout'>(</span><span class='hs-varid'>takeDirectory</span><span class='hs-layout'>)</span>
<a name="line-8"></a>
<a name="line-9"></a><a name="FileLogSpec"></a><span class='hs-comment'>-- | The spec for logging files</span>
<a name="line-10"></a><a name="FileLogSpec"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>FileLogSpec</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>FileLogSpec</span> <span class='hs-layout'>{</span>
<a name="line-11"></a> <span class='hs-varid'>log_file</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>FilePath</span>
<a name="line-12"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>log_file_size</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Integer</span>
<a name="line-13"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>log_backup_number</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Int</span>
<a name="line-14"></a> <span class='hs-layout'>}</span>
<a name="line-15"></a>
<a name="line-16"></a><a name="check"></a><span class='hs-comment'>-- | Checking if a log file can be written.</span>
<a name="line-17"></a><span class='hs-definition'>check</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>FileLogSpec</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-18"></a><span class='hs-definition'>check</span> <span class='hs-varid'>spec</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
<a name="line-19"></a> <span class='hs-varid'>dirExist</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>doesDirectoryExist</span> <span class='hs-varid'>dir</span>
<a name="line-20"></a> <span class='hs-varid'>unless</span> <span class='hs-varid'>dirExist</span> <span class='hs-varop'>$</span> <span class='hs-varid'>fail</span> <span class='hs-varop'>$</span> <span class='hs-varid'>dir</span> <span class='hs-varop'>++</span> <span class='hs-str'>" does not exist or is not a directory."</span>
<a name="line-21"></a> <span class='hs-varid'>dirPerm</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getPermissions</span> <span class='hs-varid'>dir</span>
<a name="line-22"></a> <span class='hs-varid'>unless</span> <span class='hs-layout'>(</span><span class='hs-varid'>writable</span> <span class='hs-varid'>dirPerm</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-varid'>fail</span> <span class='hs-varop'>$</span> <span class='hs-varid'>dir</span> <span class='hs-varop'>++</span> <span class='hs-str'>" is not writable."</span>
<a name="line-23"></a> <span class='hs-varid'>exist</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>doesFileExist</span> <span class='hs-varid'>file</span>
<a name="line-24"></a> <span class='hs-varid'>when</span> <span class='hs-varid'>exist</span> <span class='hs-varop'>$</span> <span class='hs-keyword'>do</span>
<a name="line-25"></a> <span class='hs-varid'>perm</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getPermissions</span> <span class='hs-varid'>file</span>
<a name="line-26"></a> <span class='hs-varid'>unless</span> <span class='hs-layout'>(</span><span class='hs-varid'>writable</span> <span class='hs-varid'>perm</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-varid'>fail</span> <span class='hs-varop'>$</span> <span class='hs-varid'>file</span> <span class='hs-varop'>++</span> <span class='hs-str'>" is not writable."</span>
<a name="line-27"></a> <span class='hs-keyword'>where</span>
<a name="line-28"></a> <span class='hs-varid'>file</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>log_file</span> <span class='hs-varid'>spec</span>
<a name="line-29"></a> <span class='hs-varid'>dir</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>takeDirectory</span> <span class='hs-varid'>file</span>
<a name="line-30"></a>
<a name="line-31"></a><a name="rotate"></a><span class='hs-comment'>-- | Rotating log files.</span>
<a name="line-32"></a><span class='hs-definition'>rotate</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>FileLogSpec</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-33"></a><span class='hs-definition'>rotate</span> <span class='hs-varid'>spec</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>mapM_</span> <span class='hs-varid'>move</span> <span class='hs-varid'>srcdsts</span>
<a name="line-34"></a> <span class='hs-keyword'>where</span>
<a name="line-35"></a> <span class='hs-varid'>path</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>log_file</span> <span class='hs-varid'>spec</span>
<a name="line-36"></a> <span class='hs-varid'>n</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>log_backup_number</span> <span class='hs-varid'>spec</span>
<a name="line-37"></a> <span class='hs-varid'>dsts'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>reverse</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-str'>""</span><span class='hs-conop'>:</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>map</span> <span class='hs-layout'>(</span><span class='hs-layout'>(</span><span class='hs-chr'>'.'</span><span class='hs-conop'>:</span><span class='hs-layout'>)</span><span class='hs-varop'>.</span> <span class='hs-varid'>show</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>[</span><span class='hs-num'>0</span><span class='hs-keyglyph'>..</span><span class='hs-varid'>n</span><span class='hs-comment'>-</span><span class='hs-num'>1</span><span class='hs-keyglyph'>]</span>
<a name="line-38"></a> <span class='hs-varid'>dsts</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>map</span> <span class='hs-layout'>(</span><span class='hs-varid'>path</span><span class='hs-varop'>++</span><span class='hs-layout'>)</span> <span class='hs-varid'>dsts'</span>
<a name="line-39"></a> <span class='hs-varid'>srcs</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>tail</span> <span class='hs-varid'>dsts</span>
<a name="line-40"></a> <span class='hs-varid'>srcdsts</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>zip</span> <span class='hs-varid'>srcs</span> <span class='hs-varid'>dsts</span>
<a name="line-41"></a> <span class='hs-varid'>move</span> <span class='hs-layout'>(</span><span class='hs-varid'>src</span><span class='hs-layout'>,</span><span class='hs-varid'>dst</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
<a name="line-42"></a> <span class='hs-varid'>exist</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>doesFileExist</span> <span class='hs-varid'>src</span>
<a name="line-43"></a> <span class='hs-varid'>when</span> <span class='hs-varid'>exist</span> <span class='hs-varop'>$</span> <span class='hs-varid'>renameFile</span> <span class='hs-varid'>src</span> <span class='hs-varid'>dst</span>
<a name="line-44"></a>
</pre></body>
</html>
|