개발의 즐거움/개발표준

say 'hello' to Blackbird and say 'goodbye' to alert

[짱가™] 2008. 10. 17. 17:24

Blackbird는 G. Scott Olson씨가 작성한 JavaScript 로깅 라이브러리

"Say 'hello' to Blackbird and 'goodbye' to alert()"  이라는 캐치 슬로건을 가지고 오픈한 라이브러리다.
자바스크립트에서 메시지 로깅을 아주 쉽게 해준다.

설치도 매우 쉽다 

라이브러리를 다운로드 하고 

<html>
  <head>
    <script type="text/javascript" src="/PATH/TO/blackbird.js"></script>
    <link type="text/css" rel="Stylesheet" href="/PATH/TO/blackbird.css" />
    ...
  </head>

이렇게 설정하면 사용할 수 있게 된다. 

로깅 api 가 그렇듯이 api 도 간단하다.

log.toggle()
Hide/show Blackbird
log.move()
Move Blackbird to next fixed positions: top-left, top-right, bottom-left, bottom-right
log.resize()
Expand/contract Blackbird
log.clear()
Clear all contents of Blackbird
log.debug( message )
Add a debug message to Blackbird
message: the string content of the debug message
log.info( message )
Add an info message to Blackbird
message: the string content of the info message
log.warn( message )
Add a warning message to Blackbird
message: the string content of the warn message
log.error( message )
Add an error message to Blackbird
message: the string content of the warn message
log.profile( label )
Start/end a time profiler for Blackbird. If a profiler named string does not exist, create a new profiler. Otherwise, stop the profiler string and display the time elapsed (in ms).
label: the string identifying a specific profile
 
인터페이스가 좀 새롭게 느껴지지만, 예전에 log4j 로그를 모니터링 할 때 사용했던 p6spy 를 닮은 것을 알 수 있다.
뭐 이미 검증된 방법으로 구성되어 있는 것도 사용하는 사람에겐 매우 좋다. 

이미 커스텀하게 구현해서 사용하고 있는 사람들이 있고, 전 회사에서도 구현하려 했던 기능인데 
이렇게 구현되어서 제공되니 이또한 즐겁군.. ^^ 

또한, 창을 자유롭게 조정할 수 도 있는데 
log.clear();
log.move();
log.resize();
log.toggle();

바로 이 명령 되시겠다.. ( 기능은 눈에 보이는 대로 생각하시면 된다. ) 
- 이런 기능들은 입맛에 맞게 수정할 수 있는 가이드 역시 사이트에서 제공한다. 


사이트를 보다 보니 
http://alistapart.com/articles/jslogging
여기서 발전이 된 모양이다. 



사이트 뿐만 아니라 구글 코드 프로젝트에서 공유하고 있다 : http://code.google.com/p/blackbirdjs/
Browser compatibility
Blackbird is has been smoke-tested on the following browsers:
Internet Explorer 6+
Firefox 2+
Safari 2+
Opera 9.5
라고 하는데 다만, 파폭이나 크롬에서는 잘 되는데  IE8 에서는 안되는 군... 더 테스트를 해 봐야겠다. 

'개발의 즐거움 > 개발표준' 카테고리의 다른 글

오라클 다국어 설정  (0) 2008.08.25