/*
 * BEGIN FLOCK GPL
 *
 * Copyright Flock Inc. 2005-2009
 * http://flock.com
 *
 * This file may be used under the terms of the
 * GNU General Public License Version 2 or later (the "GPL"),
 * http://www.gnu.org/licenses/gpl.html
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * END FLOCK GPL
 */

#ifndef __flockLogger_h__
#define __flockLogger_h__

#include "flockILogger.h"
#include "flockILoggingService.h"

#include "nsIObserver.h"

#include "nsCOMArray.h"
#include "nsStringAPI.h"

class flockLogger : public flockILogger {
public:
  NS_DECL_ISUPPORTS
  NS_DECL_FLOCKILOGGER

  NS_HIDDEN_(nsresult) Init();

  flockLogger();

private:
  ~flockLogger();

  nsString mContext;
  PRInt32 mOverrideLevel;
};

class flockLoggingService : public flockILoggingService,
                            public nsIObserver {
public:
  NS_DECL_ISUPPORTS
  NS_DECL_FLOCKILOGGINGSERVICE
  NS_DECL_NSIOBSERVER

  static flockLoggingService* GetSingleton();

private:
  flockLoggingService() NS_HIDDEN;
  ~flockLoggingService() NS_HIDDEN;

  NS_HIDDEN_(nsresult) Initialize();
  NS_HIDDEN_(nsresult) Setup();
  NS_HIDDEN_(nsresult) Shutdown();
  NS_HIDDEN_(nsresult) PrefsChanged(const char *aPref);

  PRInt32 mLevel;
  PRBool mEnabled;

  nsCOMArray<flockILoggingObserver> mObservers;
};

#endif
