Persistent log files with map changes

I know there’s a way to do it but I can’t think of it. What would be the best way to create a persistent custom log file with map changes? Currently the system creates a log file with os.time() and has a set max size of 256kb, causing it to create a new log file after that size has been met. But with map changes it creates a new log file.

Right now the only thing creating the log file is this:

LogFile = "Logs/"..os.time()..".txt"

You can try writing if the file doesn’t exist and appending otherwise.

The issue with that is the fact that when you change maps it reloads the script so it creates a new log file with the new os.time(). If it was that simple I wouldn’t be asking.

Why don’t you use SQL?

Not if you add a file.Exists check?

Because I want hard files. I have SQL logging in place for some things but I want text logging for everything. Plus I don’t what too many SQL queries being ran.

Map change = new os.time(). If I were to file.Exists(“Logs/”…os.time()…".txt",“DATA”) it would be false as it would be a new time as the script would be running at a new time. Hence the question: how to make it work with map changes causing script resets and thus making a new LogFile and causing a new file each map.

In the past week and few days I’ve had the script up 512 log files have been made. Most of them just stating that the log file has started.

They are hard files. All SQL used on the server will be stored in sv.db in the root folder. This file can be browsed using sqlitebrowser. The queries using the garrysmod sql library use 0 bandwidth also, so there’s no real sense why you wouldn’t want the queries to run.

For your problem, it makes a lot more sense and would be easier and more practical, for browsing logs, to use SQL.

We have a custom system for admins to view the text logs. So making them SQLite would be impractical because it would be difficult to incorporate the existing system, especially considering the one who made it isn’t part of the community anymore. So I really would like it to be text logs and not sqlite.

ahh, okay.