From 69b53982a83b466ba89bf94d66742dd473c84697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 16 Oct 2020 23:27:43 +0300 Subject: [PATCH] Documented ASP.NET Core MVC / Razor Pages UI: JavaScript Logging API --- docs/en/UI/AspNetCore/JavaScript-API/Index.md | 2 +- .../UI/AspNetCore/JavaScript-API/Logging.md | 49 ++++++++++++++++++- docs/en/docs-nav.json | 4 ++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/docs/en/UI/AspNetCore/JavaScript-API/Index.md b/docs/en/UI/AspNetCore/JavaScript-API/Index.md index 2ce185c6e3..281fa4726c 100644 --- a/docs/en/UI/AspNetCore/JavaScript-API/Index.md +++ b/docs/en/UI/AspNetCore/JavaScript-API/Index.md @@ -11,7 +11,7 @@ ABP provides a set of JavaScript APIs for ASP.NET Core MVC / Razor Pages applica * [abp.event](Events.md) * [abp.features](Features.md) * [abp.localization](Localization.md) -* abp.log +* [abp.log](Logging.md) * [abp.message](Message.md) * [abp.notify](Notify.md) * abp.security diff --git a/docs/en/UI/AspNetCore/JavaScript-API/Logging.md b/docs/en/UI/AspNetCore/JavaScript-API/Logging.md index 9fe48f22da..a46203b019 100644 --- a/docs/en/UI/AspNetCore/JavaScript-API/Logging.md +++ b/docs/en/UI/AspNetCore/JavaScript-API/Logging.md @@ -1,3 +1,50 @@ # ASP.NET Core MVC / Razor Pages UI: JavaScript Logging API -TODO \ No newline at end of file +`abp.log` API is used to write simple logs in the client side. + +> The logs are written to console, using the `console.log`, by default. + +> This document is for simple client side logging. See the [Logging](../../../Logging.md) document for server side logging system. + +## Basic Usage + +Use one of the `abp.log.xxx(...)` methods based on the severity of your log message. + +````js +abp.log.debug("Some debug log here..."); //Logging a simple debug message +abp.log.info({ name: "john", age: 42 }); //Logging an object as an information log +abp.log.warn("A warning message"); //Logging a warning message +abp.log.error('An error happens...'); //Error message +abp.log.fatal('Network connection has gone away!'); //Fatal error +```` + +## Log Levels + +There are 5 levels for a log message: + +* DEBUG = 1 +* INFO = 2 +* WARN = 3 +* ERROR = 4 +* FATAL = 5 + +These are defined in the `abp.log.levels` object (like `abp.log.levels.WARN`). + +### Changing the Current Log Level + +You can control the log level as shown below: + +````js +abp.log.level = abp.log.levels.WARN; +```` + +Default log level is `DEBUG`. + +### Logging with Specifying the Level + +Instead of calling `abp.log.info(...)` function, you can use the `abp.log.log` by specifying the log level as a parameter: + +````js +abp.log.log("log message...", abp.log.levels.INFO); +```` + diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index bdb99396e0..459c6947fd 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -490,6 +490,10 @@ { "text": "DOM", "path": "UI/AspNetCore/JavaScript-API/DOM.md" + }, + { + "text": "Logging", + "path": "UI/AspNetCore/JavaScript-API/Logging.md" } ] },