mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-11 19:09:04 +08:00
Merge pull request #4695 from Pro/master
Added definition for loglevel (https://github.com/pimterry/loglevel)
This commit is contained in:
21
loglevel/loglevel-tests.ts
Normal file
21
loglevel/loglevel-tests.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/// <reference path="loglevel.d.ts" />
|
||||
|
||||
log.trace("Trace message");
|
||||
log.debug("Debug message");
|
||||
log.info("Info message");
|
||||
log.warn("Warn message");
|
||||
log.error("Error message");
|
||||
log.debug(["Hello", "world", 42]);
|
||||
|
||||
log.setLevel(0);
|
||||
log.setLevel(0, false);
|
||||
|
||||
log.setLevel("error");
|
||||
log.setLevel("error", false);
|
||||
|
||||
log.setLevel(log.levels.WARN);
|
||||
log.setLevel(log.levels.WARN, false);
|
||||
|
||||
var logging = log.noConflict();
|
||||
|
||||
logging.error("still pretty easy");
|
||||
102
loglevel/loglevel.d.ts
vendored
Normal file
102
loglevel/loglevel.d.ts
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
// Type definitions for loglevel 1.3.1
|
||||
// Project: https://github.com/pimterry/loglevel
|
||||
// Definitions by: Stefan Profanter <https://github.com/Pro/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module loglevel {
|
||||
|
||||
/**
|
||||
* Log levels
|
||||
*/
|
||||
export enum levels {
|
||||
TRACE = 0,
|
||||
DEBUG = 1,
|
||||
INFO = 2,
|
||||
WARN = 3,
|
||||
ERROR = 4,
|
||||
SILENT = 5
|
||||
}
|
||||
|
||||
/**
|
||||
* Output trace message to console.
|
||||
* This will also include a full stack trace
|
||||
*
|
||||
* @param msg any data to log to the console
|
||||
*/
|
||||
export function trace(msg:any):void;
|
||||
|
||||
/**
|
||||
* Output debug message to console including appropriate icons
|
||||
*
|
||||
* @param msg any data to log to the console
|
||||
*/
|
||||
export function debug(msg:any):void;
|
||||
|
||||
/**
|
||||
* Output info message to console including appropriate icons
|
||||
*
|
||||
* @param msg any data to log to the console
|
||||
*/
|
||||
export function info(msg:any):void;
|
||||
|
||||
/**
|
||||
* Output warn message to console including appropriate icons
|
||||
*
|
||||
* @param msg any data to log to the console
|
||||
*/
|
||||
export function warn(msg:any):void;
|
||||
|
||||
/**
|
||||
* Output error message to console including appropriate icons
|
||||
*
|
||||
* @param msg any data to log to the console
|
||||
*/
|
||||
export function error(msg:any):void;
|
||||
|
||||
|
||||
/**
|
||||
* This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something")
|
||||
* or log.error("something") will output messages, but log.info("something") will not.
|
||||
*
|
||||
* @param level 0=trace to 5=silent
|
||||
* @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling back
|
||||
* to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
|
||||
* false as the optional 'persist' second argument, persistence will be skipped.
|
||||
*/
|
||||
export function setLevel(level:number, persist?:boolean):void;
|
||||
|
||||
|
||||
/**
|
||||
* This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something")
|
||||
* or log.error("something") will output messages, but log.info("something") will not.
|
||||
*
|
||||
* @param level as a string, like 'error' (case-insensitive)
|
||||
* @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling back
|
||||
* to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
|
||||
* false as the optional 'persist' second argument, persistence will be skipped.
|
||||
*/
|
||||
export function setLevel(level:string, persist?:boolean):void;
|
||||
|
||||
|
||||
/**
|
||||
* This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something")
|
||||
* or log.error("something") will output messages, but log.info("something") will not.
|
||||
*
|
||||
* @param level as the value from the enum
|
||||
* @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling back
|
||||
* to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
|
||||
* false as the optional 'persist' second argument, persistence will be skipped.
|
||||
*/
|
||||
export function setLevel(level:levels, persist?:boolean):void;
|
||||
|
||||
/**
|
||||
* If you're using another JavaScript library that exposes a 'log' global, you can run into conflicts with loglevel.
|
||||
* Similarly to jQuery, you can solve this by putting loglevel into no-conflict mode immediately after it is loaded
|
||||
* onto the page. This resets to 'log' global to its value before loglevel was loaded (typically undefined), and
|
||||
* returns the loglevel object, which you can then bind to another name yourself.
|
||||
*/
|
||||
export function noConflict():any;
|
||||
}
|
||||
|
||||
declare
|
||||
var log:typeof loglevel;
|
||||
Reference in New Issue
Block a user