-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logger): add initial working module (#104)
* feat(logger): add initial working module Add basic logger module * chore(logger): add eslint files * chore(logger): add lint scripts
- Loading branch information
Showing
8 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
jest.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../.eslintrc" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './src/logger'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "@mockinbird/logger", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"description": "Mockingbird Logger Package", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"contributors": [ | ||
{ | ||
"name": "Omer Morad", | ||
"email": "omer.moradd@gmail.com" | ||
} | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/omermorad/mockingbird.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/omermorad/mockingbird/issues" | ||
}, | ||
"readme": "https://github.com/omermorad/mockingbird/tree/refactor/master/packages/logger/README.md", | ||
"scripts": { | ||
"prebuild": "yarn rimraf dist", | ||
"build": "tsc", | ||
"watch": "tsc --watch", | ||
"lint": "eslint '{src,test}/**/*.ts'", | ||
"lint:fix": "eslint '{src,test}/**/*.ts' --fix" | ||
}, | ||
"files": [ | ||
"dist", | ||
"README.md", | ||
"CHANGELOG.md" | ||
], | ||
"dependencies": { | ||
"@types/chalk": "^2.2.0", | ||
"chalk": "^4.1.2" | ||
}, | ||
"devDependencies": { | ||
"ts-node": "8.10.2", | ||
"tsconfig-paths": "^3.9.0", | ||
"typescript": "^3.9.7" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import chalk from 'chalk'; | ||
import util from 'util'; | ||
|
||
const prefix = '\u{1F426} '; | ||
|
||
function format(args: Array<any>, customPrefix?: string) { | ||
const fullPrefix = prefix + (customPrefix === undefined ? '' : ' ' + customPrefix); | ||
return ( | ||
fullPrefix + | ||
util | ||
.format('', ...args) | ||
.split('\n') | ||
.join('\n' + fullPrefix + ' ') | ||
); | ||
} | ||
|
||
export interface MockingbirdLogger { | ||
info(message: string, ...args: any[]): void; | ||
error(message: string, ...args: any[]): void; | ||
warn(message: string, ...args: any[]): void; | ||
log(message: string, ...args: any[]): void; | ||
success(message: string, ...args: any[]): void; | ||
} | ||
|
||
export const Logger: MockingbirdLogger = { | ||
info: (...args: any[]): void => { | ||
console.info(format(args, chalk.cyan('info'))); | ||
}, | ||
log: (...args: any[]): void => { | ||
console.log(format(args)); | ||
}, | ||
error: (...args: any[]): void => { | ||
console.error(format(args, chalk.red('error'))); | ||
}, | ||
success: (...args: any[]): void => { | ||
console.log(format(args, chalk.green('success'))); | ||
}, | ||
warn: (...args: any[]): void => { | ||
console.warn(format(args, chalk.yellow('warn'))); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "../tsconfig.build.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./dist", | ||
"target": "es6" | ||
}, | ||
"exclude": [ | ||
"node_modules", | ||
"test", | ||
"src/**/*.test.ts", | ||
"index.ts" | ||
], | ||
"include": ["src/"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,9 @@ | |
}, | ||
{ | ||
"path": "packages/mockingbird" | ||
} | ||
}, | ||
{ | ||
"path": "packages/logger" | ||
}, | ||
] | ||
} |