2.0.2 • Published 6 months ago
@augmedix/logging-format v2.0.2
"# node-augmedix-logger"
A standardized logging library for node-based Augmedix applications. Contains default configurations for use in Augmedix production and pre-production environments.
Quick Start
Authenticate to GitHub Packages to use it as the NPM registry for
@augmedix
packages. When prompted for your password, use a Personal Access Token.npm login --scope=@augmedix --registry=https://npm.pkg.github.com
Add this library as a dependency to your project.
# NPM npm install --save @augmedix/logging-format # Yarn yarn add @augmedix/logging-format
Log everything with a simple function.
//Import Declaration import {CustomLog} from '@augmedix/logging-format' /* -------------------------------------------------------- BASIC CONFIGURATION -------------------------------------------------------- */ const augmedixLog = new CustomLog(); augmedixLog.setMessage("Testing message").build(); /* ******************************************************** CONSOLE OUTPUT: ******************************************************** {"instanceId":"-", "level":"error", "message":"Testing message", "payload":{"correlationId":"-", "fileName":"-", "role":"-", "thread":"-", "timestamp":"2023-11-07T20:29:28.094Z", "userEmail":"-"}, "podId":"-", "service":"-"} ******************************************************** */ /* -------------------------------------------------------- OUTPUT CONFIGURATION -------------------------------------------------------- */ //Output to Console [DEFAULT MODE] augmedixLog.setOutputToConsole().setMessage("Testing message").build(); //Output to File augmedixLog.setOutputToFile().setMessage("Testing message").build(); //Output 'logs/error.log' [DEFAULT PATH] /* my-app/ ├─ node_modules/ ├─ logs/ │ ├─ error.log ├─ src/ │ ├─ index.css │ ├─ index.js ├─ .gitignore ├─ package.json ├─ README.md */ /* OPTIONAL PARAMETER-> augmedixLog.setOutputToFile(filePathAndName) NOTA: this optional parameter accept a relative path and the name of the file. */ //Output in both ways (Console and File 'logs/error.log' [DEFAULT PATH]) augmedixLog.setOutputToFileAndConsole().setMessage("Testing message").build(); /* OPTIONAL PARAMETER-> augmedixLog.setOutputToFileAndConsole(filePathAndName) NOTA: this optional parameter accept a relative path and the name of the file. */ /* -------------------------------------------------------- METHODS FOR INFORMATIONS CONFIGURATION -------------------------------------------------------- */ setMessage("Testing message") //set the message [REQUIRED] setInstanceId("i-03ec3e9c680812ed9") // set the instance ID [OPTIONAL] setService("notebulider-service") // set the service [OPTIONAL] setPodId("Kube-pod-2") // set the production ID [OPTIONAL] setCorrelationId("796a3670-157d-4295-865f-b87360bfce4f") // set the correlation ID [OPTIONAL] setThread("main") //set the thread [OPTIONAL] setFileName("ComplaintService.js") //set the file name [OPTIONAL] setUserEmail("scribe@augmedix.com") // set the user email [OPTIONAL] setRole("SCRIBE") //set the role [OPTIONAL] /* -------------------------------------------------------- METHOD FOR RESET THE LOG INFORMACION -------------------------------------------------------- */ reset() //This Method set all the information to default value '-'.
/*
--------------------------------------------------------
FULL EXAMPLE
--------------------------------------------------------
*/
augmedixLog.setOutputToFileAndConsole()
.setMessage("Testing message")
.setInstanceId("i-03ec3e9c680812ed9")
.setService("notebulider-service")
.setPodId("Kube-pod-2")
.setCorrelationId("796a3670-157d-4295-865f-b87360bfce4f")
.setThread("main")
.setFileName("ComplaintService.js")
.setUserEmail("scribe@augmedix.com")
.setRole("SCRIBE")
.build();
/*
********************************************************
CONSOLE OUTPUT:
********************************************************
{"instanceId":"i-03ec3e9c680812ed9",
"level":"error",
"message":"Testing message",
"payload":{"correlationId":"796a3670-157d-4295-865f-b87360bfce4f",
"fileName":"ComplaintService.js",
"role":"SCRIBE",
"thread":"main",
"timestamp":"2023-11-07T20:29:28.094Z",
"userEmail":"scribe@augmedix.com"},
"podId":"-",
"service":"-"}
********************************************************
*/
2.0.2
6 months ago