all 14 comments

[–][deleted] 2 insightful - 2 fun2 insightful - 1 fun3 insightful - 2 fun -  (4 children)

[–]fschmidt[S] 2 insightful - 2 fun2 insightful - 1 fun3 insightful - 2 fun -  (3 children)

I need to write a post on why configuration files should be banned. Maybe next shabbat.

[–][deleted]  (2 children)

[deleted]

    [–]fschmidt[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (1 child)

    Then log rotate handles all the business logic seperate from my code, and I get to "code" the log storage behavior in a "language" designed for that task.

    Pointless separation is one big source of complexity. There is no reason for an end-user to ever configure logging. The app code should do that. And so it might as well do it purely through code, so no need for logrotate.

    [–]trident765 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (0 children)

    Pointless separation is one big source of complexity

    I was just thinking about this the other day. It's the thing people say to sound smart. People say to keep X and Y separate because it makes them look like they had the foresight to prevent some bad thing from happening if you mix X and Y. So people are stuck maintaining this pointless separation because if they were to question it they would look like stupid people who didn't have the foresight to understand why you have to keep X and Y separate.

    [–][deleted] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (0 children)

    That LogJ4 shit you linked is peak OO stupidity. IDK why people do that to themselves.

    [–]trident765 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (1 child)

    Doesn't this run the risk of running out of filenames if the user specifies too few?

    [–]fschmidt[S] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (0 children)

    No, the last file is just dumped. No need to keep logs forever.

    [–][deleted] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (7 children)

    Why don't you just rename the file if it's too big and call it a day?

    [–][deleted]  (1 child)

    [deleted]

      [–][deleted] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (0 children)

      Gotcha. Hey thanks man, I appreciate you taking the time to explain it.

      [–]fschmidt[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (4 children)

      Yes, it's "rolled over" by renaming it.

      [–][deleted] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (3 children)

      What I'm asking is why is this not 2 lines?

      If filesize(logfile) >= arbitrary_amount
      Rename(logfile, current_date + ".log")

      It's been a long time since I've done this shit, maybe I'm missing something you're doing

      [–]fschmidt[S] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (2 children)

      The only reason for more code is to allow multiple rolling backup files. Here is the code, it is quite simple.

      [–][deleted] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (1 child)

      I just didn't get why anything was moved, but x0 said it had to do with file descriptor staying open. That makes sense.

      [–]fschmidt[S] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (0 children)

      That only makes sense if this is done by an outside process. Since I am doing it in code in the same process, I just close the file descriptor, move the file, and open a new file descriptor. So none of the issues mentioned by x0x7 apply.