Skip to content

Commit 47337ea

Browse files
committed
Created a global definition file, fixes #39.
1 parent 10dfaec commit 47337ea

8 files changed

+71
-38
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bundles
1616

1717
/*.js
1818
/*.js.map
19-
/*.d.ts
19+
#/*.d.ts
2020

2121
app/**/*.js
2222
app/**/*.js.map

.idea/jsLibraryMappings.xml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/angular2_logger_node_modules.xml

-15
This file was deleted.

README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This is a work in progress and is not ready for production, use with care, the A
1818

1919
1. Install the npm module.
2020

21-
npm install --save angular2-logger
21+
npm install --save angular2-logger
2222

2323
2. Add the `angular2-logger` library to your app. If you are following the [Angular 2's Quickstart Guide](https://angular.io/docs/ts/latest/quickstart.html) it should be something like this:
2424

@@ -44,20 +44,19 @@ In `systemjs.config.js`:
4444
3. Setup the Provider.
4545

4646
In `app.module.ts`:
47-
48-
49-
import { NgModule } from '@angular/core';
50-
import { BrowserModule } from '@angular/platform-browser';
51-
import { HelloWorldComponent } from './app.component';
52-
import { Logger } from "angular2-logger/core"; // ADD THIS
5347

54-
@NgModule({
55-
imports: [ BrowserModule ],
56-
declarations: [ HelloWorldComponent ],
57-
bootstrap: [ HelloWorldComponent ],
58-
providers: [ Logger ] // AND THIS
59-
})
60-
export class AppModule { }
48+
import { NgModule } from '@angular/core';
49+
import { BrowserModule } from '@angular/platform-browser';
50+
import { HelloWorldComponent } from './app.component';
51+
import { Logger } from "angular2-logger/core"; // ADD THIS
52+
53+
@NgModule({
54+
imports: [ BrowserModule ],
55+
declarations: [ HelloWorldComponent ],
56+
bootstrap: [ HelloWorldComponent ],
57+
providers: [ Logger ] // AND THIS
58+
})
59+
export class AppModule { }
6160

6261
4. Inject the logger into your objects and use it.
6362

@@ -206,6 +205,7 @@ Done.
206205
- [ ] Support named loggers.
207206
- [ ] Message Layout Feature.
208207
- [ ] No coding required Dashboard UI to handle loggers.
208+
- [ ] Automatize definition files. Waiting for https://github.com/Microsoft/TypeScript/issues/4433 .
209209

210210
## Breaking changes on 0.4.0
211211
The codebase was updated to handle the breaking changes on Angular2's Release Candidate 5.

angular2-logger.iml

-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
<exclude-output />
55
<content url="file://$MODULE_DIR$" />
66
<orderEntry type="sourceFolder" forTests="false" />
7-
<orderEntry type="library" name="angular2-logger node_modules" level="project" />
87
</component>
98
</module>

core.d.ts

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
export enum Level {
2+
OFF = 0,
3+
ERROR = 1,
4+
WARN = 2,
5+
INFO = 3,
6+
DEBUG = 4,
7+
LOG = 5,
8+
}
9+
10+
export class Options {
11+
level: Level;
12+
global: boolean;
13+
globalAs: string;
14+
store: boolean;
15+
storeAs: string;
16+
}
17+
18+
export class Logger {
19+
private _level;
20+
private _globalAs;
21+
private _store;
22+
private _storeAs;
23+
Level: any;
24+
constructor(options?: Options);
25+
private _loadLevel;
26+
private _storeLevel(level);
27+
error(message?: any, ...optionalParams: any[]): void;
28+
warn(message?: any, ...optionalParams: any[]): void;
29+
info(message?: any, ...optionalParams: any[]): void;
30+
debug(message?: any, ...optionalParams: any[]): void;
31+
log(message?: any, ...optionalParams: any[]): void;
32+
global: () => this;
33+
store(): Logger;
34+
unstore(): Logger;
35+
isErrorEnabled: () => boolean;
36+
isWarnEnabled: () => boolean;
37+
isInfoEnabled: () => boolean;
38+
isDebugEnabled: () => boolean;
39+
isLogEnabled: () => boolean;
40+
level: Level;
41+
}
42+
43+
export const OFF_LOGGER_PROVIDERS: any[];
44+
export const ERROR_LOGGER_PROVIDERS: any[];
45+
export const WARN_LOGGER_PROVIDERS: any[];
46+
export const INFO_LOGGER_PROVIDERS: any[];
47+
export const DEBUG_LOGGER_PROVIDERS: any[];
48+
export const LOG_LOGGER_PROVIDERS: any[];

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "angular2-logger",
33
"version": "0.3.0",
44
"description": "A Log4j inspired Logger for Angular 2.",
5-
"main": "bundles/angular-logger.js",
65
"repository": {
76
"type": "git",
87
"url": "git+https://github.com/code-chunks/angular2-logger"
@@ -14,7 +13,7 @@
1413
"tslint": "tslint *.ts src/**/*.ts",
1514
"lint": "npm run tslint",
1615
"prepublish": "npm run build",
17-
"clean": "rimraf *.js *.map *.d.ts app/**/*.js app/**/*.map app/**/*.d.ts demos/*/app**/*.js demos/*/app/*.map demos/*/app/*.d.ts dist bundles",
16+
"clean": "rimraf *.js *.map app/**/*.js app/**/*.map app/**/*.d.ts demos/*/app**/*.js demos/*/app/*.map demos/*/app/*.d.ts dist bundles",
1817
"precompile": "typings install",
1918
"compile": "npm run compile:es5 && npm run compile:sys && npm run compile:es6",
2019
"compile:amd": "tsc -p tsconfig-amd.json",
@@ -98,5 +97,7 @@
9897
"@angular/core": "2.0.0-rc.5",
9998
"@angular/platform-browser": "2.0.0-rc.5",
10099
"@angular/platform-browser-dynamic": "2.0.0-rc.5"
101-
}
102-
}
100+
},
101+
"typings": "core.d.ts",
102+
"main": "core.js"
103+
}

tsconfig-es5.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"emitDecoratorMetadata": true,
44

5-
"declaration": true,
5+
"declaration": false,
66
"experimentalDecorators": true,
77
"module": "commonjs",
88
"moduleResolution": "node",

0 commit comments

Comments
 (0)