Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

What is mind? No matter. What is matter? Never mind. -- Thomas Hewitt Key, 1799-1875


devel / comp.lang.misc / Defensive programming

SubjectAuthor
* Defensive programmingStefan Ram
+- Re: Defensive programmingStefan Ram
`* Re: Defensive programmingDmitry A. Kazakov
 `* Re: Defensive programmingStefan Ram
  +* Re: Defensive programmingStefan Ram
  |+* Re: Defensive programmingStefan Ram
  ||`- Re: Defensive programmingDmitry A. Kazakov
  |`- Re: Defensive programmingDmitry A. Kazakov
  `* Re: Defensive programmingDmitry A. Kazakov
   `* Re: Defensive programmingStefan Ram
    `* Re: Defensive programmingDmitry A. Kazakov
     `* Re: Defensive programmingStefan Ram
      `- Re: Defensive programmingDmitry A. Kazakov

1
Defensive programming

<defensive-20220923184650@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1830&group=comp.lang.misc#1830

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.misc
Subject: Defensive programming
Date: 23 Sep 2022 17:57:13 GMT
Organization: Stefan Ram
Lines: 16
Expires: 1 Sep 2023 11:59:58 GMT
Message-ID: <defensive-20220923184650@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de v60rZIbIBv/6sEUY+GTQ7AgrMJe0YbsqJFToC5hu3wRJF/
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Fri, 23 Sep 2022 17:57 UTC

I wrote a small Python script to append a line to the end
of a log file. This script is invoked from a VBA subroutine
to append a line to that log file.

In the same VBA subroutine, I then read the last line from
the same log file and compare it with the line to be written.
If they do not agree, the VBA subroutine opens a new message
box informing the user.

This might sound overly defensive, but in fact it is not
infrequent that I happen to see that dialog! Reasons might include
problems with the character encoding, full disks, or recently,
a possible spurious error message for reasons (yet) unknown
(maybe due to an overload of the system, which led to timeouts).

Re: Defensive programming

<errors-20220923190527@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1831&group=comp.lang.misc#1831

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.misc
Subject: Re: Defensive programming
Date: 23 Sep 2022 18:06:03 GMT
Organization: Stefan Ram
Lines: 12
Expires: 1 Sep 2023 11:59:58 GMT
Message-ID: <errors-20220923190527@ram.dialup.fu-berlin.de>
References: <defensive-20220923184650@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de JhtlWdTHA9TtXHasc3Iy4wlEDti/nBXMMcVF63ATQvlrQY
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Fri, 23 Sep 2022 18:06 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:
>infrequent that I happen to see that dialog! Reasons might include
>problems with the character encoding, full disks, or recently,

I forgot: The Python script depends on a library I wrote.
A common source of errors also is that I change something
with the library, but then forget to adjust the script to
this change. That change in the library will render the
script inoperable. But the VBA check then will detect and
report this problem.

Re: Defensive programming

<tgkv84$1g7e$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1832&group=comp.lang.misc#1832

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!aioe.org!epJzlJsZWlp1WuFmYLlBpQ.user.46.165.242.91.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.misc
Subject: Re: Defensive programming
Date: Fri, 23 Sep 2022 20:51:49 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tgkv84$1g7e$1@gioia.aioe.org>
References: <defensive-20220923184650@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="49390"; posting-host="epJzlJsZWlp1WuFmYLlBpQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Fri, 23 Sep 2022 18:51 UTC

On 2022-09-23 19:57, Stefan Ram wrote:
> I wrote a small Python script to append a line to the end
> of a log file. This script is invoked from a VBA subroutine
> to append a line to that log file.
>
> In the same VBA subroutine, I then read the last line from
> the same log file and compare it with the line to be written.
> If they do not agree, the VBA subroutine opens a new message
> box informing the user.

That is an awful idea IMO. With disastrous performance as it would block
the logging file for a long time.

The key point is that logging is secondary to functionality. Thus
whatever might happen with the logs, that shall not disrupt normal
operation.

For example, in a real-time application logger queues messages instead
of writing them. Then a lower priority task flushes the log messages
queue to the disk in background.

> This might sound overly defensive, but in fact it is not
> infrequent that I happen to see that dialog! Reasons might include
> problems with the character encoding, full disks, or recently,
> a possible spurious error message for reasons (yet) unknown
> (maybe due to an overload of the system, which led to timeouts).

You should simply flush the log file periodically (keeping it open of
course).

Modern file systems do caching, mirroring, journaling,
"never-overwrite-same-block" stuff. You cannot do any better from a VBA
application! You even cannot know if the stuff you read back was
actually physically written down to the physical medium and not sitting
in some N-th order cache of some M-th controller in between... (Mission
critical logger solutions like blackboxes may use special hardware
write-once mediums etc)

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Defensive programming

<logging-20220923195833@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1833&group=comp.lang.misc#1833

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.misc
Subject: Re: Defensive programming
Date: 23 Sep 2022 18:58:57 GMT
Organization: Stefan Ram
Lines: 9
Expires: 1 Sep 2023 11:59:58 GMT
Message-ID: <logging-20220923195833@ram.dialup.fu-berlin.de>
References: <defensive-20220923184650@ram.dialup.fu-berlin.de> <tgkv84$1g7e$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de jbGkQJ7Bm+FMNZ7d8Wa8uQy0X/aGnUl5VdBCoopcdOT7rR
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Fri, 23 Sep 2022 18:58 UTC

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>You should simply flush the log file periodically (keeping it open of
>course).

This log file gets infrequent writes. Not more than 1000 per day.
So to append a line, I always open the file for appending, write
the line, and close it immediately.

Re: Defensive programming

<log-20220923202055@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1834&group=comp.lang.misc#1834

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.misc
Subject: Re: Defensive programming
Date: 23 Sep 2022 19:21:30 GMT
Organization: Stefan Ram
Lines: 8
Expires: 1 Sep 2023 11:59:58 GMT
Message-ID: <log-20220923202055@ram.dialup.fu-berlin.de>
References: <defensive-20220923184650@ram.dialup.fu-berlin.de> <tgkv84$1g7e$1@gioia.aioe.org> <logging-20220923195833@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de TMpMxXG2eaLJT1deP0y4OQwTLIIQbWgFKYF6gbsNc/442s
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Fri, 23 Sep 2022 19:21 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:
>This log file gets infrequent writes. Not more than 1000 per day.
>So to append a line, I always open the file for appending, write
>the line, and close it immediately.

But several different processes could append to that log file.

Re: Defensive programming

<tgl17e$cuj$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1835&group=comp.lang.misc#1835

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!aioe.org!epJzlJsZWlp1WuFmYLlBpQ.user.46.165.242.91.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.misc
Subject: Re: Defensive programming
Date: Fri, 23 Sep 2022 21:25:35 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tgl17e$cuj$1@gioia.aioe.org>
References: <defensive-20220923184650@ram.dialup.fu-berlin.de>
<tgkv84$1g7e$1@gioia.aioe.org>
<logging-20220923195833@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="13267"; posting-host="epJzlJsZWlp1WuFmYLlBpQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Fri, 23 Sep 2022 19:25 UTC

On 2022-09-23 20:58, Stefan Ram wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>> You should simply flush the log file periodically (keeping it open of
>> course).
>
> This log file gets infrequent writes. Not more than 1000 per day.
> So to append a line, I always open the file for appending, write
> the line, and close it immediately.

Keep it open. Flush after each write since it is infrequent.

If the file was opened for shared access then after flush you should be
able to read the file from outside, e.g. from Notepad++ etc.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Defensive programming

<log-20220923202848@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1836&group=comp.lang.misc#1836

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!aioe.org!news.mb-net.net!open-news-network.org!news.mind.de!bolzen.all.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.misc
Subject: Re: Defensive programming
Date: 23 Sep 2022 19:29:07 GMT
Organization: Stefan Ram
Lines: 6
Expires: 1 Sep 2023 11:59:58 GMT
Message-ID: <log-20220923202848@ram.dialup.fu-berlin.de>
References: <defensive-20220923184650@ram.dialup.fu-berlin.de> <tgkv84$1g7e$1@gioia.aioe.org> <logging-20220923195833@ram.dialup.fu-berlin.de> <log-20220923202055@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 5qEy1YA3d520hE7jNlsLFQquOXzLEqcHfAUTKVpiLvvG+C
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Fri, 23 Sep 2022 19:29 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:
>But several different processes could append to that log file.

Including batch files using ">>".

Re: Defensive programming

<open-20220923202948@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1837&group=comp.lang.misc#1837

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.misc
Subject: Re: Defensive programming
Date: 23 Sep 2022 19:30:26 GMT
Organization: Stefan Ram
Lines: 6
Expires: 1 Sep 2023 11:59:58 GMT
Message-ID: <open-20220923202948@ram.dialup.fu-berlin.de>
References: <defensive-20220923184650@ram.dialup.fu-berlin.de> <tgkv84$1g7e$1@gioia.aioe.org> <logging-20220923195833@ram.dialup.fu-berlin.de> <tgl17e$cuj$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de KOEnCI90LGpmJrx2h4UCcgjfi6mt66xgxwgM8LEz53qTI9
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Fri, 23 Sep 2022 19:30 UTC

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>Keep it open. Flush after each write since it is infrequent.

What's the problem this is supposed to be the solution to?

Re: Defensive programming

<tgl1j8$ibr$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1838&group=comp.lang.misc#1838

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!aioe.org!epJzlJsZWlp1WuFmYLlBpQ.user.46.165.242.91.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.misc
Subject: Re: Defensive programming
Date: Fri, 23 Sep 2022 21:31:53 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tgl1j8$ibr$1@gioia.aioe.org>
References: <defensive-20220923184650@ram.dialup.fu-berlin.de>
<tgkv84$1g7e$1@gioia.aioe.org>
<logging-20220923195833@ram.dialup.fu-berlin.de>
<log-20220923202055@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="18811"; posting-host="epJzlJsZWlp1WuFmYLlBpQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Fri, 23 Sep 2022 19:31 UTC

On 2022-09-23 21:21, Stefan Ram wrote:
> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>> This log file gets infrequent writes. Not more than 1000 per day.
>> So to append a line, I always open the file for appending, write
>> the line, and close it immediately.
>
> But several different processes could append to that log file.

Then you need something like a database to manage transactions to the
log in order to keep in consistent and properly interlock. If the file
is opened for shared write, you will get a mess. If not, you will fail
to open a locked file. The behavior will depend on the OS. E.g. Linux
does not even have a proper locking mechanism.

P.S. It is a bad idea anyway. Each process should have its own log file.
Supply messages with a time stamp if you want to be able to generate
some combined report later.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Defensive programming

<tgl1m5$ibr$2@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1839&group=comp.lang.misc#1839

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!aioe.org!epJzlJsZWlp1WuFmYLlBpQ.user.46.165.242.91.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.misc
Subject: Re: Defensive programming
Date: Fri, 23 Sep 2022 21:33:27 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tgl1m5$ibr$2@gioia.aioe.org>
References: <defensive-20220923184650@ram.dialup.fu-berlin.de>
<tgkv84$1g7e$1@gioia.aioe.org>
<logging-20220923195833@ram.dialup.fu-berlin.de>
<tgl17e$cuj$1@gioia.aioe.org> <open-20220923202948@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="18811"; posting-host="epJzlJsZWlp1WuFmYLlBpQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Fri, 23 Sep 2022 19:33 UTC

On 2022-09-23 21:30, Stefan Ram wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>> Keep it open. Flush after each write since it is infrequent.
>
> What's the problem this is supposed to be the solution to?

That upon system crash you won't lose all file, since it is never closed.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Defensive programming

<tgl1qn$ibr$3@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1840&group=comp.lang.misc#1840

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!aioe.org!epJzlJsZWlp1WuFmYLlBpQ.user.46.165.242.91.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.misc
Subject: Re: Defensive programming
Date: Fri, 23 Sep 2022 21:35:52 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tgl1qn$ibr$3@gioia.aioe.org>
References: <defensive-20220923184650@ram.dialup.fu-berlin.de>
<tgkv84$1g7e$1@gioia.aioe.org>
<logging-20220923195833@ram.dialup.fu-berlin.de>
<log-20220923202055@ram.dialup.fu-berlin.de>
<log-20220923202848@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="18811"; posting-host="epJzlJsZWlp1WuFmYLlBpQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Fri, 23 Sep 2022 19:35 UTC

On 2022-09-23 21:29, Stefan Ram wrote:
> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>> But several different processes could append to that log file.
>
> Including batch files using ">>".

Then mess is guaranteed! Batch files are perfect at this... (:-))

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Defensive programming

<open-20220923203955@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1841&group=comp.lang.misc#1841

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.misc
Subject: Re: Defensive programming
Date: 23 Sep 2022 19:41:47 GMT
Organization: Stefan Ram
Lines: 12
Expires: 1 Sep 2023 11:59:58 GMT
Message-ID: <open-20220923203955@ram.dialup.fu-berlin.de>
References: <defensive-20220923184650@ram.dialup.fu-berlin.de> <tgkv84$1g7e$1@gioia.aioe.org> <logging-20220923195833@ram.dialup.fu-berlin.de> <tgl17e$cuj$1@gioia.aioe.org> <open-20220923202948@ram.dialup.fu-berlin.de> <tgl1m5$ibr$2@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de TS0wwqAbkMMp/NTOoXNE1wdhsA7JrmEV7HgcgppwXRf7vE
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Fri, 23 Sep 2022 19:41 UTC

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>>"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>>>Keep it open. Flush after each write since it is infrequent.
>>What's the problem this is supposed to be the solution to?
>That upon system crash you won't lose all file, since it is never closed.

That's why I always keep it open as short as possible;
I immediately close it after every append. I think, ">>"
does this too. It might be open for append access few
seconds per day.

Re: Defensive programming

<tgl2lj$10vn$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1842&group=comp.lang.misc#1842

  copy link   Newsgroups: comp.lang.misc
Path: i2pn2.org!i2pn.org!aioe.org!epJzlJsZWlp1WuFmYLlBpQ.user.46.165.242.91.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.misc
Subject: Re: Defensive programming
Date: Fri, 23 Sep 2022 21:50:13 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tgl2lj$10vn$1@gioia.aioe.org>
References: <defensive-20220923184650@ram.dialup.fu-berlin.de>
<tgkv84$1g7e$1@gioia.aioe.org>
<logging-20220923195833@ram.dialup.fu-berlin.de>
<tgl17e$cuj$1@gioia.aioe.org> <open-20220923202948@ram.dialup.fu-berlin.de>
<tgl1m5$ibr$2@gioia.aioe.org> <open-20220923203955@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="33783"; posting-host="epJzlJsZWlp1WuFmYLlBpQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Fri, 23 Sep 2022 19:50 UTC

On 2022-09-23 21:41, Stefan Ram wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>>>> Keep it open. Flush after each write since it is infrequent.
>>> What's the problem this is supposed to be the solution to?
>> That upon system crash you won't lose all file, since it is never closed.
>
> That's why I always keep it open as short as possible;
> I immediately close it after every append. I think, ">>"
> does this too. It might be open for append access few
> seconds per day.

This explains well the problems you experience.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor