Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
25525a6a
Commit
25525a6a
authored
5 years ago
by
James R.
Browse files
Options
Downloads
Patches
Plain Diff
symlink latest-log.txt on nix, copy to the real log file everywhere else
parent
98cb238d
No related branches found
No related tags found
2 merge requests
!734
Rebase Keycodes only branch.
,
!567
haha log files
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/doomdef.h
+1
-0
1 addition, 0 deletions
src/doomdef.h
src/sdl/i_main.c
+29
-11
29 additions, 11 deletions
src/sdl/i_main.c
src/sdl/i_system.c
+45
-0
45 additions, 0 deletions
src/sdl/i_system.c
with
75 additions
and
11 deletions
src/doomdef.h
+
1
−
0
View file @
25525a6a
...
...
@@ -127,6 +127,7 @@
#ifdef LOGMESSAGES
extern
FILE
*
logstream
;
extern
char
logfilename
[
1024
];
#endif
//#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3
...
...
This diff is collapsed.
Click to expand it.
src/sdl/i_main.c
+
29
−
11
View file @
25525a6a
...
...
@@ -23,10 +23,14 @@
#include
"../m_misc.h"
/* path shit */
#include
"../i_system.h"
#ifdef
__GNUC__
#if
def
ined (
__GNUC__
) || defined (__unix__)
#include
<unistd.h>
#endif
#ifdef __unix__
#include
<errno.h>
#endif
#include
"time.h"
// For log timestamps
#ifdef HAVE_SDL
...
...
@@ -48,6 +52,7 @@ extern int SDL_main(int argc, char *argv[]);
#ifdef LOGMESSAGES
FILE
*
logstream
=
NULL
;
char
logfilename
[
1024
];
#endif
#ifndef DOXYGEN
...
...
@@ -117,7 +122,6 @@ int main(int argc, char **argv)
#endif
{
const
char
*
logdir
=
NULL
;
char
logfile
[
MAX_WADPATH
];
myargc
=
argc
;
myargv
=
argv
;
/// \todo pull out path to exe from this string
...
...
@@ -157,7 +161,7 @@ int main(int argc, char **argv)
if
(
fileabs
)
{
strftime
(
logfile
,
sizeof
logfile
,
format
,
timeinfo
);
strftime
(
logfile
name
,
sizeof
logfile
name
,
format
,
timeinfo
);
}
else
{
...
...
@@ -168,32 +172,46 @@ int main(int argc, char **argv)
if
(
M_IsPathAbsolute
(
reldir
))
{
left
=
snprintf
(
logfile
,
sizeof
logfile
,
left
=
snprintf
(
logfile
name
,
sizeof
logfile
name
,
"%s"
PATHSEP
,
reldir
);
}
else
#ifdef DEFAULTDIR
if
(
logdir
)
{
left
=
snprintf
(
logfile
,
sizeof
logfile
,
left
=
snprintf
(
logfile
name
,
sizeof
logfile
name
,
"%s"
PATHSEP
DEFAULTDIR
PATHSEP
"%s"
PATHSEP
,
logdir
,
reldir
);
}
else
#endif
/*DEFAULTDIR*/
{
left
=
snprintf
(
logfile
,
sizeof
logfile
,
left
=
snprintf
(
logfile
name
,
sizeof
logfile
name
,
"."
PATHSEP
"%s"
PATHSEP
,
reldir
);
}
#endif
/*LOGMESSAGES*/
strftime
(
&
logfile
[
left
],
sizeof
logfile
-
left
,
format
,
timeinfo
);
strftime
(
&
logfilename
[
left
],
sizeof
logfilename
-
left
,
format
,
timeinfo
);
}
M_MkdirEachUntil
(
logfile
,
M_MkdirEachUntil
(
logfile
name
,
M_PathParts
(
logdir
)
-
1
,
M_PathParts
(
logfile
)
-
1
,
0755
);
M_PathParts
(
logfile
name
)
-
1
,
0755
);
logstream
=
fopen
(
logfile
,
"wt"
);
#ifdef __unix__
logstream
=
fopen
(
logfilename
,
"w"
);
#ifdef DEFAULTDIR
if
(
symlink
(
logfilename
,
va
(
"%s/"
DEFAULTDIR
"/latest-log.txt"
,
logdir
))
==
-
1
)
#else
if
(
symlink
(
logfilename
,
va
(
"%s/latest-log.txt"
,
logdir
))
==
-
1
)
#endif
/*DEFAULTDIR*/
{
I_OutputMsg
(
"Error symlinking latest-log.txt: %s
\n
"
,
strerror
(
errno
));
}
#else
/*__unix__*/
logstream
=
fopen
(
"latest-log.txt"
,
"wt+"
);
#endif
/*__unix__*/
}
//I_OutputMsg("I_StartupSystem() ...\n");
...
...
@@ -222,7 +240,7 @@ int main(int argc, char **argv)
D_SRB2Main
();
#ifdef LOGMESSAGES
if
(
!
M_CheckParm
(
"-nolog"
))
CONS_Printf
(
"Logfile: %s
\n
"
,
logfile
);
CONS_Printf
(
"Logfile: %s
\n
"
,
logfile
name
);
#endif
CONS_Printf
(
"Entering main game loop...
\n
"
);
// never return
...
...
This diff is collapsed.
Click to expand it.
src/sdl/i_system.c
+
45
−
0
View file @
25525a6a
...
...
@@ -2377,6 +2377,48 @@ void I_RemoveExitFunc(void (*func)())
}
}
#ifndef __unix__
static
void
Shittycopyerror
(
const
char
*
name
)
{
I_OutputMsg
(
"Error copying log file: %s: %s
\n
"
,
name
,
strerror
(
errno
)
);
}
static
void
Shittylogcopy
(
void
)
{
char
buf
[
8192
];
FILE
*
fp
;
int
n
;
if
(
fseek
(
logstream
,
0
,
SEEK_SET
)
==
-
1
)
{
Shittycopyerror
(
"fseek"
);
}
else
if
((
fp
=
fopen
(
logfilename
,
"wt"
)
))
{
while
((
n
=
fread
(
buf
,
1
,
sizeof
buf
,
logstream
)
))
{
if
(
fwrite
(
buf
,
1
,
n
,
fp
)
<
n
)
{
Shittycopyerror
(
"fwrite"
);
break
;
}
}
if
(
ferror
(
logstream
))
{
Shittycopyerror
(
"fread"
);
}
fclose
(
fp
);
}
else
{
Shittycopyerror
(
logfilename
);
}
}
#endif
/*__unix__*/
//
// Closes down everything. This includes restoring the initial
// palette and video mode, and removing whatever mouse, keyboard, and
...
...
@@ -2395,6 +2437,9 @@ void I_ShutdownSystem(void)
if
(
logstream
)
{
I_OutputMsg
(
"I_ShutdownSystem(): end of logstream.
\n
"
);
#ifndef __unix__
Shittylogcopy
();
#endif
fclose
(
logstream
);
logstream
=
NULL
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment