author | herrick |
Fri, 08 Nov 2019 14:53:03 -0500 | |
branch | JDK-8200758-branch |
changeset 58994 | b09ba68c6a19 |
parent 57909 | src/jdk.jpackage/windows/native/libjpackage/Log.h@c7de06ed4b54 |
permissions | -rw-r--r-- |
57413
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
1 |
/* |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
4 |
* |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
10 |
* |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
15 |
* accompanied this code). |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
16 |
* |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
20 |
* |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
23 |
* questions. |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
24 |
*/ |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
25 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
26 |
#ifndef __LOG_H_INCLUDED_ |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
27 |
#define __LOG_H_INCLUDED_ |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
28 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
29 |
#include <windows.h> |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
30 |
#include "tstrings.h" |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
31 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
32 |
|
57909
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
33 |
/* Default logger (Logger::defaultLogger()) writes log messages to |
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
34 |
* the default log file. |
57413
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
35 |
* Common scenario: |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
36 |
* - main() function configures default logger: |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
37 |
* FileLogAppender appender(_T("my_log_filename.log")); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
38 |
* Logger::defaultLogger().setAppender(appender); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
39 |
* Logger::defaultLogger().setLogLevel(LOG_INFO); |
57909
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
40 |
* If the default file name and log level are not set, |
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
41 |
* _T("jusched.log")/LOG_TRACE are used. |
57413
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
42 |
* |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
43 |
* Logger fileName specifies only file name, |
57909
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
44 |
* full path for the log file depends on the platform |
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
45 |
* (usually value of the TMP env. var) |
57413
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
46 |
*/ |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
47 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
48 |
struct LogEvent { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
49 |
SYSTEMTIME ts; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
50 |
long tid; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
51 |
long pid; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
52 |
tstring moduleName; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
53 |
tstring logLevel; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
54 |
tstring fileName; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
55 |
int lineNum; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
56 |
tstring funcName; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
57 |
tstring message; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
58 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
59 |
LogEvent(); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
60 |
}; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
61 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
62 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
63 |
class LogAppender { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
64 |
public: |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
65 |
virtual ~LogAppender() { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
66 |
} |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
67 |
virtual void append(const LogEvent& v) = 0; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
68 |
}; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
69 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
70 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
71 |
class NopLogAppender: public LogAppender { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
72 |
public: |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
73 |
virtual void append(const LogEvent& v) {}; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
74 |
}; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
75 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
76 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
77 |
class TeeLogAppender: public LogAppender { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
78 |
public: |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
79 |
TeeLogAppender(LogAppender* first, LogAppender* second): |
57909
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
80 |
first(first), second(second) { |
57413
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
81 |
} |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
82 |
virtual ~TeeLogAppender() { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
83 |
} |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
84 |
virtual void append(const LogEvent& v) { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
85 |
if (first) { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
86 |
first->append(v); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
87 |
} |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
88 |
if (second) { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
89 |
second->append(v); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
90 |
} |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
91 |
} |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
92 |
private: |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
93 |
LogAppender* first; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
94 |
LogAppender* second; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
95 |
}; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
96 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
97 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
98 |
/** |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
99 |
* Writes log events to stderr. |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
100 |
*/ |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
101 |
class StderrLogAppender: public LogAppender { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
102 |
public: |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
103 |
explicit StderrLogAppender(); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
104 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
105 |
virtual void append(const LogEvent& v); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
106 |
}; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
107 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
108 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
109 |
class Logger { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
110 |
public: |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
111 |
enum LogLevel { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
112 |
LOG_TRACE, |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
113 |
LOG_INFO, |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
114 |
LOG_WARNING, |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
115 |
LOG_ERROR |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
116 |
}; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
117 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
118 |
static Logger& defaultLogger(); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
119 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
120 |
explicit Logger(LogAppender& appender, LogLevel logLevel = LOG_TRACE); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
121 |
~Logger(); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
122 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
123 |
LogAppender& setAppender(LogAppender& v) { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
124 |
LogAppender& oldAppender = *appender; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
125 |
appender = &v; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
126 |
return oldAppender; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
127 |
} |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
128 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
129 |
LogAppender& getAppender() const { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
130 |
return *appender; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
131 |
} |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
132 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
133 |
void setLogLevel(LogLevel logLevel); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
134 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
135 |
bool isLoggable(LogLevel logLevel) const ; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
136 |
void log(LogLevel logLevel, LPCTSTR fileName, int lineNum, |
57909
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
137 |
LPCTSTR funcName, const tstring& message) const; |
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
138 |
void log(LogLevel logLevel, LPCTSTR fileName, int lineNum, |
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
139 |
LPCTSTR funcName, const tstrings::any& message) const { |
57413
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
140 |
return log(logLevel, fileName, lineNum, funcName, message.tstr()); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
141 |
} |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
142 |
void log(LogLevel logLevel, LPCTSTR fileName, int lineNum, |
57909
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
143 |
LPCTSTR funcName, tstring::const_pointer message) const { |
57413
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
144 |
return log(logLevel, fileName, lineNum, funcName, tstring(message)); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
145 |
} |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
146 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
147 |
// internal class for scope tracing |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
148 |
class ScopeTracer { |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
149 |
public: |
57909
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
150 |
ScopeTracer(Logger &logger, LogLevel logLevel, LPCTSTR fileName, |
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57413
diff
changeset
|
151 |
int lineNum, LPCTSTR funcName, const tstring& scopeName); |
57413
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
152 |
~ScopeTracer(); |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
153 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
154 |
private: |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
155 |
const Logger &log; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
156 |
const LogLevel level; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
157 |
const bool needLog; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
158 |
const tstring file; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
159 |
const int line; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
160 |
const tstring func; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
161 |
const tstring scope; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
162 |
}; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
163 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
164 |
private: |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
165 |
LogLevel level; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
166 |
LogAppender* appender; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
167 |
}; |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
168 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
169 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
170 |
// base logging macro |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
171 |
#define LOGGER_LOG(logger, logLevel, message) \ |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
172 |
do { \ |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
173 |
if (logger.isLoggable(logLevel)) { \ |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
174 |
logger.log(logLevel, _T(__FILE__), __LINE__, _T(__FUNCTION__), message); \ |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
175 |
} \ |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
176 |
} while(false) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
177 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
178 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
179 |
// custom logger macros |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
180 |
#define LOGGER_TRACE(logger, message) LOGGER_LOG(logger, Logger::LOG_TRACE, message) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
181 |
#define LOGGER_INFO(logger, message) LOGGER_LOG(logger, Logger::LOG_INFO, message) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
182 |
#define LOGGER_WARNING(logger, message) LOGGER_LOG(logger, Logger::LOG_WARNING, message) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
183 |
#define LOGGER_ERROR(logger, message) LOGGER_LOG(logger, Logger::LOG_ERROR, message) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
184 |
// scope tracing macros |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
185 |
#define LOGGER_TRACE_SCOPE(logger, scopeName) \ |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
186 |
Logger::ScopeTracer tracer__COUNTER__(logger, Logger::LOG_TRACE, _T(__FILE__), __LINE__, _T(__FUNCTION__), scopeName) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
187 |
#define LOGGER_TRACE_FUNCTION(logger) LOGGER_TRACE_SCOPE(logger, _T(__FUNCTION__)) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
188 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
189 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
190 |
// default logger macros |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
191 |
#define LOG_TRACE(message) LOGGER_LOG(Logger::defaultLogger(), Logger::LOG_TRACE, message) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
192 |
#define LOG_INFO(message) LOGGER_LOG(Logger::defaultLogger(), Logger::LOG_INFO, message) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
193 |
#define LOG_WARNING(message) LOGGER_LOG(Logger::defaultLogger(), Logger::LOG_WARNING, message) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
194 |
#define LOG_ERROR(message) LOGGER_LOG(Logger::defaultLogger(), Logger::LOG_ERROR, message) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
195 |
// scope tracing macros |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
196 |
// logs (_T("Entering ") + scopeName) at the beging, (_T("Exiting ") + scopeName) at the end of scope |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
197 |
#define LOG_TRACE_SCOPE(scopeName) LOGGER_TRACE_SCOPE(Logger::defaultLogger(), scopeName) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
198 |
// logs (_T("Entering ") + functionName) at the beging, (_T("Exiting ") + __FUNCTION__) at the end of scope |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
199 |
#define LOG_TRACE_FUNCTION() LOGGER_TRACE_FUNCTION(Logger::defaultLogger()) |
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
200 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
201 |
|
45c74e654794
8221333: Replace Inno Setup with custom MSI wrapper for .exe bundler (missed files)
herrick
parents:
diff
changeset
|
202 |
#endif // __LOG_H_INCLUDED_ |