Git Product home page Git Product logo

log's Introduction

@seasonjs/log

Js log library which copy from vscode

Version License

quick start

install

npm

npm i @seasonjs/log

yarn

yarn add @seasonjs/log

pnpm

pnpm add @seasonjs/log

special notice

import {LoggerService} from '@seasonjs/log/node' this may need package @vscode/spdlog you may need install it and add external key to your builder options

here is an example:

import {defineConfig} from "vite";
// this is vite config,but it also work with rollup, as you know.
export default defineConfig(() => {
    return {
        build: {
            rollupOptions: {
                external: ['@vscode/spdlog']
            },
        },
    }
})

example usage

just console log

import {LogService, ConsoleLogger} from '@seasonjs/log'

const logger = new LogService(new ConsoleLogger(LogLevel.Debug))
logger.info("this is an info")

use with node and write to file

import path from "node:path"
import {LogService, ConsoleLogger, DEFAULT_LOG_LEVEL, URI, BufferLogger} from '@seasonjs/log'
import {LoggerService} from '@seasonjs/log/node'

const uri = URI.file(path.join(__dirname, './.test_data/log'))
const loggerService = new LoggerService(DEFAULT_LOG_LEVEL, uri)
const bufferLogger = new BufferLogger(loggerService.getLogLevel());
// In this case mean you can set anyother logger to bufferLogger, which is implements with ILogger.
bufferLogger.logger = loggerService.createLogger('example')
const logger = new LogService(new ConsoleLogger(loggerService.getLogLevel()), [bufferLogger])
logger.info("this is an info")

log's People

Contributors

cyberhan123 avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.