@guiiai/logg
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -106,2 +106,10 @@ import { Color } from 'colorette'; | ||
/** | ||
* Works like `child()`, but will try to get the call stack and add it to the logger. | ||
* This is useful for debugging purposes. | ||
*/ | ||
withCallStack: (errorLike: { | ||
message: string; | ||
stack?: string; | ||
}) => Logger; | ||
/** | ||
* Write a 'debug' level log, if the configured level allows for it. | ||
@@ -171,9 +179,4 @@ * Prints to `stdout` with newline. | ||
declare const availableLogLevels: LogLevel[]; | ||
declare function shouldOutputDebugLevelLogWhenLogLevelIsOneOf(logLevel: LogLevel): boolean; | ||
declare function shouldOutputVerboseLevelLogWhenLogLevelIsOneOf(logLevel: LogLevel): boolean; | ||
declare function shouldOutputLogLevelLogWhenLogLevelIsOneOf(logLevel: LogLevel): boolean; | ||
declare function shouldOutputWarningLevelLogWhenLogLevelIsOneOf(logLevel: LogLevel): boolean; | ||
declare function shouldOutputErrorLevelLogWhenLogLevelIsOneOf(logLevel: LogLevel): boolean; | ||
declare const availableFormats: Format[]; | ||
export { Format, type Log, LogLevel, LogLevelString, availableFormats, availableLogLevelStrings, availableLogLevels, createLogg, getGlobalFormat, getGlobalLogLevel, getGlobalLogLevelString, logLevelStringToLogLevelMap, logLevelToChalkColorMap, logLevelToLogLevelStringMap, setGlobalFormat, setGlobalLogLevel, setGlobalLogLevelString, shouldOutputDebugLevelLogWhenLogLevelIsOneOf, shouldOutputErrorLevelLogWhenLogLevelIsOneOf, shouldOutputLogLevelLogWhenLogLevelIsOneOf, shouldOutputVerboseLevelLogWhenLogLevelIsOneOf, shouldOutputWarningLevelLogWhenLogLevelIsOneOf, useLogg }; | ||
export { Format, type Log, LogLevel, LogLevelString, availableFormats, availableLogLevelStrings, availableLogLevels, createLogg, getGlobalFormat, getGlobalLogLevel, getGlobalLogLevelString, logLevelStringToLogLevelMap, logLevelToChalkColorMap, logLevelToLogLevelStringMap, setGlobalFormat, setGlobalLogLevel, setGlobalLogLevelString, useLogg }; |
{ | ||
"name": "@guiiai/logg", | ||
"version": "1.0.1", | ||
"type": "module", | ||
"version": "1.0.2", | ||
"description": "Yet another simple, nearly zero dependency, structural log compliance logger implementation.", | ||
"repository": "https://github.com/guiiai/logg", | ||
"license": "MIT", | ||
"contributors": [ | ||
@@ -17,7 +16,4 @@ { | ||
], | ||
"main": "./dist/index.cjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"license": "MIT", | ||
"repository": "https://github.com/guiiai/logg", | ||
"exports": { | ||
@@ -29,2 +25,7 @@ ".": { | ||
}, | ||
"main": "./dist/index.cjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"dependencies": { | ||
@@ -34,2 +35,4 @@ "colorette": "^2.0.20" | ||
"devDependencies": { | ||
"@antfu/eslint-config": "2.21", | ||
"eslint": "8", | ||
"unbuild": "^2.0.0" | ||
@@ -36,0 +39,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
# Logg | ||
# @guiiai/logg | ||
@@ -7,13 +7,16 @@ Yet another simple, nearly zero dependency, structural log compliance logger implementation. | ||
- Stack Parse: Automatically captures and includes stack trace information for enhanced debugging. | ||
- Caller Records: Provides detailed information about the calling function and file. | ||
- JSON Format & stdout: Outputs logs in JSON format to stdout for easy parsing and integration with log management tools. | ||
- Drop-in Replacement for Winston: Can be used as a direct replacement for the popular Winston logger. | ||
- Best Practices for Structural Logging: Implements industry best practices for structured logging. | ||
- Intuitive API: Simple and easy-to-use API for quick integration into your projects. | ||
- 🛠️ Stack Parse: Automatically captures and includes stack trace information for enhanced debugging. | ||
- 📞 Caller Records: Provides detailed information about the calling function and file. | ||
- 🗄️ JSON Format & stdout: Outputs logs in JSON format to stdout for easy parsing and integration with log management tools. | ||
- 🔄 Drop-in Replacement for Winston: Can be used as a direct replacement for the popular Winston logger. | ||
- 📏 Best Practices for Structural Logging: Implements industry best practices for structured logging. | ||
- 🧩 Intuitive API: Simple and easy-to-use API for quick integration into your projects. | ||
## Preview | ||
<img width="817" alt="image" src="https://github.com/user-attachments/assets/1cd7efb2-2257-409b-8011-7de69320f2be"> | ||
## Installation | ||
```bash | ||
npm install logg | ||
npm install @guiiai/logg | ||
``` | ||
@@ -24,6 +27,9 @@ | ||
```javascript | ||
const { createLogg } = require('logg'); | ||
import { Format, LogLevel, createLogg, setGlobalFormat, setGlobalLogLevel } from '@guiiai/logg' | ||
setGlobalLogLevel(LogLevel.Debug) | ||
setGlobalFormat(Format.Pretty) // Otherwise it will output JSON | ||
// Create a logger instance with a specific context | ||
const log = createLogg('http/request').useGlobalConfig(); | ||
const log = createLogg('http/request').useGlobalConfig() | ||
@@ -34,3 +40,3 @@ // Log a 404 error with additional fields | ||
.withField('url', req.url) | ||
.error('Resource not found (404)'); | ||
.error('Resource not found (404)') | ||
``` | ||
@@ -79,1 +85,12 @@ | ||
- `Format`: Enum for log formats (`JSON`, `Pretty`). | ||
## Star History | ||
[![Star History Chart](https://api.star-history.com/svg?repos=guiiai/logg&type=Date)](https://star-history.com/#guiiai/logg&Date) | ||
## Contributors | ||
[![contributors](https://contrib.rocks/image?repo=guiiai/logg)](https://github.com/guiiai/logg/graphs/contributors) | ||
### Made with ❤ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59929
1349
93
Yes
3