Участник:StasFomin/Bookmarks/Stegano — различия между версиями

Материал из DISCOPAL
Перейти к: навигация, поиск
(Добавлена закладка Python Parse log file in realtime, reload when the log rotates - Stack Overflow)
(Добавлена закладка pygtail · PyPI)
Строка 2: Строка 2:
 
=== 2020-10 ===
 
=== 2020-10 ===
  
 +
* 2020-10-29, 00:10:17: [https://pypi.org/project/pygtail/ pygtail · PyPI]
 +
*: <html><span class="kn">from</span> <span class="nn">pygtail</span> <span class="kn">import</span> <span class="n">Pygtail</span>  <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">Pygtail</span><span class="p">(</span><span class="s2">"some.log"</span><span class="p">):</span>    <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">line</span><span class="p">)</span></html>
 +
<!-- NEXT BOOKMARK -->
 
* 2020-10-29, 00:09:15: [https://stackoverflow.com/questions/36327265/python-parse-log-file-in-realtime-reload-when-the-log-rotates Python Parse log file in realtime, reload when the log rotates - Stack Overflow]
 
* 2020-10-29, 00:09:15: [https://stackoverflow.com/questions/36327265/python-parse-log-file-in-realtime-reload-when-the-log-rotates Python Parse log file in realtime, reload when the log rotates - Stack Overflow]
 
*: <html><span class="hljs-keyword">import</span> os  file_path = <span class="hljs-string">'/var/log/app/access.log'</span>  <span class="hljs-keyword">with</span> open(file_path) <span class="hljs-keyword">as</span> f:    file_size = <span class="hljs-number">0</span>    <span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>:        line = f.readline()        <span class="hljs-keyword">if</span> line:            <span class="hljs-keyword">print</span> line        file_status_obj = os.stat(file_path)        <span class="hljs-keyword">if</span> file_size &lt; file_status_obj.st_size:            f.seek(<span class="hljs-number">0</span>)        file_size = file_status_obj.st_size </html>
 
*: <html><span class="hljs-keyword">import</span> os  file_path = <span class="hljs-string">'/var/log/app/access.log'</span>  <span class="hljs-keyword">with</span> open(file_path) <span class="hljs-keyword">as</span> f:    file_size = <span class="hljs-number">0</span>    <span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>:        line = f.readline()        <span class="hljs-keyword">if</span> line:            <span class="hljs-keyword">print</span> line        file_status_obj = os.stat(file_path)        <span class="hljs-keyword">if</span> file_size &lt; file_status_obj.st_size:            f.seek(<span class="hljs-number">0</span>)        file_size = file_status_obj.st_size </html>

Версия 21:10, 28 октября 2020

2020

2020-10

2020-09

2020-08

2020-07

Навигация