Class JKLogServiceClient

java.lang.Object
com.jk.services.client.logging.JKLogServiceClient

public class JKLogServiceClient extends Object
This class provides a client interface for logging messages to the remote logging service.

It allows you to log messages with different severity levels and send them to the remote logging microservice.

Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Summary

    Constructors
    Constructor
    Description
    This method constructs a new with the logging service base URL and initializes the client.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    callAddLog(String message, String severity)
    This method logs a message with the specified severity level to the remote logging service.
    void
    callDebug(String message)
    This method logs a debug-level message to the remote logging service.
    void
    callError(String message)
    This method logs an error-level message to the remote logging service.
    void
    callInfo(String message)
    This method logs an info-level message to the remote logging service.
    void
    callTrace(String message)
    This method logs a trace-level message to the remote logging service.
    void
    callWarn(String message)
    This method logs a warn-level message to the remote logging service.
    getAppLogCount(String appName, boolean reset)
    This method retrieves the count of log entries for a specific application from the remote logging service.
    getAppLogs(String appName, boolean reset)
    This method retrieves a list of log entries for a specific application from the remote logging service.
    static Boolean
    THis method checks whether log messages should be sent asynchronously.
    static boolean
    This method checks whether the logging service client is enabled based on the configuration.
    static void
    setRunAsync(Boolean runAsync)
    This method sets whether log messages should be sent asynchronously (true) or not (false).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JKLogServiceClient

      public JKLogServiceClient()
      This method constructs a new with the logging service base URL and initializes the client.
      See Also:
  • Method Details

    • callTrace

      public void callTrace(String message)
      This method logs a trace-level message to the remote logging service.
      Parameters:
      message - Specifies the message to be logged.
    • callDebug

      public void callDebug(String message)
      This method logs a debug-level message to the remote logging service.
      Parameters:
      message - Specifies the message to be logged.
    • callInfo

      public void callInfo(String message)
      This method logs an info-level message to the remote logging service.
      Parameters:
      message - Specifies the message to be logged.
    • callWarn

      public void callWarn(String message)
      This method logs a warn-level message to the remote logging service.
      Parameters:
      message - Specifies the message to be logged.
    • callError

      public void callError(String message)
      This method logs an error-level message to the remote logging service.
      Parameters:
      message - Specifies the message to be logged.
    • callAddLog

      public void callAddLog(String message, String severity)
      This method logs a message with the specified severity level to the remote logging service.
      Parameters:
      message - Specifies the message to be logged.
      severity - Specifies the severity level of the log entry.
    • getAppLogCount

      public Integer getAppLogCount(String appName, boolean reset)
      This method retrieves the count of log entries for a specific application from the remote logging service.
      Parameters:
      appName - Specifies the name of the application for which log entries are counted.
      reset - Indicates whether to reset the log count after retrieval (true) or not (false).
      Returns:
      an integer representing the count of log entries for the specified application, or null if logging is not enabled.
    • getAppLogs

      public List<JKLog> getAppLogs(String appName, boolean reset)
      This method retrieves a list of log entries for a specific application from the remote logging service.
      Parameters:
      appName - Specifies the name of the application for which log entries are retrieved.
      reset - Indicates whether to reset the log count after retrieval (true) or not (false).
      Returns:
      a list of JKLog objects representing the log entries for the specified application, or an empty list if logging is not enabled.
    • isEnabled

      public static boolean isEnabled()
      This method checks whether the logging service client is enabled based on the configuration.
      Returns:
      true, if the logging service client is enabled, false otherwise.
    • getRunAsync

      public static Boolean getRunAsync()
      THis method checks whether log messages should be sent asynchronously.
      Returns:
      true, if the log messages should be sent asynchronously, false otherwise.
    • setRunAsync

      public static void setRunAsync(Boolean runAsync)
      This method sets whether log messages should be sent asynchronously (true) or not (false).
      Parameters:
      runAsync - Indicates whether log messages should be sent asynchronously (true) or not (false).