/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "util.h"
#include <time.h>
#include <errno.h>
#include "proc_md.h"
#include "log_messages.h"
#ifdef JDWP_LOGGING
/* Static variables (should be protected with mutex) */
static int logging;
static int open_count;
/* Ascii id of current native thread. */
static void
{
unsigned millisecs = 0;
time_t t = 0;
t = 0;
/* Break this string up for SCCS's sake */
"%" "d.%" "m.%" "Y %" "T.%%.3d %" "Z", localtime(&t));
}
/* Get basename of filename */
static const char *
{
char *p1;
char *p2;
return "unknown";
}
return file;
}
/* Fill in the exact source location of the LOG entry. */
static void
{
"%s:\"%s\":%d;",
}
/* Begin a log entry. */
void
{
if ( logging ) {
location_stamp[0] = 0;
}
}
/* Standard Logging Format Entry */
static void
const char *datetime,
const char *level,
const char *product,
const char *module,
const char *optional,
const char *messageID,
const char *message)
{
const char *format;
/* "[#|Date&Time&Zone|LogLevel|ProductName|ModuleID|
* OptionalKey1=Value1;OptionalKeyN=ValueN|MessageID:MessageText|#]\n"
*/
format="[#|%s|%s|%s|%s|%s|%s:%s|#]\n";
message);
}
/* End a log entry */
void
{
if ( logging ) {
const char *level;
const char *product;
const char *module;
const char *messageID;
/* Grab the location, start file if needed, and clear the lock */
open_count++;
} else {
logging = 0;
}
}
/* Get the rest of the needed information */
tid = GET_THREAD_ID();
"LOC=%s;PID=%d;THR=t@%d",
(int)processPid,
(int)tid);
/* Construct message string. */
/* Send out standard logging format message */
message);
}
location_stamp[0] = 0;
}
}
#endif
/* Set up the logging with the name of a logging file. */
void
{
#ifdef JDWP_LOGGING
/* Turn off logging */
logging = 0;
/* Just return if not doing logging */
return;
/* Create potential filename for logging */
processPid = GETPID();
/* Turn on logging (do this last) */
logging = 1;
#endif
}
/* Finish up logging, flush output to the logfile. */
void
{
#ifdef JDWP_LOGGING
if ( logging ) {
logging = 0;
}
}
#endif
}