New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@baileyherbert/logging

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@baileyherbert/logging - npm Package Compare versions

Comparing version 2.1.0 to 3.0.0

2

dist/core/Logger.d.ts

@@ -189,3 +189,3 @@ import { EventEmitter } from '@baileyherbert/events';

}
declare type LoggerEvents = {
type LoggerEvents = {
/**

@@ -192,0 +192,0 @@ * Emitted when the logger receives output within its configured log level.

@@ -42,3 +42,3 @@ "use strict";

LogLevel[LogLevel["None"] = 6] = "None";
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
})(LogLevel || (exports.LogLevel = LogLevel = {}));
//# sourceMappingURL=LogLevel.js.map

@@ -152,4 +152,4 @@ import { LogLevel } from '../enums/LogLevel';

}
declare type ChalkColor = (...text: unknown[]) => string;
declare type LogLevelMap<T> = {
type ChalkColor = (...text: unknown[]) => string;
type LogLevelMap<T> = {
trace?: T;

@@ -156,0 +156,0 @@ debug?: T;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

@@ -40,3 +40,3 @@ /// <reference types="node" />

}
declare type Destination = 'std' | 'console';
type Destination = 'std' | 'console';
export {};
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { WriteStream } from 'fs';

@@ -117,3 +119,3 @@ import { InspectOptions } from 'util';

}
declare type FileTransportEvents = {
type FileTransportEvents = {
/**

@@ -120,0 +122,0 @@ * Emitted when the active log file is rotated and archived.

@@ -68,3 +68,2 @@ "use strict";

write(lines) {
var _a;
return __awaiter(this, void 0, void 0, function* () {

@@ -84,3 +83,3 @@ if (!this.available) {

this.currentFileSize += content.length;
const rotateAfter = (_a = (this.options.rotation && this.options.rotation.maxFileSize)) !== null && _a !== void 0 ? _a : 0;
const rotateAfter = this.options.rotation !== false ? this.options.rotation.maxFileSize : 0;
if (rotateAfter > 0 && this.currentFileSize >= rotateAfter) {

@@ -87,0 +86,0 @@ yield this.rotate(content);

@@ -60,4 +60,4 @@ import { EventEmitter, EventEmitterSchema } from '@baileyherbert/events';

}
declare type Promisable<T> = T | Promise<T>;
declare type TransportEvents = {
type Promisable<T> = T | Promise<T>;
type TransportEvents = {
/**

@@ -64,0 +64,0 @@ * Emitted when a logger is attached to the transport.

@@ -1,3 +0,3 @@

export declare type DeepNonNullable<T> = {
export type DeepNonNullable<T> = {
[P in keyof T]-?: NonNullable<DeepNonNullable<T[P]>>;
};
{
"name": "@baileyherbert/logging",
"version": "2.1.0",
"version": "3.0.0",
"description": "Just another logging solution.",

@@ -17,35 +17,45 @@ "author": "Bailey Herbert <hello+npm@bailey.sh> (https://bailey.sh)",

"logger",
"logs",
"browser"
"logs"
],
"scripts": {
"dev": "ts-node-dev --respawn --rs src/main.ts",
"build": "rimraf dist && tsc",
"watch": "rimraf dist && tsc -w",
"start": "node dist/main",
"test": "jest"
},
"dependencies": {
"@baileyherbert/events": "^1.0.0",
"@baileyherbert/events": "^1.0.1",
"chalk": "^4.1.2"
},
"devDependencies": {
"@types/jest": "^27.0.1",
"@types/node": "^14",
"dayjs": "^1.10.7",
"jest": "^27.1",
"rimraf": "^3.0.2",
"ts-jest": "^27.0",
"ts-node-dev": "^1.1.8",
"typescript": "^4.4"
"@types/jest": "^29.5.11",
"@types/node": "^18.0.0",
"dayjs": "^1.11.10",
"jest": "^29.7.0",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3"
},
"engines": {
"node": ">=18.0.0"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"globals": {
"ts-jest": {
"tsconfig": "tests/tsconfig.json"
}
"rootDir": ".",
"testMatch": [
"<rootDir>/tests/**/*.test.ts",
"<rootDir>/tests/**/*.spec.ts"
],
"moduleNameMapper": {
"^src/?$": "<rootDir>/src/index.ts",
"^src/(.*)$": "<rootDir>/src/$1"
},
"transform": {
"^.+\\.tsx?$": [
"ts-jest",
{
"tsconfig": "tests/tsconfig.json"
}
]
}
}
}

@@ -1,49 +0,67 @@

# Logging
<p align="center">
<a href="https://bailey.sh/" target="_blank" rel="noopener noreferrer">
<img width="96" height="96" src="https://i.bailey.sh/mA6G3zHDcE.png" alt="Bailey Herbert Logo">
</a>
</p>
<p align="center">
<a href="https://github.com/baileyherbert/logging" target="_blank" rel="noopener noreferrer">github</a> &nbsp;/&nbsp;
<a href="https://www.npmjs.com/package/@baileyherbert/logging" target="_blank" rel="noopener noreferrer">npm</a> &nbsp;/&nbsp;
<a href="https://docs.bailey.sh/logging/" target="_blank" rel="noopener noreferrer">documentation</a>
</p>
This package offers a logging solution based on a modular delivery concept. Simply create a logger instance, attach a
delivery transport (such as console, file, or your own), and start logging!
# logging
## Installation
An elegant logging solution for TypeScript built on a hierarchical composite pattern.
```plain
```
npm install @baileyherbert/logging
```
## Example
## examples
Create a logger instance. This is what we'll use to actually write output.
### creating the root logger
Each application needs at least one root logger instance.
```ts
const logger = new Logger();
const rootLogger = new Logger();
```
Create a console transport. This will print our output to the console. You can define a minimum log level for output.
We'll use `Trace` here which will capture all levels of output.
### attaching transports to the root logger
The root logger is responsible for piping its output into one or more transports. The example below will create and attach a [console transport](https://docs.bailey.sh/logging/latest/guide/transports/) to the logger, which writes logs directly to the console. This works in a browser environment.
```ts
logger.createConsoleTransport(LogLevel.Trace);
rootLogger.createConsoleTransport();
```
Create a file transport. This will send our output into a file. We'll set a minimum log level of `Information` to keep
the logs minimal. Please note that the file transport has automatic log rotation enabled by default, but you can
customize or disable this behavior.
### creating child loggers
Each service in your application should have its own logger instance. These are called child loggers, and they are used to automatically prefix output from services with their names.
```ts
logger.createFileTransport(LogLevel.Information, {
fileName: 'logs/output.log'
});
const logger = rootLogger.createChild('ServiceName');
```
Done! Now use the logger to write output to both the console and log file at once.
### writing logs
Loggers expose methods for each supported severity level.
```ts
logger.trace('Starting example program');
logger.info('Hello world');
logger.trace();
logger.debug();
logger.info();
logger.warning();
logger.error();
logger.critical();
```
Both of those transports have many customization options, and you can also create your own. Check the
[transports guide](https://docs.bailey.sh/logging/latest/guide/transports/) to learn more.
These methods work identically to `console.log()`. You can pass multiple parameters of any type, and can pass a string for formatting.
## Documentation
```ts
logger.info('Logged in as %s from %s', username, ip);
```
- [Documentation website](https://docs.bailey.sh/logging/)
## license
MIT

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc