App42 Cloud API

PHP cloud SDK

Log

Centralize logging for your App. This service allows different levels e.g. info, debug, fatal, error etc. to log a message and query the messages based on different parameters. You can fetch logs based on module, level, message, date range etc.

In order to use the various functions available under a particular API, a developer will have to create an instance of ServiceAPI by passing the apiKey and the secretKey which has been received while creating an app.

	$api = new ServiceAPI("<API_KEY>","<SECRET_KEY>"); 

After initialization, developer needs to call the buildXXXService method on ServiceAPI instance to get the instance of the particular API that you wish to build. For example, To build an instance of LogService, buildLogService() method needs to be called.

	$logService = $api->buildLogService();

Once the API instance has been retrieved, You are ready to use the functions available for that particular API.

The methods available under a particular API will return the user domain object (like Logs in this case) as a response which will have the accessor / mutator to access the available properties for that object. You can get the response in the form of JSON as well. We have provided the JSON response with every function detail which can be retrieved by calling the toString() on the returned object.

$message = "Info logs";
$module =	"testmod";
	
$logs = $logService->info($message,$module);   /* returns the Log object. */ 
$messageList =  $logs->getMessageList();
for($messageList as $msg)
{    
print_r("msg is" . $msg->getMessage());
print_r("module is" . $msg->getModule());
print_r("type is" . $msg->getType());
print_r("logTime is" . $msg->getLogTime());
}   
$jsonResponse = $logs->toString(); /* returns the response in JSON format. */ 
                            

The functions available under Logging API can throw some exceptions in abnormal conditions. Example of the same has been given below.

E.g. If App developer is requesting the logs for the module which is not in the database, the function will throw the Exception with message as "Not Found" and the appErrorCode as "2700" and the details as "Logs for the module '<module>' does not exist.".

$moduleName =	"testmod";							
try{
	$log = $logService->fetchLogsByModule($moduleName);
} catch(App42Exception $ex) {
	$appErrorCode = $ex->getAppErrorCode();
	$httpErrorCode = $ex->getHttpErrorCode();
	if($appErrorCode == 2700)
{
    // Handle here for Not Found (Logs for the module '<module>' does not exist.)
}
    else if($appErrorCode == 1401){
    // handle here for Client is not authorized
}
    else if($appErrorCode == 1500){
    // handle here for Internal Server Error
}	
	$jsonText = $ex->getMessage(); /* returns the Exception text in JSON format. (as shown below)*/	
}
                            
	{
		"app42Fault": {
			"httpErrorCode": 404,
			"appErrorCode": 2700,
			"message": "Not Found",
			"details": "Logs for the module 'testmod' does not exist"
		}
	}							

Below are the HTTP Error Codes and their description, the function under the Logging API can throw.

/*
1400 - BAD REQUEST - The Request parameters are invalid
1401 - UNAUTHORIZED - Client is not authorized
1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again	
*/						

Below are the Application Error Codes and their description, the function under the Logging API can throw.

/*
2700 - NOT FOUND - Logs for the module '<module>' does not exist.
2701 - NOT FOUND - Logs for the type '<type>' does not exist.
2702 - Not Found - Logs betweem startDate '<startDate>' and endDate '<endDate>' does not exist.     
2703 - NOT FOUND - Logs for the module '<module>' with text '<text>' does not exist.
2704 - NOT FOUND - The number of logs for the module '<module>' are less than the specified offset : <offset>.
2705 - NOT FOUND - The number of logs for the type '<type>' are less than the specified offset : <offset>.
2706 - NOT FOUND - The number of logs betweem startDate '<startDate>' and endDate '<endDate>' are less than the specified offset : <offset>.
2707 - NOT FOUND - The number of logs for the module '<module>' with text '<text>' are less than the specified offset : <offset>.
*/				

Various functions available under Logging API has been explained below.

function info($msg, $module)

Logs the info message

Parameters:

msg - Message to be logged
module - Module name for which the message is getting logged

Returns:

Log object containing logged message

Response: Log Object

For more details click Exception
$msg = "Info logs";
$module =	"testmod";
							
$log = $logService->info($message,$module);   /* returns the Log object. */ 
$messageList =  $log->getMessageList();  
foreach( $messageList as $message ){
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "Info logs",
                    "type": "INFO",
                    "logTime": "2012-05-09T12:38:17.437Z",
                    "module": "testmod"
                }
            }
        }
    }
}
function debug($msg, $module)

Logs the debug message

Parameters:

msg - Message to be logged
module - Module name for which the message is getting logged

Returns:

Log object containing logged message

Response: Log Object

For more details click Exception
$msg = "Debug logs";
$module =	"testmod";

$log = $logService->debug($msg, $module);   /* returns the Log object. */ 
$messageList =  $log->getMessageList();  
foreach( $messageList as $message ){
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "Debug logs",
                    "type": "DEBUG",
                    "logTime": "2012-05-09T12:39:33.237Z",
                    "module": "testmod"
                }
            }
        }
    }
}
function fatal($msg, $module)

Logs the fatal message

Parameters:

msg - Message to be logged
module - Module name for which the message is getting logged

Returns:

Log object containing logged message

Response: Log Object

For more details click Exception
$msg = "Fatal logs";
$module =	"testmod";

$log = $logService->fatal($msg, $module);   /* returns the Log object. */ 
$messageList =  $log->getMessageList();  
foreach( $messageList as $message ){
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
 }
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/ 
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "Fatal logs",
                    "type": "FATAL",
                    "logTime": "2012-05-09T12:40:49.678Z",
                    "module": "testmod"
                }
            }
        }
    }
}
function error($msg, $module)

Logs the error message

Parameters:

msg - Message to be logged
module - Module name for which the message is getting logged.

Returns:

Log object containing logged message

Response: Log Object

For more details click Exception
$msg = "Error logs";
$module =	"testmod";
						
$log = $logService->error($msg, $module);   /* returns the Log object. */ 
$messageList =  $log->getMessageList();  
foreach( $messageList as $message ){
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/ 
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "Error logs",
                    "type": "ERROR",
                    "logTime": "2012-05-09T12:45:47.435Z",
                    "module": "testmod"
                }
            }
        }
    }
}
function fetchLogsByModule($moduleName)

Fetch the log messages based on the Module

Parameters:

moduleName - Module name for which the messages has to be fetched

Returns:

Log object containing fetched messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2700 - NOT FOUND - Logs for the module '<module>' does not exist. 
*/ 	        
For more details click Exception
$moduleName =	"testmod";
							
$log = $logService->fetchLogsByModule($moduleName);   /* returns the Log object. */ 
$messageList =  $log->getMessageList();  
foreach( $messageList as $message ){
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
 }
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": [
                    {
                        "message": "Info logs",
                        "logTime": "2012-05-09T12:37:57.000Z",
                        "module": "testmod",
                        "type": "INFO"
                    },
                    {
                        "message": "Info logs",
                        "logTime": "2012-05-09T12:38:17.000Z",
                        "module": "testmod",
                        "type": "INFO"
                    },
                    {
                        "message": "Debug logs",
                        "logTime": "2012-05-09T12:39:33.000Z",
                        "module": "testmod",
                        "type": "DEBUG"
                    },
                    {
                        "message": "Fatal logs",
                        "logTime": "2012-05-09T12:40:49.000Z",
                        "module": "testmod",
                        "type": "FATAL"
                    },
                    {
                        "message": "Error logs",
                        "logTime": "2012-05-09T12:45:47.000Z",
                        "module": "testmod",
                        "type": "ERROR"
                    }
                ]
            }
        }
    }
}
function fetchLogsCountByModule($moduleName)

Fetch the count of log messages based on the Module

Parameters:

moduleName - Module name for which the count of messages has to be fetched

Returns:

App42Response object containing count of fetched messages

Response: App42Response Object

Exception:

This method throws following exception.
/* 
2700 - NOT FOUND - Logs for the module '<module>' does not exist. 
*/ 		        
For more details click Exception
$moduleName =	"testmod";

$response = $logService->fetchLogsCountByModule($moduleName); /* returns the App42Response objects. */
$success = $response->isResponseSuccess();
$totalRecords = $response->getTotalRecords();
$jsonResponse = $response->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}
function fetchLogsByModule($moduleName, $max, $offset) throws App42Exception

Fetch the log messages based on the Module by paging

Parameters:

moduleName - Module name for which the messages has to be fetched
max - Maximum number of records to be fetched
offset - From where the records are to be fetched

Returns:

Log object containing fetched messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2700 - NOT FOUND - Logs for the module '<module>' does not exist.
2704 - NOT FOUND - The number of logs for the module '<module>' are less than the specified offset : <offset>. 
*/ 	        
For more details click Exception
$moduleName = "testmod";
$max = 1;
$offset = 0;
						
$log = $logService->fetchLogsByModule($moduleName,$max,$offset);   /* returns the Log object. */ 
$messageList = $logObj->getMessageList();
foreach($messageList as $message)
{  
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
} 
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "debug logs",
                    "logTime": "2012-06-02T14:08:26.000Z",
                    "module": "testmod",
                    "type": "DEBUG"
                }
            }
        }
    }
}
function fetchLogsByModuleAndText($moduleName, $text)

Fetch log messages based on the Module and Message Text.

Parameters:

moduleName - Module name for which the messages has to be fetched
text - The log message on which logs have to be searched

Returns:

Log object containing fetched messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2703 - NOT FOUND - Logs for the module '<module>' with text '<text>' does not exist.
*/ 		       
For more details click Exception
$moduleName = "testmod";
$text = "Info logs";
						
$log = $logService->fetchLogsByModuleAndText($moduleName, $text);   /* returns the Log object. */ 
$messageList =  $log->getMessageList();  
foreach( $messageList as $message )
{
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": [
                    {
                        "message": "Info logs",
                        "logTime": "2012-05-09T12:37:57.000Z",
                        "module": "testmod",
                        "type": "INFO"
                    },
                    {
                        "message": "Info logs",
                        "logTime": "2012-05-09T12:38:17.000Z",
                        "module": "testmod",
                        "type": "INFO"
                    }
                ]
            }
        }
    }
}
          
 
function fetchLogsCountByModuleAndText($moduleName, $text)

Fetch count of log messages based on the Module and Message Text

Parameters:

moduleName - Module name for which the count of messages has to be fetched
text - The log message on which count of logs have to be searched

Returns:

App42Response object containing count of fetched messages

Response: App42Response Object

Exception:

This method throws following exception.
/* 
2703 - NOT FOUND - Logs for the module '<module>' with text '<text>' does not exist.
*/ 		       
For more details click Exception
$moduleName = "testmod";
$text = "debug logs";

$response = $logService->fetchLogsCountByModuleAndText($moduleName,$text); /* returns the App42Response objects. */
$success = $response->isResponseSuccess();
$totalRecords = $response->getTotalRecords();
$jsonResponse = $response->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}
function fetchLogsByModuleAndText($moduleName, $text, $max, $offset)

Fetch log messages based on the Module and Message Text by paging.

Parameters:

moduleName - Module name for which the messages has to be fetched
text - The log message on which logs have to be searched
max - Maximum number of records to be fetched
offset - From where the records are to be fetched

Returns:

Log object containing fetched messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2707 - NOT FOUND - The number of logs for the module '<module>' with text '<text>' are less than the specified offset : <offset>.
*/ 		       
For more details click Exception
$moduleName = "testmod";
$text = "debug logs";
$max = 1;
$offset = 0;
						
$log = $logService->fetchLogsByModuleAndText($moduleName,$text,$max,$offset);   /* returns the Log object. */ 
$messageList = $logObj->getMessageList();
foreach($messageList as $message){  
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
} 
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "debug logs",
                    "logTime": "2012-06-02T14:08:22.000Z",
                    "module": "testmod",
                    "type": "DEBUG"
                }
            }
        }
    }
}
function fetchLogsByInfo()

Fetch log messages based on Info Level.

Parameters:

N/A

Returns:

Log object containing fetched info messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2701 - NOT FOUND - Logs for the type '<type>' does not exist. 
*/ 		        
For more details click Exception
$log = $logService->fetchLogsByInfo();   /* returns the Log object. */ 
$messageList =  $log->getMessageList();  
foreach( $messageList as $message ){
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": [
                    {
                        "message": "Info logs",
                        "logTime": "2012-05-09T12:37:57.000Z",
                        "module": "testmod",
                        "type": "INFO"
                    },
                    {
                        "message": "Info logs",
                        "logTime": "2012-05-09T12:38:17.000Z",
                        "module": "testmod",
                        "type": "INFO"
                    }
                ]
            }
        }
    }
}
function fetchLogsCountByInfo()

Fetch count of log messages based on Info Level

Parameters:

N/A

Returns:

App42Response object containing count of fetched info messages

Response: App42Response Object

Exception:

This method throws following exception.
/* 
2701 - NOT FOUND - Logs for the type '<type>' does not exist. 
*/ 		        
For more details click Exception
$response = $logService->fetchLogsCountByInfo(); /* returns the App42Response objects. */
$success = $response->isResponseSuccess();
$totalRecords = $response->getTotalRecords();
$jsonResponse = $response->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords":3
        }
    }
}
function fetchLogsByInfo($max, $offset)

Fetch log messages based on Info Level by paging

Parameters:

max - Maximum number of records to be fetched
offset - From where the records are to be fetched

Returns:

Log object containing fetched info messages

Response: Log Object

div id="method_parameters">

Exception:

This method throws following exception.
/* 
2705 - NOT FOUND - The number of logs for the type '<type>' are less than the specified offset : <offset>.
*/ 		        
For more details click Exception
$max = 1;
$offset = 0;
						
$log = $logService->fetchLogsByInfo($max,$offset);   /* returns the Log object. */ 
$messageList = $logObj->getMessageList();
foreach($messageList as $message)
{  
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "info logs",
                    "logTime": "2012-06-02T14:14:54.000Z",
                    "module": "testmod",
                    "type": "INFO"
                }
            }
        }
    }
}
function fetchLogsByDebug()

Fetch log messages based on Debug Level.

Parameters:

N/A

Returns:

Log object containing fetched debug messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2701 - NOT FOUND - Logs for the type '<type>' does not exist. 
*/ 		        
For more details click Exception
$log = $logService->fetchLogsByDebug();   /* returns the Log object. */ 
$messageList =  $log->getMessageList();  
foreach( $messageList as $message )
{
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "Debug logs",
                    "logTime": "2012-05-09T12:39:33.000Z",
                    "module": "testmod",
                    "type": "DEBUG"
                }
            }
        }
    }
}
function fetchLogsCountByDebug()

Fetch count of log messages based on Debug Level

Parameters:

N/A

Returns:

App42Response object containing count of fetched debug messages

Response: App42Response Object

Exception:

This method throws following exception.
/* 
2701 - NOT FOUND - Logs for the type '<type>' does not exist. 
*/ 		       
For more details click Exception
$response = $logService->fetchLogsCountByDebug(); /* returns the App42Response objects. */
$success = $response->isResponseSuccess();
$totalRecords = $response->getTotalRecords();
$jsonResponse = $response->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}
function fetchLogsByDebug($max, $offset) throws App42Exception

Fetch log messages based on Debug Level by paging.

Parameters:

max - Maximum number of records to be fetched
offset - From where the records are to be fetched

Returns:

Log object containing fetched debug messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2705 - NOT FOUND - The number of logs for the type '<type>' are less than the specified offset : <offset>.
*/ 		       
For more details click Exception
$max = 1;
$offset = 0;
						
$log = $logService->fetchLogsByDebug($max,$offset);   /* returns the Log object. */ 
$messageList = $logObj->getMessageList();
foreach($messageList as message)
{  
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "debug logs",
                    "logTime": "2012-06-02T14:08:22.000Z",
                    "module": "testmod",
                    "type": "DEBUG"
                }
            }
        }
    }
}
function fetchLogsByError().

Fetch log messages based on Error Level.

Parameters:

N/A

Returns:

Log object containing fetched error messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2701 - NOT FOUND - Logs for the type '<type>' does not exist. 
*/ 		       
For more details click Exception
$log = $logService->fetchLogsByError();   /* returns the Log object. */ 
$messageList =  $log->getMessageList();  
foreach( $messageList as $message )
{
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "Error logs",
                    "logTime": "2012-05-09T12:45:47.000Z",
                    "module": "testmod",
                    "type": "ERROR"
                }
            }
        }
    }
}
function fetchLogsCountByError()

Fetch count of log messages based on Error Level

Parameters:

N/A

Returns:

App42Response object containing count of fetched error messages

Response: App42Response Object

Exception:

This method throws following exception.
/* 
2701 - NOT FOUND - Logs for the type '<type>' does not exist. 
*/ 		       
For more details click Exception
$response = $logService->fetchLogsCountByError(); /* returns the App42Response objects. */
$success = $response->isResponseSuccess();
$totalRecords = $response->getTotalRecords();
$jsonResponse = $response->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}

function fetchLogsByError($max, $offset)

Fetch log messages based on Error Level by paging.

Parameters:

max - Maximum number of records to be fetched
offset - From where the records are to be fetched

Returns:

Log object containing fetched error messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2705 - NOT FOUND - The number of logs for the type '<type>' are less than the specified offset : <offset>.
*/ 		       
For more details click Exception
$max = 1;
$offset = 0;
						
$log = $logService->fetchLogsByError($max,$offset);   /* returns the Log object. */ 
$messageList = $logObj->getMessageList();
foreach($messageList as $message)
{  
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "error logs",
                    "logTime": "2012-06-02T14:17:14.000Z",
                    "module": "testmod",
                    "type": "ERROR"
                }
            }
        }
    }
}
function fetchLogsByFatal()

Fetch log messages based on Fatal Level.

Parameters:

N/A

Returns:

Log object containing fetched Fatal messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2701 - NOT FOUND - Logs for the type '<type>' does not exist. 
*/ 		       
For more details click Exception
$log = $logService->fetchLogsByFatal();   /* returns the Log object. */ 
$messageList =  $log->getMessageList();  
foreach( $messageList as $message )
{
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "Fatal logs",
                    "logTime": "2012-05-09T12:40:49.000Z",
                    "module": "testmod",
                    "type": "FATAL"
                }
            }
        }
    }
}
function fetchLogsCountByFatal()

Fetch count of log messages based on Fatal Level

Parameters:

N/A

Returns:

App42Response object containing count of fetched Fatal messages

Response: App42Response Object

Exception:

This method throws following exception.
/* 
2701 - NOT FOUND - Logs for the type '<type>' does not exist. 
*/ 		    
For more details click Exception
$response = $logService->fetchLogsCountByFatal(); /* returns the App42Response objects. */
$success = $response->isResponseSuccess();
$totalRecords = $response->getTotalRecords();
$jsonResponse = $response->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}
function fetchLogsByFatal($max, $offset)

Fetch log messages based on Fatal Level by paging.

Parameters:

max - Maximum number of records to be fetched
offset - From where the records are to be fetched

Returns:

Log object containing fetched Fatal messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2705 - NOT FOUND - The number of logs for the type '<type>' are less than the specified offset : <offset>.
*/ 		   
For more details click Exception
$max = 1;
$offset = 0;
						
$log = $logService->fetchLogsByFatal($max,$offset);   /* returns the Log object. */ 
$messageList = $logObj->getMessageList();
foreach($messageList as $message)
{  
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}  
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "fatal logs",
                    "logTime": "2012-06-02T14:18:00.000Z",
                    "module": "testmod",
                    "type": "FATAL"
                }
            }
        }
    }
}
function fetchLogByDateRange($startDate, $endDate)

Fetch log messages based on Date range.

Parameters:

startDate- Start date from which the log messages have to be fetched.
endDate - End date upto which the log messages have to be fetched

Returns:

Log object containing fetched messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2702 - Not Found - Logs betweem startDate '<startDate>' and endDate '<endDate>' does not exist.	
*/ 		
For more details click Exception
$date = date(DATE_ATOM, mktime());
$date2 = strtotime($date);
$newdate = strtotime('-2 day', strtotime($date));
$startDate = date('Y-m-j', $newdate);
$endDate = date('Y-m-j', $date2);	
					
$log = $logService->fetchLogByDateRange($startDate, $endDate);   /* returns the Log object. */ 
$messageList =  $log->getMessageList();  
foreach( $messageList as $message ){
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": [
                    {
                        "message": "Fatal logs",
                        "logTime": "2012-05-13T05:42:37.000Z",
                        "module": "testmod",
                        "type": "FATAL"
                    },
                    {
                        "message": "Hello",
                        "logTime": "2012-05-13T05:43:05.000Z",
                        "module": "Module",
                        "type": "DEBUG"
                    },
                    {
                        "message": "Hello",
                        "logTime": "2012-05-13T05:43:48.000Z",
                        "module": "Module",
                        "type": "DEBUG"
                    }
                ]
            }
        }
    }
}
function fetchLogCountByDateRange($startDate, $endDate)

Fetch count of log messages based on Date range

Parameters:

startDate - Start date from which the count of log messages have to be fetched
endDate - End date upto which the count of log messages have to be fetched

Returns:

App42Response object containing count of fetched messages

Response: App42Response Object

Exception:

This method throws following exception.
/* 
2702 - Not Found - Logs betweem startDate '<startDate>' and endDate '<endDate>' does not exist.	
*/ 		   
For more details click Exception
$date = date(DATE_ATOM, mktime());
$date2 = strtotime($date);
$newdate = strtotime('-2 day', strtotime($date));
$startDate = date('Y-m-j', $newdate);
$endDate = date('Y-m-j', $date2);	
						
$response = $logService->fetchLogsCountByDateRange($startDate,$endDate); /* returns the App42Response objects. */
$success = $response->isResponseSuccess();
$totalRecords = $response->getTotalRecords();
$jsonResponse = $response->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}


function fetchLogByDateRange($startDate, $endDate, $max, $offset) throws App42Exception

Fetch log messages based on Date range by paging.

Parameters:

startDate - Start date from which the log messages have to be fetched
endDate - End date upto which the log messages have to be fetched
max - Maximum number of records to be fetched
offset - From where the records are to be fetched

Returns:

Log object containing fetched messages

Response: Log Object

Exception:

This method throws following exception.
/* 
2706 - NOT FOUND - The number of logs betweem startDate '<startDate>' and endDate '<endDate>' are less than the specified offset : <offset>.
*/ 	     
For more details click Exception
$date = date(DATE_ATOM, mktime());
$date2 = strtotime($date);
$newdate = strtotime('-2 day', strtotime($date));
$startDate = date('Y-m-j', $newdate);
$endDate = date('Y-m-j', $date2);
$max = 1;
$offset = 0;
	
$log = $logService->fetchLogsByDateRange($startDate,$endDate,$max,$offset);   /* returns the Log object. */ 
$messageList = $logObj->getMessageList();
foreach($messageList as $message)
{  
print_r("msg is" . $message->getMessage());
print_r("module is" . $message->getModule());
print_r("type is" . $message->getType());
print_r("logTime is" . $message->getLogTime());
}  
$jsonResponse = $log->toString(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "logs": {
                "log": {
                    "message": "info logs",
                    "logTime": "2012-06-05T10:59:27.000Z",
                    "module": "testmod",
                    "type": "INFO"
                }
            }
        }
    }
}