4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
27 * \file KMSAgentFatalState.cpp
32 #include "SYSCommon.h"
33 #include "KMSAgentStringUtilities.h"
34 #include "KMSAuditLogger.h"
36 #define MAX_TIME_STAMP_LENGTH 30
40 * append the state of the application in the <KMSAgentAuditLogger> log file.
42 void process_fatal_application_state(const char* sFile
,
43 const char* sFunction
,
45 const char* sAdditionalText
)
48 // File format: <date/time>,<operation>,<retention>,<audit id>,<network adddress>,<message>
49 char sFileLogEntry
[MAX_LOG_FILE_LINE_LENGTH
];
50 char sTimeStamp
[MAX_TIME_STAMP_LENGTH
];
53 GetCurrentDateTimeISO8601UTC(sTimeStamp
, MAX_TIME_STAMP_LENGTH
);
54 Int64ToUTF8(sLine
, iLine
, false, false);
56 strncpy(sFileLogEntry
, "A fatal application error has occurred. Date: ", sizeof(sFileLogEntry
));
58 sFileLogEntry
[sizeof(sFileLogEntry
)-1] = '\0';
60 strncat(sFileLogEntry
, sTimeStamp
, MAX_LOG_FILE_LINE_LENGTH
- strlen(sFileLogEntry
));
62 strncat(sFileLogEntry
, " File: ", MAX_LOG_FILE_LINE_LENGTH
- strlen(sFileLogEntry
));
64 strncat(sFileLogEntry
, sFile
, MAX_LOG_FILE_LINE_LENGTH
- strlen(sFileLogEntry
));
66 strncat(sFileLogEntry
, " Function: ", MAX_LOG_FILE_LINE_LENGTH
- strlen(sFileLogEntry
));
68 strncat(sFileLogEntry
, sFunction
, MAX_LOG_FILE_LINE_LENGTH
- strlen(sFileLogEntry
));
70 strncat(sFileLogEntry
, " Line: ", MAX_LOG_FILE_LINE_LENGTH
- strlen(sFileLogEntry
));
72 strncat(sFileLogEntry
, sLine
, MAX_LOG_FILE_LINE_LENGTH
- strlen(sFileLogEntry
));
74 LogToFile( 0, sFileLogEntry
);