1.0.2 • Published 9 months ago
logging-serius v1.0.2
Language Switcher
A lightweight JavaScript utility to handle multi-language support in web applications. This library provides a logging-serius
class to retrieve translations based on a specified language code and a predefined list of translations.
Table of Contents
Installation
Simply download the code or integrate it directly into your project as an independent module.
Usage
Define Translations: Start by creating an object that holds all the translation texts for each language. Each language is represented as an object with specific key-value pairs for the translations.
Retrieve Translations: Use the
logging-serius
class to retrieve the translations for a specific language code. If the requested language code is unavailable, the function will default to English (en
).
Importing and Using the Library
import { Logging } from "./path/to/your/module";
const db = new Logging("mongodb+srv://username:password@url/database");
await logging.connect();
// create db
const data = await db.createRecord({
name: "s",
email: "d",
description: "description",
code: "500",
type: "POST",
level: "warning",
device_id: "tes",
status: "admin",
ip_address: "34",
message: "34",
user: "df",
});
// wiston db
await db.wiston("warn", "aw");
// result in logs
// combine.log
// error.log