Code Monkey home page Code Monkey logo

s60-logger's Introduction

Logging library for Symbian

This module provides logging feature for Symbian OS. Main functions are listed below.

Features

  • Output to file
  • Logging levels: Debug, Information, Warning and Error; you can customize which ones to write to the file
  • Encodings: 8-bit, Unicode, UTF-8
  • Buffered output for increasing performance with frequent write operations
  • It`s possible to enable/disable logging in compile time
  • Formatting (descriptors, ints, floats, etc...)
  • Writes where the message was sent from (function name)

Usage example

RFs fs;
User::LeaveIfError(fs.Connect());
CleanupClosePushL(fs);

_LIT(KLogFile, "c:\\log.txt");
RFile file;
file.Replace(fs, KLogFile, EFileWrite);
CleanupClosePushL(file);

CLogger *logger = CLogger::NewL(file, CLogger::ELevelAll & ~CLogger::ELevelDebug); // Prints all messages except Debug
CleanupStack::PushL(logger);
LoggerStatic::SetLogger(logger); // Set default logger

// You may use either 16 or 8-bit descriptors
LOG(_L16("Simple message in 16bit descriptor (uncategorized)"));
// or
LOG(_L8("Simple message in 8bit descriptor (uncategorized)"));

DEBUG(_L("This is debug message")); // This kind of message currently disabled in logger settings
INFO(_L("This is info message"));
WARNING(_L("This is warning message"));
_LIT(KErrTxt, "Not Found");
ERROR(_L("This is formatted error message with code: %d (%S)"), 404, &KErrTxt);

CleanupStack::PopAndDestroy(3, &fs); // logger + file + fs

LOG(_L("Logger already has been destroyed and this message won`t be included to the log file :("));

c:\log.txt file:

20:12:50.176	[LoggerDemo()]   Simple message in 16bit descriptor (uncategorized)
20:12:50.176	[LoggerDemo()]   Simple message in 8bit descriptor (uncategorized)
20:12:50.176	(Info)	[LoggerDemo()]   This is info message
20:12:50.176	(Warning)	[LoggerDemo()]   This is warning message
20:12:50.176	(Error)	[LoggerDemo()]   This is formatted error message with code: 404 (Not Found)

Dependings from libs

Don`t forget to add these libs in your project MMP-file:

  • efsrv.lib
  • estor.lib
  • charconv.lib

Limitations

  • Max strings length (with formatting) - 4 Kb

s60-logger's People

Contributors

artem78 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.