mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
dist: Support strftime-style date formatting in log_filename
Fixes #1103
This commit is contained in:
parent
068ceaaf58
commit
f55cdd8907
5
direct/src/dist/FreezeTool.py
vendored
5
direct/src/dist/FreezeTool.py
vendored
@ -1735,7 +1735,7 @@ class Freezer:
|
|||||||
return target
|
return target
|
||||||
|
|
||||||
def generateRuntimeFromStub(self, target, stub_file, use_console, fields={},
|
def generateRuntimeFromStub(self, target, stub_file, use_console, fields={},
|
||||||
log_append=False):
|
log_append=False, log_filename_strftime=False):
|
||||||
self.__replacePaths()
|
self.__replacePaths()
|
||||||
|
|
||||||
# We must have a __main__ module to make an exe file.
|
# We must have a __main__ module to make an exe file.
|
||||||
@ -1906,9 +1906,12 @@ class Freezer:
|
|||||||
# A null entry marks the end of the module table.
|
# A null entry marks the end of the module table.
|
||||||
blob += struct.pack(entry_layout, 0, 0, 0)
|
blob += struct.pack(entry_layout, 0, 0, 0)
|
||||||
|
|
||||||
|
# These flags should match the enum in deploy-stub.c
|
||||||
flags = 0
|
flags = 0
|
||||||
if log_append:
|
if log_append:
|
||||||
flags |= 1
|
flags |= 1
|
||||||
|
if log_filename_strftime:
|
||||||
|
flags |= 2
|
||||||
|
|
||||||
# Compose the header we will be writing to the stub, to tell it
|
# Compose the header we will be writing to the stub, to tell it
|
||||||
# where to find the module data blob, as well as other variables.
|
# where to find the module data blob, as well as other variables.
|
||||||
|
3
direct/src/dist/commands.py
vendored
3
direct/src/dist/commands.py
vendored
@ -247,6 +247,7 @@ class build_apps(setuptools.Command):
|
|||||||
self.extra_prc_data = ''
|
self.extra_prc_data = ''
|
||||||
self.default_prc_dir = None
|
self.default_prc_dir = None
|
||||||
self.log_filename = None
|
self.log_filename = None
|
||||||
|
self.log_filename_strftime = False
|
||||||
self.log_append = False
|
self.log_append = False
|
||||||
self.requirements_path = os.path.join(os.getcwd(), 'requirements.txt')
|
self.requirements_path = os.path.join(os.getcwd(), 'requirements.txt')
|
||||||
self.use_optimized_wheels = True
|
self.use_optimized_wheels = True
|
||||||
@ -786,7 +787,7 @@ class build_apps(setuptools.Command):
|
|||||||
'prc_executable_args_envvar': None,
|
'prc_executable_args_envvar': None,
|
||||||
'main_dir': None,
|
'main_dir': None,
|
||||||
'log_filename': self.expand_path(self.log_filename, platform),
|
'log_filename': self.expand_path(self.log_filename, platform),
|
||||||
}, self.log_append)
|
}, self.log_append, self.log_filename_strftime)
|
||||||
stub_file.close()
|
stub_file.close()
|
||||||
|
|
||||||
if temp_file:
|
if temp_file:
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
/* Stored in the flags field of the blobinfo structure below. */
|
/* Stored in the flags field of the blobinfo structure below. */
|
||||||
enum Flags {
|
enum Flags {
|
||||||
F_log_append = 1,
|
F_log_append = 1,
|
||||||
|
F_log_filename_strftime = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Define an exposed symbol where we store the offset to the module data. */
|
/* Define an exposed symbol where we store the offset to the module data. */
|
||||||
@ -786,6 +787,14 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (log_filename != NULL) {
|
if (log_filename != NULL) {
|
||||||
|
char log_filename_buf[PATH_MAX];
|
||||||
|
if (blobinfo.flags & F_log_filename_strftime) {
|
||||||
|
log_filename_buf[0] = 0;
|
||||||
|
time_t now = time(NULL);
|
||||||
|
if (strftime(log_filename_buf, sizeof(log_filename_buf), log_filename, localtime(&now)) > 0) {
|
||||||
|
log_filename = &log_filename_buf;
|
||||||
|
}
|
||||||
|
}
|
||||||
setup_logging(log_filename, (blobinfo.flags & F_log_append) != 0);
|
setup_logging(log_filename, (blobinfo.flags & F_log_append) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user