Logs & Monitoring
Overview of logs service
CodeMash Logs service logs all the requests and errors in your project. All the logs can be reached on the dashboard. In addition, you can create your custom logs from your own application.
To start using logs services and API methods you firstly need to enable logs service in your CodeMash dashboard.
Features included in logs service:
  1. 1.
    Logs - logs of various actions in your application.

If you decide to use one of our provided SDK, the following code shows how to initialize logs service.
.NET
Node
PHP
var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
var apiKey = "{YOUR_SECRET_KEY}";
โ€‹
var client = new CodeMashClient(apiKey, projectId);
var logsService = new CodeMashLogsService(client);
โ€‹
use Codemash\CodemashClient;
use Codemash\CodemashLog;
โ€‹
class CodemashService
{
protected CodemashLog $codemashLog;
โ€‹
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
โ€‹
$client = new CodemashClient($secretKey, $projectId);
$this->codemashLog = new CodemashLog($client);
}
โ€‹
}

The following are examples of logs SDK using different languages and frameworks.
.NET
Node
PHP
using System;
using CodeMash.Client;
using CodeMash.Membership.Services;
using Isidos.CodeMash.ServiceContracts;
โ€‹
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
// 1. Get your Project ID and Secret Key
var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
var apiKey = "{YOUR_SECRET_KEY}";
โ€‹
// 2. Create a general client for API calls
var client = new CodeMashClient(apiKey, projectId);
// 3. Create a service object
var logsService = new CodeMashLogsService(client);
โ€‹
// 4. Call an API method
logsService.CreateLog(new CreateLogRequest
{
Message = "Custom log",
Level = "Information"
});
}
}
}
โ€‹
use Codemash\CodemashClient;
use Codemash\CodemashLog;
โ€‹
class CodemashService
{
protected CodemashLog $codemashLog;
โ€‹
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
โ€‹
$client = new CodemashClient($secretKey, $projectId);
$this->codemashLog = new CodemashLog($client);
}
โ€‹
public function log()
{
$responseData = $this->codemashLog->create([
'message' => 'Custom log',
'level' => 'Warning'
]);
}
}

The following links explore the usage of logs service:
Copy link
On this page
Using SDK
Example
Working with Logs Service