]>
cygwin.com Git - cygwin-apps/setup.git/blob - log.cc
2 * Copyright (c) 2000, Red Hat, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by DJ Delorie <dj@redhat.com>
16 /* The purpose of this file is to centralize all the logging functions. */
19 static const char *cvsid
=
46 static LogEnt
*first_logent
= 0;
47 static LogEnt
**next_logent
= &first_logent
;
50 log (int flags
, const char *fmt
, ...)
55 vsprintf (buf
, fmt
, args
);
57 LogEnt
*l
= (LogEnt
*) malloc (sizeof (LogEnt
) + strlen (buf
) + 20);
62 next_logent
= &(l
->next
);
65 if (flags
& LOG_TIMESTAMP
)
67 struct tm
*tm
= localtime (&(l
->when
));
68 strftime (b
, 1000, "%Y/%m/%d %H:%M:%S ", tm
);
73 msg ("LOG: %d %s", l
->flags
, l
->msg
);
77 log_save (int babble
, const char *filename
, int append
)
79 static int been_here
= 0;
84 mkdir_p (0, filename
);
86 FILE *f
= fopen (filename
, append
? "at" : "wt");
89 fatal (NULL
, IDS_NOLOGFILE
, filename
);
95 for (l
= first_logent
; l
; l
= l
->next
)
97 if (babble
|| !(l
->flags
& LOG_BABBLE
))
100 if (l
->msg
[strlen (l
->msg
) - 1] != '\n')
110 exit_setup (int exit_code
)
112 static int been_here
= 0;
118 note (NULL
, exit_msg
);
120 log (LOG_TIMESTAMP
, "Ending cygwin install");
122 if (source
== IDC_SOURCE_DOWNLOAD
|| !get_root_dir ())
124 log_save (LOG_BABBLE
, concat (local_dir
, "/setup.log.full", 0), 0);
125 log_save (0, concat (local_dir
, "/setup.log", 0), 1);
129 log_save (LOG_BABBLE
, cygpath ("/setup.log.full", 0), 0);
130 log_save (0, cygpath ("/setup.log", 0), 1);
133 ExitProcess (exit_code
);
This page took 0.039115 seconds and 5 git commands to generate.