CXI
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
CryptoServerLog Class Reference

This class provides methods to write a log file. More...

Classes

enum  LogLevel
 Log level to be set on CryptoServerLog.CryptoServerLog and CryptoServerLog.init. More...
 

Public Member Functions

void init (String filename, int level, int size)
 Initializes a log file with the given name, level and maximum size. More...
 
void init (String filename, LogLevel level, int size)
 Initializes a log file with the given name, level and maximum size. More...
 
void init (CryptoServerConfig config)
 Initializes log file according to the given configuration object. More...
 
 CryptoServerLog ()
 Creates a default log file ("CryptoServer.log") with a default log level (LOG_LEVEL_WARNING) and a default maximum size of 1MB.
 
 CryptoServerLog (String filename, int level, int size)
 Creates a log file with the given name, level and maximum size. More...
 
 CryptoServerLog (String filename, LogLevel level, int size)
 Initializes a log file with the given name, level and maximum size. More...
 
 CryptoServerLog (CryptoServerConfig config)
 Initializes log file according to the given configuration object. More...
 
void print (String where, String format, Object...args)
 Prints a new log entry. More...
 
void xtrace (String where, String message, byte[] data)
 Writes binary data to the log file. More...
 

Detailed Description

This class provides methods to write a log file.


Example:

The following example illustrates the usage of the CryptoServerLog class:

CryptoServerLog log = new CryptoServerLog("c:/temp/CryptoServer.log", CryptoServerLog.LogLevel.Info, 0x200000);
...
log.print("Method1", "E: key generation failed with code: 0x%08x", err);
...
byte [] blob = cxi.exportKey(...);
log.xtrace("Method1", "I: Key blob returned by the CryptoServer", blob);
This class provides methods to write a log file.
Definition: CryptoServerLog.java:26
void print(String where, String format, Object...args)
Prints a new log entry.
Definition: CryptoServerLog.java:221
CryptoServerLog()
Creates a default log file ("CryptoServer.log") with a default log level (LOG_LEVEL_WARNING) and a de...
Definition: CryptoServerLog.java:160
void xtrace(String where, String message, byte[] data)
Writes binary data to the log file.
Definition: CryptoServerLog.java:270
Log level to be set on CryptoServerLog.CryptoServerLog and CryptoServerLog.init.
Definition: CryptoServerLog.java:39
Info
Additionally write informational messages to log file (3)
Definition: CryptoServerLog.java:43

Constructor & Destructor Documentation

◆ CryptoServerLog() [1/3]

CryptoServerLog ( String  filename,
int  level,
int  size 
)

Creates a log file with the given name, level and maximum size.

Parameters
filenameName of the log file including path.
levelLog level to be applied:
  • LOG_LEVEL_NONE - disable logging
  • LOG_LEVEL_ERROR - log error messages
  • LOG_LEVEL_WARNING - log error messages and warnings
  • LOG_LEVEL_INFO - log error messages, warnings and informational messages
  • LOG_LEVEL_TRACE - additionally trace data
sizeMaximum log file size.
Deprecated:
As of CryptoServerAPI version 1.41 replaced by CryptoServerAPI.CryptoServerLog.CryptoServerLog(String filename, LogLevel level, int size)

◆ CryptoServerLog() [2/3]

CryptoServerLog ( String  filename,
LogLevel  level,
int  size 
)

Initializes a log file with the given name, level and maximum size.

Parameters
filenameName of the log file including path.
levelLog level to be applied (see LogLevel)
sizeMaximum log file size.
If the actual log file size extends this limit the log file is renamed to *.bak and a new log file is created.
Note
If the log size value is given as '0' the log file may grow without limitation.

◆ CryptoServerLog() [3/3]

Initializes log file according to the given configuration object.

Parameters
configConfiguration object. The following key names will be recognized:

Key Mandatory Default Value Description
LogFile No "" Filename (including path) of log file to be written. Use forward slashes as path separator (even on Windows).
LogLevel No LogLevel.None Log level to be applied (see LogLevel)
LogSize No 1MB Maximum log file size before log file is rotated.
The integer value may optionally be followed by a tag ('KB', 'MB' or 'GB').
If this value is configured as '0' log file may grow without limitation.


Member Function Documentation

◆ init() [1/3]

void init ( String  filename,
int  level,
int  size 
)

Initializes a log file with the given name, level and maximum size.

Parameters
filenameName of the log file including path.
levelLog level to be applied:
  • LOG_LEVEL_NONE - disable logging
  • LOG_LEVEL_ERROR - log error messages
  • LOG_LEVEL_WARNING - log error messages and warnings
  • LOG_LEVEL_INFO - log error messages, warnings and informational messages
  • LOG_LEVEL_TRACE - additionally trace data
sizeMaximum log file size.
If the actual log file size extends this limit the log file is renamed to *.bak and a new log file is created.
Note
If the log size value is given as '0' the log file may grow without limitation.
Deprecated:
As of CryptoServerAPI version 1.41 replaced by CryptoServerAPI.CryptoServerLog.init(String filename, LogLevel level, int size)

◆ init() [2/3]

void init ( String  filename,
LogLevel  level,
int  size 
)

Initializes a log file with the given name, level and maximum size.

Parameters
filenameName of the log file including path.
levelLog level to be applied (see LogLevel)
sizeMaximum log file size.
If the actual log file size extends this limit the log file is renamed to *.bak and a new log file is created.
Note
If the log size value is given as '0' the log file may grow without limitation.

◆ init() [3/3]

void init ( CryptoServerConfig  config)

Initializes log file according to the given configuration object.

Parameters
configConfiguration object. The following key names will be recognized:

Key Mandatory Default Value Description
LogFile No "" Filename (including path) of log file to be written. Use forward slashes as path separator (even on Windows).
LogLevel No LogLevel.None Log level to be applied (see LogLevel)
LogSize No 1MB Maximum log file size before log file is rotated.
The integer value may optionally be followed by a tag ('KB', 'MB' or 'GB').
If this value is configured as '0' log file may grow without limitation.


◆ print()

void print ( String  where,
String  format,
Object...  args 
)

Prints a new log entry.


Parameters
whereLocation / method name where log message is written.
formatFormat string. The string can be prefixed by either 'E:', 'W:', "I:' or 'T:' to indicated at which log level the entry will be printed.
argsArgument list.

◆ xtrace()

void xtrace ( String  where,
String  message,
byte[]  data 
)

Writes binary data to the log file.

The data printed as a hexadecimal dump.

Parameters
whereLocation / method name where log message is written.
messageMessage that prefixes the binary dump. The message can be prefixed by either 'E:', 'W:', "I:' or 'T:' to indicated at which log level the entry will be printed.
dataBinary data to be printed to the log file.