]>
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
=
37 #include "io_stream.h"
47 static LogEnt
*first_logent
= 0;
48 static LogEnt
**next_logent
= &first_logent
;
51 log (enum log_level level
, String
const &message
)
53 LogEnt
*l
= new LogEnt
;
58 next_logent
= &(l
->next
);
63 if (level
== LOG_TIMESTAMP
)
65 struct tm
*tm
= localtime (&(l
->when
));
66 strftime (b
, 1000, "%Y/%m/%d %H:%M:%S ", tm
);
68 l
->msg
= String (b
) + message
;
70 msg ("LOG: %d %s", l
->level
, l
->msg
.cstr_oneuse());
74 log (enum log_level level
, const char *fmt
, ...)
79 vsprintf (buf
, fmt
, args
);
80 log (level
, String(buf
));
84 log_save (int babble
, String
const &filename
, int append
)
86 static int been_here
= 0;
91 io_stream::mkpath_p (PATH_TO_FILE
, filename
);
93 io_stream
*f
= io_stream::open(String("file://")+filename
, append
? "at" : "wt");
96 fatal (NULL
, IDS_NOLOGFILE
, filename
.cstr_oneuse());
102 for (l
= first_logent
; l
; l
= l
->next
)
104 if (babble
|| !(l
->level
== LOG_BABBLE
))
106 char *tstr
= l
->msg
.cstr();
107 f
->write (tstr
, strlen (tstr
));
108 if (tstr
[strlen (tstr
) - 1] != '\n')
118 exit_setup (int exit_code
)
120 static int been_here
= 0;
126 note (NULL
, exit_msg
);
128 log (LOG_TIMESTAMP
, "Ending cygwin install");
130 if (source
== IDC_SOURCE_DOWNLOAD
|| !get_root_dir ().size())
132 log_save (LOG_BABBLE
, local_dir
+ "/setup.log.full", 0);
133 log_save (0, local_dir
+ "/setup.log", 1);
137 log_save (LOG_BABBLE
, cygpath ("/var/log/setup.log.full"), 0);
138 log_save (0, cygpath ("/var/log/setup.log"), 1);
141 ExitProcess (exit_code
);
This page took 0.08621 seconds and 5 git commands to generate.