Logs Service
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.

Using SDK

If you decide to use one of our provided SDK, the following code shows how to initialize logs service.
.NET
Node
PHP
1
var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
2
var apiKey = "{YOUR_SECRET_KEY}";
3
4
var client = new CodeMashClient(apiKey, projectId);
5
var logsService = new CodeMashLogsService(client);
Copied!
1
Copied!
1
use Codemash\CodemashClient;
2
use Codemash\CodemashLog;
3
4
class CodemashService
5
{
6
protected CodemashLog $codemashLog;
7
8
public function __construct()
9
{
10
$secretKey = '{YOUR_SECRET_KEY}';
11
$projectId = '{YOUR_PROJECT_ID}';
12
13
$client = new CodemashClient($secretKey, $projectId);
14
$this->codemashLog = new CodemashLog($client);
15
}
16
17
18
}
Copied!

Example

The following are examples of logs SDK using different languages and frameworks.
.NET
Node
PHP
1
using System;
2
using CodeMash.Client;
3
using CodeMash.Membership.Services;
4
using Isidos.CodeMash.ServiceContracts;
5
6
namespace ConsoleApplication
7
{
8
class Program
9
{
10
static void Main(string[] args)
11
{
12
// 1. Get your Project ID and Secret Key
13
var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
14
var apiKey = "{YOUR_SECRET_KEY}";
15
16
// 2. Create a general client for API calls
17
var client = new CodeMashClient(apiKey, projectId);
18
19
// 3. Create a service object
20
var logsService = new CodeMashLogsService(client);
21
22
// 4. Call an API method
23
logsService.CreateLog(new CreateLogRequest
24
{
25
Message = "Custom log",
26
Level = "Information"
27
});
28
}
29
}
30
}
Copied!
1
Copied!
1
use Codemash\CodemashClient;
2
use Codemash\CodemashLog;
3
4
class CodemashService
5
{
6
protected CodemashLog $codemashLog;
7
8
public function __construct()
9
{
10
$secretKey = '{YOUR_SECRET_KEY}';
11
$projectId = '{YOUR_PROJECT_ID}';
12
13
$client = new CodemashClient($secretKey, $projectId);
14
$this->codemashLog = new CodemashLog($client);
15
}
16
17
public function log()
18
{
19
$responseData = $this->codemashLog->create([
20
'message' => 'Custom log',
21
'level' => 'Warning'
22
]);
23
}
24
25
}
Copied!

Working with Logs Service

The following links explore the usage of logs service:
Last modified 1yr ago